An image inpainting method, device, electronic equipment and storage medium

By automatically determining the scratch area through differential processing and scratch fitting, and using the benchmark tomographic image for automatic repair, the problem of relying on manual operation for scratch repair of tomographic images is solved, thus improving the repair quality and efficiency.

CN116739942BActive Publication Date: 2025-11-25山东数字人科技股份有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310796567.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-30
Publication Date
2025-11-25
Estimated Expiration
2043-06-30

AI Technical Summary

Technical Problem

Existing technologies for repairing scratches on interrupted layer images heavily rely on manual operation, resulting in low repair quality and efficiency.

Method used

By acquiring the target fault image and the reference fault image, differential processing is performed to determine the location and shape of the scratch. The scratch area is automatically determined using the scratch fitting line, and automatic repair is performed using the reference fault image.

Benefits of technology

It significantly reduces reliance on manual operation and improves the quality and efficiency of tomographic image scratch repair.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116739942B_ABST
    Figure CN116739942B_ABST
Patent Text Reader

Abstract

The application provides an image repairing method and device, electronic equipment and storage medium, and relates to the field of image repairing. The method comprises the following steps: obtaining a target tomographic image to be repaired and a reference tomographic image corresponding to the target tomographic image; performing difference processing on the target tomographic image and the reference tomographic image to obtain a difference image; fitting a scratch in the target tomographic image to obtain a scratch fitting line; determining a scratch region where the scratch is located in the difference image by using the scratch fitting line; and repairing the scratch in the target tomographic image by using the scratch region and the reference tomographic image. The scratch region where the scratch is located can be automatically determined according to the approximate position and approximate shape of the scratch in the target tomographic image, and the target tomographic image can be automatically repaired by using the scratch region and the reference tomographic image, so that the dependence of tomographic image scratch repair on manual operation can be reduced, and the quality and efficiency of tomographic image scratch repair can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of image inpainting, and in particular to an image inpainting method and device, an electronic device, and a computer readable storage medium. BACKGROUND

[0002] A tomographic image is an image obtained by collecting sectional data of a human body. In the image collection process, the problem of leaving a scratch in the tomographic image often occurs due to the non-parallelism between a cutter and a section. Since these scratches are not conducive to the use of the tomographic image, such as causing interference in medical diagnosis and digital conversion of the human body, it is necessary to remove these scratches.

[0003] In related technologies, the repair of scratches in a tomographic image relies heavily on manual operation, which significantly reduces the quality and efficiency of the repair of scratches in the tomographic image. SUMMARY

[0004] The purpose of the present application is to provide an image inpainting method and device, an electronic device, and a computer readable storage medium, which can automatically determine a scratch region where a scratch in a target tomographic image is located according to the approximate position and approximate shape of the scratch, and can automatically repair the scratch in the target tomographic image using the scratch region and a reference tomographic image, thereby reducing the dependence of the repair of scratches in the tomographic image on manual operation.

[0005] To solve the above technical problems, the present application provides an image inpainting method, comprising:

[0006] obtaining a target tomographic image to be repaired and a reference tomographic image corresponding to the target tomographic image;

[0007] differentially processing the target tomographic image and the reference tomographic image to obtain a difference image;

[0008] fitting a scratch in the target tomographic image to obtain a scratch fitting line;

[0009] determining a scratch region where the scratch is located in the difference image using the scratch fitting line;

[0010] repairing the scratch in the target tomographic image using the scratch region and the reference tomographic image.

[0011] Optionally, the obtaining of the target tomographic image to be repaired and the reference tomographic image corresponding to the target tomographic image comprises:

[0012] obtaining the target tomographic image from a sequence of tomographic images;

[0013] setting a previous or next tomographic image in the target tomographic image as the reference tomographic image.

[0014] Optionally, the differentiating the target tomographic image from the reference tomographic image to obtain a difference image comprises:

[0015] Converting the target tomographic image and the reference tomographic image into gray scale images;

[0016] Differentiating the converted target tomographic image from the converted reference tomographic image to obtain the difference image.

[0017] Optionally, the fitting the scratch in the target tomographic image to obtain a scratch fitting line comprises:

[0018] Receiving inputted multiple fitting points;

[0019] Fitting the scratch using the multiple fitting points and a preset fitting function to obtain the scratch fitting line.

[0020] Optionally, the determining a scratch region where the scratch is located in the difference image using the scratch fitting line comprises:

[0021] Receiving an inputted scratch width value and setting a search window according to the scratch width value;

