Image local region repairing method and device
By extracting the bad line region from an X-ray flat panel detector, performing grayscale probability distribution conversion and multiple filtering processes, the problems of insufficient information utilization and missing stripes during stitching in bad line region restoration are solved, achieving a more natural image restoration effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-22
- Publication Date
- 2026-03-24
AI Technical Summary
Existing technologies cannot effectively utilize the original image information when repairing bad line areas of X-ray flat panel detectors, resulting in significant deviations between the repaired area and surrounding pixels, and the loss of bar information during image stitching.
By acquiring the image to be repaired, the bad line area is extracted and traversed row by row or column by column to form a reference area. Then, through grayscale probability distribution conversion and multiple filtering processes, the grayscale probability distribution of the bad line area is ensured to be consistent with that of the reference area. Finally, sliding window filtering is performed to eliminate edge distortion.
It effectively improves the effect of bad line repair and image stitching in flat panel detector imaging. The edges of bad lines in the repaired image are not obvious, there are no obvious distorted pixels, and a more natural image transition is achieved.
Smart Images

Figure CN115330609B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of X-ray flat panel detector imaging, and specifically relates to a method and apparatus for local area restoration of images. Background Technology
[0002] Flat panel digital detectors represent a leap forward in clinical imaging technology. X-rays, after passing through the human body, undergo varying degrees of attenuation before reaching the flat panel detector. The detector captures the X-rays and converts the photoelectric signal into a digital signal. This digital image data is then stored and processed within the acquisition workstation. However, due to the varying sensitivity of each pixel within the flat panel detector to X-rays over prolonged use, inconsistencies may appear in the computer-generated image. These inconsistencies require periodic correction. However, this correction often results in areas with poor grayscale values appearing significantly lower than adjacent areas. Because CT images have a high grayscale level (e.g., a 16-bit image contains 65,536 grayscale levels), these areas often appear as black—areas invisible to the human eye—but they do contain usable information, such as… Figure 1 As shown.
[0003] Furthermore, in practice, flat panel detectors have a maximum size, typically 17 inches x 17 inches, limited by manufacturing equipment and processes. Exceeding this maximum size makes it impossible to image the entire object (e.g., taking X-rays of very large animals, inspecting oversized objects at security checkpoints, and examining the human spine). Since X-rays cannot be deflected like visible light, the object being inspected must be placed between the X-ray source and the detector, using a detector of the same size to receive the attenuated X-rays, thus enabling imaging of the object's internal structure. Therefore, multiple flat panel detectors need to be stitched together. Due to technological limitations, seams are unavoidable, appearing as strip-shaped gaps in the image, requiring processing and repair.
[0004] Existing methods for repairing bad lines or stitching images often employ techniques such as image histogram equalization, image interpolation, and filtering, which utilize local pixel distribution to replace the pixel distribution in the damaged area.
[0005] For example, Chinese patent application CN20101035142.0 discloses a method and apparatus for processing bad lines in X-ray flat panel detector images. This method first detects the location of the bad line in the X-ray flat panel detector, and then uses the image data of non-bad line image pixels in the neighborhood of the bad line to calculate the compensation amount, thereby repairing the bad line in the image. This method ignores the pixel values of each pixel in the bad line area, thus discarding useful information.
[0006] Chinese patent application CN201310441747.6 proposes a method for repairing bad lines in X-ray flat panel detector images. This method processes the image using interpolation smoothing in the vertical direction of the bad line, utilizing the undamaged pixel regions surrounding the bad line's coordinates. However, this method also ignores the pixel values of individual pixels within the bad line, relying solely on image information from adjacent undamaged regions to smooth and interpolate the damaged area. It fails to effectively utilize the original image information for maximum restorative repair.
[0007] Moreover, the area edges of the above methods still have obvious deviations from the surrounding pixels, the problem areas do not achieve good elimination effects, and the useful information of the bad line areas cannot be fully utilized. Summary of the Invention
[0008] To address the aforementioned technical problems, this invention proposes a method and apparatus for image local region restoration.
[0009] To achieve the above objectives, the technical solution of the present invention is as follows:
[0010] On one hand, this invention discloses a method for local region restoration of an image, comprising the following steps:
[0011] S1: Obtain the image to be repaired;
[0012] S2: Extract the bad line region from the image to be repaired obtained in S1;
[0013] S3: Process the bad line area by traversing the bad line area row by row or column by column, and stitch together the pixels before and after the bad line area to form a reference area.
[0014] S4: Perform a conversion process on the bad line area so that the gray level probability distribution of the converted bad line area is consistent with the gray level probability distribution of the reference area;
[0015] S5: Filter the bad line area after conversion.
[0016] Based on the above technical solution, the following improvements can be made:
[0017] As a preferred solution, S4 specifically includes the following steps:
[0018] S4.1: Calculate the cumulative probability distribution of pixel grayscale values in the bad line region and the reference region respectively. and
[0019] Where, r m and z n represents the grayscale level of the image pixel value in the bad line region and the reference region, respectively; m and n are the values of the grayscale level with the highest cumulative probability in the bad line region and the reference region, respectively; Pr and P z These represent the probabilities of gray levels in the bad line region and the reference region, respectively.
[0020] S4.2: Calculate the absolute difference between the cumulative probability of each gray level in the bad line area and the cumulative probability of each gray level in the reference area;
[0021] S4.3: Use the gray value corresponding to the minimum difference obtained in S4.2 as the mapping value from the bad line region to the reference image, and generate the mapping relationship;
[0022] S4.4: Modify the pixel values at each location in the bad line area to the corresponding pixel values according to the mapping relationship.
[0023] As a preferred solution, S5 specifically includes the following steps:
[0024] S5.1: Merge the converted bad line region and the reference region into a single region, which is the region to be filtered;
[0025] S5.2: Perform preliminary filtering on the region to be filtered;
[0026] S5.3: Perform sliding window filtering on the region after initial filtering.
[0027] As a preferred option, the preliminary filtering method in S5.2 includes the following:
[0028] Set a threshold range, and replace pixel values outside the threshold range in the region to be filtered with the median value of the region to be filtered.
[0029] As a preferred option, the sliding window filtering method in S5.3 includes the following:
[0030] Set up a sliding window. Within the sliding window area, first perform a median filter, then perform a Gaussian filter on the pixels in the sliding window area, and finally take the average value.
[0031] On the other hand, the present invention also discloses an image local area restoration device, comprising:
[0032] Image acquisition module, used to acquire the image to be repaired;
[0033] The bad line region extraction module is used to extract the bad line region on the image to be repaired acquired by the image acquisition module.
[0034] The reference region generation module is used to process the bad line region by traversing the bad line region row by row or column by column and splicing the pixels before and after the bad line region to form a reference region.
[0035] The conversion module is used to convert the bad line area so that the gray probability distribution of the converted bad line area is consistent with the gray probability distribution of the reference area.
[0036] The filtering module is used to filter the bad line areas after conversion.
[0037] As a preferred option, the conversion module specifically includes:
[0038] The probability distribution calculation unit is used to calculate the cumulative probability distribution of pixel grayscale values in the bad line region. The cumulative probability distribution of pixel grayscale values in the reference region;
[0039] Where, r m and z n These represent the grayscale values of the image pixels in the bad line region and the reference region, respectively.
[0040] m and n are the values of the gray level with the highest cumulative probability in the bad line region and the reference region, respectively.
[0041] P r and P z These represent the probabilities of gray levels in the bad line region and the reference region, respectively.
[0042] The absolute value difference calculation unit is used to calculate the absolute value difference between the cumulative probability of each gray level in the bad line area and the cumulative probability of each gray level in the reference area.
[0043] The pixel processing unit is used to take the gray value corresponding to the minimum difference obtained by the absolute value difference calculation unit as the mapping value from the bad line area to the reference image, generate the mapping relationship, and modify the pixel value of each place in the bad line area to the corresponding pixel value according to the mapping relationship.
[0044] As a preferred embodiment, the filtering module specifically includes:
[0045] The merging unit is used to merge the converted bad line region and the reference region into a single region, which is the region to be filtered.
[0046] The preliminary filtering unit is used to perform preliminary filtering on the region to be filtered.
[0047] The sliding window filtering unit is used to perform sliding window filtering on the region after the initial filtering.
[0048] As a preferred embodiment, the preliminary filtering unit performs filtering through the following steps:
[0049] Set a threshold range, and replace pixel values outside the threshold range in the region to be filtered with the median value of the region to be filtered.
[0050] As a preferred embodiment, the sliding window filtering unit performs filtering using the following methods:
[0051] Set up a sliding window. Within the sliding window area, first perform a median filter, then perform a Gaussian filter on the pixels in the sliding window area, and finally take the average value.
[0052] This invention discloses a method and apparatus for local image restoration. It employs regional pixel value probability distribution conversion and multiple filtering operations to effectively improve the effect of bad line restoration or image stitching in flat panel detector imaging. The restored image has indistinct bad line edges and no obvious distorted pixels. Attached Figure Description
[0053] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 This is a schematic diagram illustrating the occurrence of bad lines after imaging using existing flat panel detectors.
[0055] Figures (a) and (b) show the images of different regions.
[0056] Figure 2 This is a flowchart of an image local area restoration method provided in an embodiment of the present invention.
[0057] Figure 3 This is a processing roadmap for the image local region restoration method provided in an embodiment of the present invention.
[0058] Figure 4 This is a schematic diagram of the bad line area after conversion processing provided by an embodiment of the present invention;
[0059] Figures (a) and (b) show the images of different regions.
[0060] Figure 5 This is a schematic diagram of a sliding window filter provided in an embodiment of the present invention.
[0061] Figure 6 Comparison images before and after repair provided for embodiments of the present invention;
[0062] Among them: Figure (a) is one of the images with bad lines, and Figure (b) is one of the images after restoration;
[0063] Figure (c) is the second image with bad lines, and Figure (d) is the second image after repair.
[0064] Figure (e) shows the third image with bad lines, and Figure (f) shows the third image after repair. Detailed Implementation
[0065] The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0066] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0067] Using ordinal numbers such as “first,” “second,” “third,” etc. to describe ordinary objects merely indicates different instances of similar objects and is not intended to imply that the objects being described must have a given order in time, space, sequence, or any other way.
[0068] Furthermore, the expression "includes" is an "open-ended" expression, which only means that the corresponding component exists and should not be interpreted as excluding additional components.
[0069] To achieve the objectives of this invention, some embodiments of an image local region restoration method and apparatus are provided, such as... Figure 2-3 As shown, the image local area restoration method includes the following steps:
[0070] S1: Obtain the image to be repaired;
[0071] S2: Extract the bad line region from the image to be repaired obtained in S1;
[0072] S3: Process the bad line area by traversing the bad line area row by row or column by column, and stitch together the pixels before and after the bad line area to form a reference area.
[0073] S4: Perform a conversion process on the bad line area so that the gray level probability distribution of the converted bad line area is consistent with the gray level probability distribution of the reference area;
[0074] S5: Filter the bad line area after conversion.
[0075] During the repair process, the entire image should transition as naturally as possible. Therefore, the pixel distribution of the area to be repaired should be as similar as possible to the distribution of the surrounding pixels. In some specific embodiments, in S3, the bad line area is traversed row by row or column by column, and N pixels before and after the bad line interval are stitched together. The value of N depends on the width of the bad line and its proportion in the entire image.
[0076] The bad line area is used as the area to be transformed, and the goal is to make the gray probability distribution of the transformed bad line area consistent with that of the reference area.
[0077] The mathematical model is derived as follows. Assume that the pixel gray level of the bad line region is r, and the pixel gray level of the image after probability distribution normalization is s1. From the normalization, we can see that the mapping relationship T(r) between r and s1 is as shown in equation (1):
[0078] s1=T(r)=(L-1)×∫P r (w)dw; (1)
[0079] In the formula, P r (w) represents the probability distribution of the gray values of r, and L represents the gray level of the pixel values in the bad line region of the image.
[0080] Similarly, the reference image is also normalized in terms of probability distribution. Assuming the pixel gray level of the reference region is z, and the pixel gray level of the image after probability distribution normalization is s2, the mapping relationship G(z) between z and s2 is shown in equation (2) as follows:
[0081] s2=G(z)=(L-1)×∫P z (t)dt; (2)
[0082] In the formula, P z (w) represents the probability distribution of the z grayscale values.
[0083] Because it is assumed that the cumulative probability distribution of the bad line region is consistent with that of the reference region, i.e., ∫P z (w)dw and ∫P r Since (t)dt is consistent, s = s1 = s2, and therefore z = G -1 (T(r))=G -1 (s).
[0084] In discrete space, then we have
[0085] Where, r m and z n These are the pixel gray levels of the bad line region and the reference region, respectively. Therefore, if we want to obtain r... m To z n The mapping relationship is such that, in practice, it is sufficient to ensure that the cumulative probability distributions of the two are similar.
[0086] Therefore, in some embodiments, S4 specifically includes the following steps:
[0087] S4.1: Calculate the cumulative probability distribution of pixel grayscale values in the bad line region and the reference region respectively. and
[0088] Where, r m z and zn are the image pixel values of the bad line region and the reference region, respectively;
[0089] m and n are the values of the gray level with the highest cumulative probability in the bad line region and the reference region, respectively.
[0090] Pr and Pz are the probabilities of the gray levels in the bad line region and the reference region, respectively.
[0091] S4.2: Calculate the absolute difference between the cumulative probability of each gray level in the bad line area and the cumulative probability of each gray level in the reference area;
[0092] S4.3: Use the gray value corresponding to the minimum difference obtained in S4.2 as the mapping value from the bad line region to the reference image, and generate the mapping relationship;
[0093] S4.4: Modify the pixel values at each location in the bad line area to the corresponding pixel values according to the mapping relationship.
[0094] The result after converting the bad line area is as follows Figure 4 As shown.
[0095] like Figure 4 As shown, the result of the distribution transformation repairs some areas, but there are still problems such as obvious edges and insufficient removal of bad lines. Therefore, it is necessary to blur the edges of the bad lines and filter out the remaining parts.
[0096] Furthermore, in some embodiments, such as Figure 5 As shown, S5 specifically includes the following steps:
[0097] S5.1: Merge the converted bad line region and the reference region into a single region, which is the region to be filtered;
[0098] S5.2: Perform preliminary filtering on the region to be filtered;
[0099] S5.3: Perform sliding window filtering on the region after initial filtering.
[0100] The preliminary filtering method in S5.2 includes the following:
[0101] Set a threshold range, and replace pixel values outside the threshold range in the region to be filtered with the median value of the region to be filtered.
[0102] Preliminary filtering can eliminate noise present in the material to be filtered.
[0103] The sliding window filtering method in S5.3 includes the following:
[0104] Set up a sliding window. Within the sliding window area, first perform a median filter, then perform a Gaussian filter on the pixels in the sliding window area, and finally take the average value.
[0105] Performing a median filter within the sliding window area can effectively ensure that distorted pixel values are completely filtered out.
[0106] Sliding window filtering can effectively remove distortion points and smooth edges.
[0107] Furthermore, in some other embodiments, the present invention also discloses an image local area restoration apparatus, comprising:
[0108] Image acquisition module, used to acquire the image to be repaired;
[0109] The bad line region extraction module is used to extract the bad line region on the image to be repaired acquired by the image acquisition module.
[0110] The reference region generation module is used to process the bad line region by traversing the bad line region row by row or column by column and splicing the pixels before and after the bad line region to form a reference region.
[0111] The conversion module is used to convert the bad line area so that the gray probability distribution of the converted bad line area is consistent with the gray probability distribution of the reference area.
[0112] The filtering module is used to filter the bad line areas after conversion.
[0113] It is worth noting that the mathematical model of the conversion module in the image local region restoration device disclosed in this invention is the same as the mathematical model described in the image local region restoration method, and will not be repeated here.
[0114] Furthermore, in some embodiments, the conversion module specifically includes:
[0115] The probability distribution calculation unit is used to calculate the cumulative probability distribution of pixel grayscale values in the bad line region. Cumulative probability distribution of pixel grayscale values in the reference region
[0116] Where, rm and z n These represent the grayscale values of the image pixels in the bad line region and the reference region, respectively.
[0117] m and n are the values of the gray level with the highest cumulative probability in the bad line region and the reference region, respectively.
[0118] P r and P z These represent the probabilities of gray levels in the bad line region and the reference region, respectively.
[0119] The absolute value difference calculation unit is used to calculate the absolute value difference between the cumulative probability of each gray level in the bad line area and the cumulative probability of each gray level in the reference area.
[0120] The pixel processing unit is used to take the gray value corresponding to the minimum difference obtained by the absolute value difference calculation unit as the mapping value from the bad line area to the reference image, generate the mapping relationship, and modify the pixel value of each place in the bad line area to the corresponding pixel value according to the mapping relationship.
[0121] Furthermore, in some embodiments, the filtering module specifically includes:
[0122] The merging unit is used to merge the converted bad line region and the reference region into a single region, which is the region to be filtered.
[0123] The preliminary filtering unit is used to perform preliminary filtering on the region to be filtered.
[0124] The sliding window filtering unit is used to perform sliding window filtering on the region after the initial filtering.
[0125] Furthermore, in some embodiments, the preliminary filtering unit performs filtering by:
[0126] Set a threshold range, and replace pixel values outside the threshold range in the region to be filtered with the median value of the region to be filtered.
[0127] Furthermore, in some embodiments, the sliding window filtering unit performs filtering using the following methods:
[0128] Set up a sliding window. Within the sliding window area, first perform a median filter, then perform a Gaussian filter on the pixels in the sliding window area, and finally take the average value.
[0129] It is worth noting that, in some embodiments, the present invention also discloses a computing device, which includes:
[0130] One or more processors;
[0131] Memory;
[0132] And one or more programs, wherein the one or more programs are stored in memory and configured to be executed by one or more processors, and the one or more programs include instructions for the image local region restoration method disclosed in any of the above embodiments.
[0133] In other embodiments, the present invention also discloses a computer-readable storage medium, wherein one or more programs include instructions adapted to be loaded by a memory and to execute the image local region restoration method disclosed in any of the above embodiments.
[0134] In some specific embodiments, the image local region restoration method and apparatus disclosed in this invention were used for experiments.
[0135] The first step is to use a region pixel value probability distribution transformation; the second step is to use multiple smoothing filtering operations to obtain the final repair result, as shown below. Figure 6 As shown.
[0136] like Figure 6 As shown, the final result has no obvious bad line edges and no obvious distorted pixels, achieving a good effect.
[0137] This invention discloses a method and apparatus for local area image repair, which can effectively improve the effect of bad line repair or image stitching in flat panel detector imaging. The repaired image has inconspicuous bad line edges and no obvious distorted pixels.
[0138] It should be understood that the various techniques described herein can be implemented in combination with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embedded in a tangible medium, such as a floppy disk, CD-ROM, hard disk, or any other machine-readable storage medium, wherein when the program is loaded into and executed by a machine such as a computer, that machine becomes an apparatus for practicing the present invention.
[0139] The above embodiments are only for illustrating the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the content of the present invention and implement it. They should not be used to limit the scope of protection of the present invention. All equivalent changes or modifications made in accordance with the spirit and essence of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A method for local region restoration in images, characterized in that, Includes the following steps: S1: Obtain the image to be repaired; S2: Extract the bad line region from the image to be repaired obtained in S1; S3: Process the bad line area by traversing the bad line area row by row or column by column, and stitch together the pixels before and after the bad line area to form a reference area. S4: Perform a conversion process on the bad line area so that the gray level probability distribution of the converted bad line area is consistent with the gray level probability distribution of the reference area; S5: Filter the bad line area after conversion; S4 specifically includes the following steps: S4.1: Calculate the cumulative probability distribution of pixel grayscale values in the bad line region and the reference region respectively. and Where, r m and z n These represent the grayscale values of the image pixels in the bad line region and the reference region, respectively. m and n are the values of the gray level with the highest cumulative probability in the bad line region and the reference region, respectively. P r and P z These represent the probabilities of gray levels in the bad line region and the reference region, respectively. S4.2: Calculate the absolute difference between the cumulative probability of each gray level in the bad line area and the cumulative probability of each gray level in the reference area; S4.3: Use the gray value corresponding to the minimum difference obtained in S4.2 as the mapping value from the bad line region to the reference image, and generate the mapping relationship; S4.4: Modify the pixel values at each location in the bad line area to the corresponding pixel values according to the mapping relationship.
2. The image local region restoration method according to claim 1, characterized in that, S5 specifically includes the following steps: S5.1: Merge the converted bad line region and the reference region into a single region, which is the region to be filtered; S5.2: Perform preliminary filtering on the region to be filtered; S5.3: Perform sliding window filtering on the region after initial filtering.
3. The image local region restoration method according to claim 2, characterized in that, The preliminary filtering method in S5.2 includes the following: Set a threshold range, and replace pixel values outside the threshold range in the region to be filtered with the median value of the region to be filtered.
4. The image local region restoration method according to claim 2, characterized in that, The sliding window filtering method in S5.3 includes the following: Set up a sliding window. Within the sliding window area, first perform a median filter, then perform a Gaussian filter on the pixels in the sliding window area, and finally take the average value.
5. An image local area restoration device, characterized in that, include: An image acquisition module is used to acquire the image to be repaired. A bad line region extraction module, wherein the extraction module is used to extract bad line regions on the image to be repaired acquired by the image acquisition module; A reference region generation module is used to process the bad line region by traversing the bad line region row by row or column by column and splicing the pixels before and after the bad line region to form a reference region. A conversion module is used to convert the bad line region so that the gray probability distribution of the converted bad line region is consistent with the gray probability distribution of the reference region. A filtering module is used to filter the converted bad line region; The conversion module specifically includes: The probability distribution calculation unit is used to calculate the cumulative probability distribution of pixel grayscale values in the bad line region. Cumulative probability distribution of pixel grayscale values in the reference region Where, r m and z n These represent the grayscale values of the image pixels in the bad line region and the reference region, respectively. m and n are the values of the gray level with the highest cumulative probability in the bad line region and the reference region, respectively. P r and P z These represent the probabilities of gray levels in the bad line region and the reference region, respectively. An absolute value difference calculation unit is used to calculate the absolute value difference between the cumulative probability of each gray level in the bad line area and the cumulative probability of each gray level in the reference area. A pixel processing unit is used to take the gray value corresponding to the minimum difference obtained by the absolute value difference calculation unit as the mapping value from the bad line area to the reference image, generate a mapping relationship, and modify the pixel values at each location in the bad line area to the corresponding pixel values according to the mapping relationship.
6. The image local area restoration device according to claim 5, characterized in that, The filtering module specifically includes: The merging unit is used to merge the converted bad line region and the reference region into a single region, which is the region to be filtered. A preliminary filtering unit is used to perform preliminary filtering on the region to be filtered. A sliding window filtering unit is used to perform further sliding window filtering on the region after preliminary filtering.
7. The image local area restoration device according to claim 6, characterized in that, The preliminary filtering unit performs filtering through the following: Set a threshold range, and replace pixel values outside the threshold range in the region to be filtered with the median value of the region to be filtered.
8. The image local region restoration method according to claim 6, characterized in that, The sliding window filtering unit performs filtering based on the following: Set up a sliding window. Within the sliding window area, first perform a median filter, then perform a Gaussian filter on the pixels in the sliding window area, and finally take the average value.
Citation Information
Patent Citations
A method for repairing bad lines in X-ray flat panel detector images
CN104463831B
Method for processing faulty wire of x-ray flat panel detector image and device thereof
CN101795349A
Shiitake mushroom damage detection method based on machine vision
CN111986192A