[0022] Creating a scratch region image according to the size of the target tomographic image; the initial pixel value of each pixel point in the scratch region image is zero;

[0023] Moving the search window to a first scanning position on the scratch fitting line in the difference image; the scratch fitting line is provided with multiple scanning positions, and the search window is used to completely scan the scratch based on the multiple scanning positions;

[0024] Screening target pixel points belonging to the scratch from the pixel points currently covered by the search window;

[0025] Adjusting the pixel value of the pixel point at the corresponding position in the scratch region image to a preset value according to the position of the target pixel point;

[0026] When it is determined that there is an unscanned position in the multiple scanning positions, sequentially moving the search window to a next scanning position and entering the step of screening target pixel points belonging to the scratch from the pixel points currently covered by the search window;

[0027] When it is determined that there is no unscanned position in the multiple scanning positions, determining the scratch region based on the pixel points with the preset value in the scratch region image.

[0028] Optionally, the filtering out of the target pixel points belonging to the scratch from the pixel points currently covered by the search window comprises:

[0029] In the pixel points currently covered by the search window, the pixel point with a pixel value greater than a preset threshold is set as the target pixel point.

[0030] Optionally, the repairing of the scratch in the target tomographic image by using the scratch region and the reference tomographic image comprises:

[0031] performing inflation processing and filtering processing on the scratch region image;

[0032] generating a repair coefficient matrix according to the pixel values of the pixel points in the processed scratch region image; the repair coefficient matrix comprises repair coefficients corresponding to the pixel points in the target tomographic image;

[0033] repairing the scratch in the target tomographic image by using the repair coefficient matrix and the reference tomographic image.

[0034] The present application further provides an image repairing device, comprising:

[0035] an acquisition module configured to acquire a target tomographic image to be repaired and a reference tomographic image corresponding to the target tomographic image;

[0036] a difference processing module configured to perform difference processing on the target tomographic image and the reference tomographic image to obtain a difference image;

[0037] a fitting module configured to fit a scratch in the target tomographic image to obtain a scratch fitting line;

[0038] a scratch region determination module configured to determine a scratch region where the scratch is located in the difference image by using the scratch fitting line;

[0039] a repairing module configured to repair the scratch in the target tomographic image by using the scratch region and the reference tomographic image.

[0040] The present application further provides an electronic device, comprising:

[0041] a memory configured to store a computer program;

[0042] a processor configured to execute the computer program to implement the image repairing method as described above.

[0043] The present application further provides a computer readable storage medium, wherein the computer readable storage medium stores computer executable instructions, and the computer executable instructions are loaded and executed by a processor to implement the image repairing method as described above.

[0044] The present application provides a kind of image restoration method, comprising: obtaining the target tomographic image to be repaired and the reference tomographic image corresponding to the target tomographic image;The target tomographic image and the reference tomographic image are differentially processed, and difference image is obtained;Scratch in the target tomographic image is fitted, and scratch fitting line is obtained;Scratch area where the scratch is located in the difference image is determined using the scratch fitting line;Scratch in the target tomographic image is repaired using the scratch area and the reference tomographic image.

[0045] It can be seen that, first, the target tomographic image to be repaired and the reference tomographic image corresponding to the target tomographic image can be obtained, wherein the reference tomographic image contains image content similar to the target tomographic image;Subsequently, the target tomographic image and the reference tomographic image can be differentially processed to obtain a difference image, to determine the approximate position of the scratch in the target tomographic image, and the scratch in the target tomographic image can be fitted to obtain a scratch fitting line, to determine the approximate shape of the scratch in the target tomographic image;Furthermore, the scratch area where the scratch is located in the difference image can be automatically determined using the scratch fitting line, and the scratch in the target tomographic image can be automatically repaired using the scratch area and the reference tomographic image, which can significantly reduce the dependence of tomographic image scratch repair on manual operation, and thus can improve the quality and efficiency of tomographic image scratch repair. The present application also provides an image restoration device, an electronic device and a computer readable storage medium, which have the above beneficial effects. BRIEF DESCRIPTION OF DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor based on the provided drawings.

[0047] Figure 1 A flowchart of an image restoration method provided by an embodiment of the present application is shown in FIG. 1.

[0048] Figure 2 A schematic diagram of differentially processing the target tomographic image and the reference tomographic image to obtain a difference image is shown in FIG. 2.

[0049] Figure 3 A schematic diagram of a difference image obtained by differentially processing two adjacent tomographic images without scratch is shown in FIG. 3.

[0050] Figure 4 A schematic diagram of a fitting point marker is shown in FIG. 4.

[0051] Figure 5 A schematic diagram of a scratch fitting line provided by an embodiment of the present application;

[0052] Figure 6 A schematic diagram of searching by using a search window provided by an embodiment of the present application;

[0053] Figure 7 A schematic diagram of a scratch area image provided by an embodiment of the present application;

[0054] Figure 8 A schematic diagram of a processed scratch area image provided by an embodiment of the present application;

[0055] Figure 9 A schematic diagram of a target tomographic image before repair provided by an embodiment of the present application;

[0056] Figure 10 A schematic diagram of a target tomographic image after repair provided by an embodiment of the present application;

[0057] Figure 11 A flow chart of another image repair method provided by an embodiment of the present application;

[0058] Figure 12 A structure block diagram of an image repair device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0059] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0060] The tomographic image is an image obtained by collecting sectional data of a human body. During the image collection process, the problem of leaving a scratch in the tomographic image often occurs due to the non-parallelism between the cutter and the section. Since these scratches are not conducive to the use of the tomographic image, such as causing interference to medical diagnosis and human digitization conversion, it is necessary to remove these scratches. However, in the related art, the repair of the scratches in the tomographic image is heavily dependent on manual operation, for example, the complete scratch area needs to be manually marked, and then the marked scratch area is manually filled and repaired, which significantly reduces the quality and efficiency of the repair of the scratches in the tomographic image. Therefore, the present application can provide an image repair method, which can accurately determine the scratch area where the scratch is located according to the approximate position and shape of the scratch in the target tomographic image, and can automatically complete the repair of the scratch, thereby reducing the dependence of the repair of the image scratches on manual operation, and improving the quality and efficiency of the repair of the scratches in the tomographic image.

[0061] It should be noted that the embodiments of the present application do not limit the hardware devices for executing the method, for example, it can be a personal computer, a mobile device (such as a mobile phone, a tablet computer, etc.), a server, etc., which can be set according to actual application requirements.

[0062] Please refer to Figure 1 , Figure 1 A flowchart of an image repair method provided by the embodiments of the present application, which can include:

[0063] S100, acquiring a target tomographic image to be repaired and a reference tomographic image corresponding to the target tomographic image.

[0064] In the present embodiment, the target tomographic image refers to a tomographic image with scratches, and the reference tomographic image refers to a tomographic image with similar image content as the target tomographic image and without scratches. Since the main difference between the two images is the scratch, the distribution position of the scratch in the target tomographic image can be roughly determined after the target tomographic image and the reference tomographic image are differentially processed, thereby laying a foundation for accurately determining the position of the scratch.

[0065] It should be noted that since the tomographic images are usually collected in sequence, and the layer thickness of the tomographic image collection (i.e. the slice thickness interval between adjacent tomographic images) is generally small (such as 0.05mm-0.1mm), and the image content of adjacent slices is similar, therefore the reference tomographic image can be the adjacent previous or next one of the target tomographic image in the tomographic image sequence.

[0066] Based on this, acquiring the target tomographic image to be repaired and the reference tomographic image corresponding to the target tomographic image can include:

[0067] S101: acquiring the target tomographic image from the tomographic image sequence;

[0068] S101: set the previous or next tomographic image in the target tomographic images as a reference tomographic image.

[0069] S200: perform difference processing on the target tomographic image and the reference tomographic image to obtain a difference image.

[0070] As described above, since the main difference between the target tomographic image and the reference tomographic image is the scratch, the approximate position where the scratch is located can be clearly shown in the difference image obtained after the difference processing on the two images, so that the accurate position of the scratch can be determined subsequently. For the convenience of understanding, please refer to Figure 2 、 3 wherein Figure 2 the difference processing is performed on the target tomographic image and the reference tomographic image to obtain the difference image, Figure 3 the difference processing is performed on two adjacent tomographic images without scratches to obtain the difference image. It can be seen that, compared with the difference image obtained by performing difference processing on two adjacent tomographic images without scratches, the approximate position where the scratch is located is obviously shown in the difference image obtained by performing difference processing on the target tomographic image and the reference tomographic image.

[0071] It should be noted that the specific process of the difference processing is not limited in the embodiment, and can be referred to the related technologies of difference processing. In order to avoid the color of the image interfering with the difference processing result, the target tomographic image and the reference tomographic image can be converted into gray-scale images first, the colors in the two images are removed, and then the converted target tomographic image and the converted reference tomographic image are subjected to difference processing to obtain the difference image.

[0072] Based on this, the difference processing on the target tomographic image and the reference tomographic image to obtain the difference image can include:

[0073] S201: performing gray-scale image conversion on the target tomographic image and the reference tomographic image;

[0074] S202: performing difference processing on the converted target tomographic image and the converted reference tomographic image to obtain the difference image.

[0075] S300: fitting the scratch in the target tomographic image to obtain a scratch fitting line.

[0076] In addition to determining the approximate position of the scratch, the embodiment can also determine the approximate shape of the scratch using the scratch fitting line. Specifically, since the shape of the scratch is generally regular (such as a straight line, a circular arc, etc.), a preset fitting function can be set according to the general shape of the scratch to fit the scratch using the preset fitting function. In the specific implementation process, in order to ensure that the scratch fitting line fits the scratch, the operator needs to manually mark a plurality of fitting points corresponding to the scratch, such as marking the starting point, the intermediate point, etc. of the scratch (as shown in Figure 4 , wherein points A and C are starting points, and point B is an intermediate point); and after receiving the input fitting points, the device can automatically fit the scratch using the fitting points and the preset fitting function to obtain the scratch fitting line (as shown in Figure 5 ).

[0077] Based on this, fitting the scratch in the target fault image to obtain the scratch fitting line can include:

[0078] S301: Receive a plurality of input fitting points;

[0079] S302: Fit the scratch using the plurality of fitting points and a preset fitting function to obtain a scratch fitting line.

[0080] It should be noted that the embodiment does not limit the number of fitting points, and to achieve better fitting effect, the minimum number of fitting points can be set according to the shape of the scratch fitting line, for example, when the scratch fitting line is a straight line, the number of fitting points is at least two; when the scratch fitting line is a circular arc, the number of fitting points is at least three. Of course, the more fitting points the user correctly marks, the better the fitting effect. The embodiment also does not limit the specific preset fitting function, which can be a corresponding fitting function such as a straight line, a circular arc, etc. To facilitate user use, the embodiment can also set fitting functions corresponding to different shapes for user selection.

[0081] Further, it is worth pointing out that step S200 and step S300 can not be in sequence in the specific implementation process, and can be executed in parallel.

[0082] S400: Determine the scratch region where the scratch is located in the difference image using the scratch fitting line.

[0083] After the approximate position and approximate shape of the scratch are determined, the embodiment will accurately find the scratch region where the scratch is located in the difference image, wherein the region is composed of all pixel points belonging to the scratch. Specifically, the embodiment can preset a search window, which is used to slide along the scratch fitting line and scan the pixel points covered thereby to determine the target pixel points belonging to the scratch among the pixel points. The scratch fitting line is further provided with a plurality of scanning positions, and the search window can slide to each scanning position to completely scan the scratch. Further, the embodiment can also pre-create a scratch region image of the same size as the target tomographic image and all black, and can adjust the pixel value of the pixel point at the corresponding position in the scratch region image to a preset value (such as 255) according to the position of the target pixel point scanned by the search window, so as to completely mark the accurate position of the scratch region in the scratch region image. It should be pointed out that the embodiment does not limit the specific size of the search window, which can be a preset value or can be set according to the actual scratch width value. In order to be close to the actual situation, the embodiment can receive the scratch width value input by the user and set the search window according to the scratch width value.

[0084] Based on this, the scratch region where the scratch is located in the difference image is determined by using the scratch fitting line, which can include:

[0085] S401: receiving an input scratch width value and setting a search window according to the scratch width value;

[0086] S402: creating a scratch region image according to the size of the target tomographic image; the initial pixel value of each pixel point in the scratch region image is zero;

[0087] S403: moving the search window to the first scanning position on the scratch fitting line in the difference image; the scratch fitting line is provided with a plurality of scanning positions, and the search window completely scans the scratch based on the plurality of scanning positions;

[0088] S404: screening target pixel points belonging to the scratch from the pixel points currently covered by the search window;

[0089] S405: adjusting the pixel value of the pixel point at the corresponding position in the scratch region image to a preset value according to the position of the target pixel point;

[0090] S406: when it is determined that there is an unscanned position in the plurality of scanning positions, sequentially moving the search window to the next scanning position and entering the step of screening target pixel points belonging to the scratch from the pixel points currently covered by the search window;

[0091] S407: when it is determined that there is no unscanned position in the plurality of scanning positions, determining the scratch region based on the pixel points with the preset value in the scratch region image.

[0092] For the sake of understanding, reference is made to Figure 6 , Figure 6 The schematic diagram for searching by using the search window provided by the embodiment of the present application is shown in the figure, in which the white square represents the search window, which will move to each scanning position on the scratch fitting line in turn for scanning. After the scanning is completed, the scratch area image as shown in Figure 7 can be obtained, in which the white pixel points are all the pixel points constituting the scratch.

[0093] It should be noted that the embodiment does not limit how to screen the target pixel points belonging to the scratch. For example, the pixel points with pixel values greater than a preset threshold value can be set as the target pixel points; or the regions composed of non-zero pixel points in the search window can be determined, and the pixel points in the region with an area greater than a preset threshold value can be set as the target pixel points, which can be set according to actual application requirements. Considering that the pixel values of the scratch pixel points are significantly different from the pixel values of the non-scratch pixel points, in the embodiment, the pixel points with pixel values greater than a preset threshold value can be set as the target pixel points.

[0094] Based on this, screening the target pixel points belonging to the scratch from the pixel points currently covered by the search window can include:

[0095] S4041: In the pixel points currently covered by the search window, set the pixel points with pixel values greater than a preset threshold value as target pixel points.

[0096] It should be noted that the embodiment does not limit the specific value of the preset threshold value, which can be set according to actual application requirements.

[0097] Specifically, assuming that the size of the search window is w x h, p is a point on the scratch fitting line of the scratch, the coordinates are (x p ,y p ), and the filtering threshold value is T. The difference point is searched in the range of w x h with point p as the anchor point. The search window moves along the scratch fitting line, and the difference points are searched in turn. The value mode of the pixel value in the scratch area image can be formulated as:

[0098]

[0099] Among them, D is the difference image, and S represents the scratch area image.

[0100] S500, repairing the scratch in the target fault image by using the scratch area and the reference fault image.

[0101] After obtaining the accurate scratch region, this embodiment can use the image content located in that region of the reference tomographic image to replace the image content of the same region in the target tomographic image, thereby completing the repair of the scratch in the target tomographic image. However, simple region replacement can easily lead to a lack of smooth transition between the replaced content and the original content in the target tomographic image. Therefore, this embodiment can also perform smoothing transition processing on the replaced content to ensure a smooth transition between the replaced content and the original content in the target tomographic image. Specifically, this embodiment first performs dilation and filtering processing on the scratch region image. Dilation processing can expand the scratch region, and filtering processing can smooth the pixel values ​​of pixels in the boundary area between the scratch region and the non-scratched region. For easier understanding, please refer to... Figure 8 , Figure 8 This is a schematic diagram of the processed scratch region image provided in an embodiment of the present invention. The white portion represents the original scratch region, the black portion represents the non-scratched region, and the gray portion represents the boundary region expanded after dilation and filtering. The pixel value of this boundary region gradually transitions from 255 to 0 from the inside out. Subsequently, this embodiment can generate a repair coefficient matrix based on the pixel values ​​of each pixel in the processed scratch region image, and use the repair coefficient matrix and a reference tomographic image to repair the scratches in the target tomographic image. The repair coefficient matrix contains the repair coefficients corresponding to each pixel in the target tomographic image. For example, the pixel value of each pixel in the scratch region image can be divided by 255 to obtain the repair coefficient corresponding to each pixel. For pixels in the scratch region image with a pixel value of 255 (i.e., located at...)... Figure 8 For pixels in the white area of ​​the image, the repair coefficient is 1, and therefore this pixel needs to be completely replaced by the baseline tomographic image; for pixels with a value of 0 in the scratch area image (i.e., located in...), the repair coefficient is 1, and therefore this pixel needs to be completely replaced by the baseline tomographic image; Figure 8 For pixels in the black area of ​​the image, if the repair coefficient is 0, then the pixel does not need to be replaced at all; for pixels with pixel values ​​between 0 and 255 in the scratched area image (i.e., located in...), the repair coefficient is 0. Figure 8 If the pixel value of a pixel is in the gray area and its restoration coefficient is between 0 and 1, then the pixel value of that pixel will be obtained by fusing the pixel value in the reference tomographic image with the pixel value of the restoration coefficient based on the restoration coefficient.

[0102] Based on this, repairing scratches in a target tomographic image using the scratched area and a reference tomographic image can include:

[0103] S501. Perform dilation and filtering processing on the scratched area image;

[0104] S502. Generate a repair coefficient matrix based on the pixel values ​​of each pixel in the processed scratch area image; the repair coefficient matrix contains the repair coefficients corresponding to each pixel in the target tomographic image.

[0105] S503, repairing the scratch in the target tomographic image by using the repair coefficient matrix and the reference tomographic image.

[0106] In actual operation, the expansion size can be set as 1 / 2 of the width of the scratch; the filtering mode can adopt Gaussian filtering, and the filter size is consistent with the expansion size. The repair coefficient matrix can be constructed by using the processed scratch region image. Specifically, assuming that the processed scratch region image is F, then the repair coefficient matrix is Further, assuming that P is the target tomographic image, R is the reference tomographic image, P and R are both color images, and I is the repaired image, then:

[0107] I(x, y) = P(x, y) * (1-C(x, y)) + R(x, y) * C(x, y).

[0108] The specific repair effect can be seen from Figure 9 and Figure 10 , wherein the target tomographic image before repair is as shown in Figure 9 , and the target tomographic image after repair is as shown in Figure 10 It can be seen that the scratch in the target tomographic image has been repaired.

[0109] Based on the above embodiment, the target tomographic image to be repaired and the reference tomographic image corresponding to the target tomographic image can be obtained first, wherein the reference tomographic image contains image content similar to the target tomographic image; then, the target tomographic image and the reference tomographic image can be subjected to difference processing to obtain a difference image, so as to determine the approximate distribution position of the scratch in the target tomographic image, and the scratch in the target tomographic image can be fitted to obtain a scratch fitting line, so as to determine the approximate shape of the scratch in the target tomographic image; further, the scratch region where the scratch is located in the difference image can be determined automatically by using the scratch fitting line, and the scratch in the target tomographic image can be automatically repaired by using the scratch region and the reference tomographic image, which can significantly reduce the dependence of tomographic image scratch repair on manual operation, and further improve the quality and efficiency of tomographic image scratch repair.

[0110] The above image repair method will be introduced in detail below based on specific schematic diagrams. Please refer to Figure 11 , Figure 11 The flowchart of another image repair method provided by the embodiment of the present application. The flowchart can include:

[0111] Step 1: difference between the target tomographic image to be processed and the reference tomographic image to obtain a difference image.

[0112] Step 2: evenly select several points on the scratch of the target tomographic image, fit these points to obtain a scratch fitting line of the scratch.

[0113] Step 3: searching for difference points in the difference image according to a specific window along the scratch fitting line of the scratch to obtain a scratch area image.

[0114] Step 4: expanding the scratch area image, setting a filter, and constructing a repair coefficient matrix.

[0115] Step 5: repairing the scratch in the target tomographic image by using the repair coefficient matrix.

[0116] The image repair device, the electronic device and the computer readable storage medium provided by the embodiment of the present application are described below, and the image repair device, the electronic device and the computer readable storage medium described below can be mutually corresponding to the image repair method described above.

[0117] Please refer to Figure 12 , Figure 12 The structural block diagram of an image repair device provided by the embodiment of the present application can include:

[0118] The acquisition module 1201 is configured to acquire a target tomographic image to be repaired and a reference tomographic image corresponding to the target tomographic image.

[0119] The difference processing module 1202 is configured to perform difference processing on the target tomographic image and the reference tomographic image to obtain a difference image.

[0120] The fitting module 1203 is configured to fit the scratch in the target tomographic image to obtain a scratch fitting line.

[0121] The scratch area determination module 1204 is configured to determine a scratch area where the scratch is located in the difference image by using the scratch fitting line.

[0122] The repair module 1205 is configured to repair the scratch in the target tomographic image by using the scratch area and the reference tomographic image.

[0123] Optionally, the acquisition module 1201 can include:

[0124] The target tomographic image acquisition submodule is configured to acquire the target tomographic image from a tomographic image sequence.

[0125] The reference tomographic image acquisition submodule is configured to set a previous or next tomographic image in the target tomographic image as the reference tomographic image.

[0126] Optionally, the difference processing module 1202 can include:

[0127] The gray scale conversion submodule is configured to perform gray scale image conversion on the target tomographic image and the reference tomographic image.

[0128] The difference processing submodule is configured to perform difference processing on the converted target tomographic image and the converted reference tomographic image to obtain a difference image.

[0129] Optionally, the fitting module 1203 can include:

[0130] The receiving submodule is configured to receive a plurality of input fitting points.

[0131] The fitting submodule is configured to fit the scratch using the plurality of fitting points and a preset fitting function to obtain a scratch fitting line.

[0132] Optionally, the scratch region determining module 1204 can include:

[0133] The search window setting submodule is configured to receive an input scratch width value and set a search window according to the scratch width value.

[0134] The creating submodule is configured to create a scratch region image according to the size of the target tomographic image; and the initial pixel value of each pixel point in the scratch region image is zero.

[0135] The first search window moving submodule is configured to move the search window to a first scanning position on the scratch fitting line in the difference image; the scratch fitting line is provided with a plurality of scanning positions, and the search window is used to completely scan the scratch based on the plurality of scanning positions.

[0136] The screening submodule is configured to screen target pixel points belonging to the scratch from the pixel points currently covered by the search window.

[0137] The adjusting submodule is configured to adjust the pixel value of the pixel point at the corresponding position in the scratch region image to a preset value according to the position of the target pixel point.

[0138] The second search window moving submodule is configured to, when it is determined that there is an unscanned position in the plurality of scanning positions, sequentially move the search window to a next scanning position and enter the step of screening target pixel points belonging to the scratch from the pixel points currently covered by the search window.

[0139] The scratch region determining submodule is configured to, when it is determined that there is no unscanned position in the plurality of scanning positions, determine the scratch region based on the pixel points with the preset value in the scratch region image.

[0140] Optionally, the screening submodule is specifically configured to:

[0141] In the pixel points currently covered by the search window, set the pixel points with a pixel value greater than a preset threshold value as the target pixel points.

[0142] Optionally, the repairing module 1205 can include:

[0143] The processing submodule is configured to perform inflation processing and filtering processing on the scratch area image.

[0144] The repair coefficient matrix generating submodule is configured to generate a repair coefficient matrix according to pixel values of each pixel point in the processed scratch area image.

[0145] The repair submodule is configured to repair the scratch in the target tomographic image by using the repair coefficient matrix and the reference tomographic image.

[0146] The embodiment of the present application further provides an electronic device, which can comprise:

[0147] The memory is configured to store the computer program.

[0148] The processor is configured to implement the steps of the image repair method when executing the computer program.

[0149] Since the embodiment of the electronic device part corresponds to the embodiment of the image repair method part, the embodiment of the electronic device part is described in the description of the embodiment of the image repair method part, and will not be described here.

[0150] The embodiment of the present application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the image repair method of any embodiment.

[0151] Since the embodiment of the computer readable storage medium part corresponds to the embodiment of the image repair method part, the embodiment of the storage medium part is described in the description of the embodiment of the image repair method part, and will not be described here.

[0152] The embodiments in the description are described in a progressive manner, and each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the related parts can be referred to the method part.

[0153] The skilled person can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in the present application can be realized in electronic hardware, computer software or combination of the two. In order to clearly show the interchangeability of hardware and software, the components and steps of each example are described in the above description. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0154] The steps of a method or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in random access memory (RAM), flash memory, read-only memory (ROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium. In the alternative, hard disk can be used as a storage medium.

[0155] The above provides a kind of image repairing method, device, electronic equipment and computer readable storage medium provided by the present application.The principle and implementation of the present application are described in this paper by applying specific examples, the above example is only used to help understand the method and core idea of the present application.It should be pointed out that for the ordinary skilled person in the art, without departing from the principles of the present application, the present application can be improved and modified in several ways, and these improvements and modifications also fall within the scope of the claims of the present application.

Claims

1. An image inpainting method characterized by, The method comprises the following steps: obtaining a target tomographic image to be repaired and a reference tomographic image corresponding to the target tomographic image; wherein the reference tomographic image is not scratchy; differentially processing the target tomographic image and the reference tomographic image to obtain a differential image; fitting a scratch in the target tomographic image to obtain a scratch fitting line; determining a scratch region where the scratch is located in the differential image by using the scratch fitting line; repairing the scratch in the target tomographic image by using the scratch region and the reference tomographic image; the step of fitting the scratch in the target tomographic image to obtain a scratch fitting line comprises the following steps: receiving a plurality of input fitting points; fitting the scratch by using the plurality of fitting points and a preset fitting function to obtain the scratch fitting line; the step of determining the scratch region where the scratch is located in the differential image by using the scratch fitting line comprises the following steps: receiving an input scratch width value and setting a search window according to the scratch width value; creating a scratch region image according to the size of the target tomographic image; the initial pixel value of each pixel point in the scratch region image is zero; moving the search window to a first scanning position on the scratch fitting line in the differential image; the scratch fitting line is provided with a plurality of scanning positions, and the search window completely scans the scratch based on the plurality of scanning positions; screening target pixel points belonging to the scratch from the pixel points currently covered by the search window; adjusting the pixel value of the pixel point at the corresponding position in the scratch region image to a preset value according to the position of the target pixel point; when it is determined that there is an unscanned position in the plurality of scanning positions, sequentially moving the search window to the next scanning position and entering the step of screening target pixel points belonging to the scratch from the pixel points currently covered by the search window; when it is determined that there is no unscanned position in the plurality of scanning positions, determining the scratch region based on the pixel points with the preset value in the scratch region image.

2. The image inpainting method of claim 1, wherein, The step of obtaining the target tomographic image to be repaired and the reference tomographic image corresponding to the target tomographic image comprises the following steps: obtaining the target tomographic image from a tomographic image sequence; setting the previous or next tomographic image in the target tomographic image as the reference tomographic image.

3. The image inpainting method of claim 1, wherein, The step of differentially processing the target tomographic image and the reference tomographic image to obtain a differential image comprises the following steps: performing gray image conversion on the target tomographic image and the reference tomographic image; differentially processing the converted target tomographic image and the converted reference tomographic image to obtain the differential image.

4. The image inpainting method of claim 1, wherein, The step of screening target pixel points belonging to the scratch from the pixel points currently covered by the search window comprises the following steps: in the pixel points currently covered by the search window, setting the pixel points with a pixel value greater than a preset threshold value as the target pixel points.

5. The image inpainting method of claim 1, wherein, The step of repairing the scratch in the target tomographic image by using the scratch region and the reference tomographic image comprises the following steps: performing inflation processing and filtering processing on the scratch region image; Generate a repair coefficient matrix according to the pixel value of each pixel point in the processed scratch area image; the repair coefficient matrix contains the repair coefficient corresponding to each pixel point in the target fault image; Repair the scratch in the target fault image by using the repair coefficient matrix and the reference fault image.

6. An image inpainting apparatus characterized by comprising: Comprise: An acquisition module is used to acquire a target fault image to be repaired and a reference fault image corresponding to the target fault image; wherein the reference fault image does not have a scratch; A difference processing module is used to perform difference processing on the target fault image and the reference fault image to obtain a difference image; A fitting module is used to fit the scratch in the target fault image to obtain a scratch fitting line; A scratch area determination module is used to determine a scratch area where the scratch is located in the difference image by using the scratch fitting line; A repair module is used to repair the scratch in the target fault image by using the scratch area and the reference fault image; The fitting module comprises: A receiving sub-module is used to receive a plurality of input fitting points; A fitting sub-module is used to fit the scratch by using the plurality of fitting points and a preset fitting function to obtain the scratch fitting line; The scratch area determination module comprises: A search window setting sub-module is used to receive an input scratch width value and set a search window according to the scratch width value; A creating sub-module is used to create a scratch area image according to the size of the target fault image; the initial pixel value of each pixel point in the scratch area image is zero; A first search window moving sub-module is used to move the search window to the first scanning position on the scratch fitting line in the difference image; a plurality of scanning positions are arranged on the scratch fitting line, and the search window completely scans the scratch based on the plurality of scanning positions; A screening sub-module is used to screen target pixel points belonging to the scratch from the pixel points currently covered by the search window; An adjusting sub-module is used to adjust the pixel value of the pixel point at the corresponding position in the scratch area image to a preset value according to the position of the target pixel point; A second search window moving sub-module is used to sequentially move the search window to the next scanning position when it is determined that there is an unscanned position in the plurality of scanning positions, and enter the step of screening target pixel points belonging to the scratch from the pixel points currently covered by the search window; A scratch area determination sub-module is used to determine the scratch area based on the pixel points with the preset value in the scratch area image when it is determined that there is no unscanned position in the plurality of scanning positions.

7. An electronic device, comprising: Comprise: A memory is used to store a computer program; A processor is used to execute the computer program to implement the image repair method in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions, and the computer executable instructions are loaded and executed by the processor to implement the image repair method in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Scratch detection method, apparatus and electronic device based on image processing

    CN106920233A

  • Video processing method and device, electronic equipment and storage medium

    CN115049555A