Image processing method and apparatus
By performing differential gradient calculation and threshold judgment on single-channel images, the storage space and computational complexity issues of image sensor bad pixel correction are solved, achieving effective bad pixel correction and noise reduction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SINOSURGICAL HEALTHCARE TECH BEIJING CO LTD
- Filing Date
- 2023-08-24
- Publication Date
- 2026-04-14
AI Technical Summary
In existing technologies, methods for correcting bad pixels in image sensors require large storage space or are computationally complex and slow, and different filtering methods can result in the loss of image detail information.
By performing differential gradient calculation and threshold judgment on a single-channel image, bad pixels are identified and corrected, generating a corrected single-channel image.
It effectively corrects bad pixels while reducing image noise, improving correction speed without losing image details.
Smart Images

Figure CN117196973B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and more specifically to an image processing method and apparatus. Background Technology
[0002] Image sensors inevitably develop dead pixels during manufacturing and use. Dead pixels typically exist in two forms: bright spots and dark spots. Since dead pixels are permanently located within the photosensitive element, they cannot detect changes in ambient light and color, causing images to fail to accurately represent real-world scenes. Therefore, it is necessary to correct existing dead pixels during image processing.
[0003] Currently, there are generally two methods for correcting bad pixels. One method is to pre-record the location of the bad pixels and directly retrieve that location for correction during use. This method requires a large amount of storage space to record the location information, and it cannot effectively correct bad pixels generated during use. The other method is through filtering, which does not require storing location information, but this detection method is complex, has a slow calculation speed, and different filtering methods can cause some loss of image detail information. Summary of the Invention
[0004] In view of the above problems, the present invention provides an image processing method and apparatus.
[0005] According to a first aspect of the present invention, an image processing method is provided, comprising: in response to acquiring an image to be processed, obtaining a plurality of single-channel images corresponding to the image to be processed; for non-edge pixels in each single-channel image, determining a first target point corresponding to each single-channel image based on the gray value of each non-edge pixel; performing differential gradient calculation in multiple horizontal and vertical directions for the first target point in each single-channel image to obtain a calculation result corresponding to each first target point; acquiring a threshold, and determining a second target point among the first target points based on each calculation result and the threshold; and correcting the gray value of each second target point to obtain a plurality of corrected single-channel images.
[0006] According to an embodiment of the present invention, the method further includes: generating a target image based on the plurality of corrected single-channel images.
[0007] According to an embodiment of the present invention, determining a first target point corresponding to each single-channel image based on the grayscale value of each non-edge pixel in each single-channel image includes: for any non-edge pixel, obtaining the grayscale values of neighboring pixels surrounding the non-edge pixel to obtain a plurality of neighboring pixel grayscale values; determining the maximum and minimum values among the plurality of neighboring pixel grayscale values; obtaining the grayscale value of the non-edge pixel; determining whether to use the non-edge pixel as the first target point based on the comparison result between the maximum value and the grayscale value of the non-edge pixel; and determining whether to use the non-edge pixel as the first target point based on the comparison result between the minimum value and the grayscale value of the non-edge pixel.
[0008] According to an embodiment of the present invention, the step of performing differential gradient calculations in multiple horizontal and vertical directions for a first target point in each single-channel image to obtain a calculation result corresponding to each first target point includes: for any first target point, obtaining the grayscale values of neighboring pixels around the first target point; wherein, the grayscale values of neighboring pixels around the first target point include a first grayscale value of a pixel west of the first target point, a second grayscale value of a pixel east of the first target point, a third grayscale value of a pixel north of the first target point, a fourth grayscale value of a pixel south of the first target point, a fifth grayscale value of a pixel northwest of the first target point, a sixth grayscale value of a pixel southeast of the first target point, and a sixth grayscale value of a pixel northeast of the first target point. The algorithm obtains the seventh gray value of the adjacent pixels in the direction of the first target point and the eighth gray value of the adjacent pixels in the southwest direction of the first target point; obtains the gray value of the first target point; obtains a first calculated value for differential gradient calculation based on the gray value of the first target point, the first gray value, and the second gray value; obtains a second calculated value for differential gradient calculation based on the gray value of the first target point, the third gray value, and the fourth gray value; obtains a third calculated value for differential gradient calculation based on the gray value of the first target point, the fifth gray value, and the sixth gray value; obtains a fourth calculated value for differential gradient calculation based on the gray value of the first target point, the seventh gray value, and the eighth gray value; and uses the first calculated value, the second calculated value, the third calculated value, and the fourth calculated value as the calculation result corresponding to the first target point.
[0009] According to an embodiment of the present invention, obtaining a threshold and determining a second target point among the first target points based on each calculation result and the threshold includes: determining the maximum value among the first calculated value, the second calculated value, the third calculated value, and the fourth calculated value; and determining the second target point among the first target points based on the comparison result between the maximum value and the threshold.
[0010] According to an embodiment of the present invention, the step of correcting the grayscale value of each second target point to obtain multiple corrected single-channel images includes: for any second target point, determining a target value corresponding to the second target point for correction; and converting the grayscale value of the second target point into the target value to obtain a corrected single-channel image.
[0011] A second aspect of the present invention provides an image processing apparatus, comprising: a first obtaining module, configured to, in response to obtaining an image to be processed, obtain a plurality of single-channel images corresponding to the image to be processed; a first determining module, configured to, for non-edge pixels in each single-channel image, determine a first target point corresponding to each single-channel image based on the grayscale value of each non-edge pixel; a second obtaining module, configured to perform differential gradient calculations in multiple horizontal and vertical directions on the first target point in each single-channel image to obtain a calculation result corresponding to each first target point; a second determining module, configured to obtain a threshold and determine a second target point among the first target points based on each calculation result and the threshold; and a third obtaining module, configured to correct the grayscale value of each second target point to obtain a plurality of corrected single-channel images.
[0012] A third aspect of the present invention provides an electronic device comprising: one or more processors; and a memory for storing one or more programs, wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the methods disclosed above.
[0013] A fourth aspect of the present invention also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the methods disclosed above. Attached Figure Description
[0014] The above-described features, other objects, and advantages of the present invention will become clearer from the following description of embodiments of the invention with reference to the accompanying drawings, in which:
[0015] Figure 1 A flowchart illustrating an image processing method according to an embodiment of the present invention is shown schematically;
[0016] Figure 2 A schematic block diagram of an image processing apparatus according to an embodiment of the present invention is shown; and
[0017] Figure 3 A block diagram schematically illustrates an electronic device suitable for implementing an image processing method according to an embodiment of the present invention. Detailed Implementation
[0018] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the invention. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the invention for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concept of the invention.
[0019] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0020] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0021] When using expressions such as "at least one of A, B, and C", the expression should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B, and C, etc.).
[0022] pass Figure 1 The image processing method of the disclosed embodiments will be described in detail.
[0023] Figure 1 A flowchart illustrating an image processing method according to an embodiment of the present invention is shown schematically. Figure 1 As shown, this embodiment includes operations S101 to S105.
[0024] In operation S101, in response to acquiring the image to be processed, multiple single-channel images corresponding to the image to be processed are obtained based on the image to be processed.
[0025] For example, the image to be processed is an image acquired by a medical device.
[0026] For example, the image to be processed is a color filter matrix image.
[0027] It is understandable that this step can extract single-channel images from the image to be processed, such as extracting four single-color channel images.
[0028] It is understandable that for an image to be processed, IM∈R M×N Each 2×2 grid consists of 2 Gs (G1, G2), one B, and one R. If the arrangement pattern is "BGGR", four single-color channel images can be obtained using the following formula.
[0029]
[0030]
[0031]
[0032]
[0033] In operation S102, for each non-edge pixel in a single-channel image, a first target point corresponding to each single-channel image is determined based on the gray value of each non-edge pixel.
[0034] Target points, such as the first target point determined in this step, can be considered as bad points.
[0035] For example, for each non-edge pixel in a single-channel image, a first target point corresponding to each single-channel image is determined based on the grayscale value of each non-edge pixel. This includes: for any non-edge pixel, obtaining the grayscale values of neighboring pixels around the non-edge pixel to obtain multiple neighboring pixel grayscale values; determining the maximum and minimum values among the multiple neighboring pixel grayscale values; obtaining the grayscale value of the non-edge pixel; determining whether to use the non-edge pixel as the first target point based on the comparison result between the maximum value and the grayscale value of the non-edge pixel; and determining whether to use the non-edge pixel as the first target point based on the comparison result between the minimum value and the grayscale value of the non-edge pixel.
[0036] For example, the centering value is processed for four single-color channel images. The value in this step can be a grayscale value. (Image example follows.) For any point I(i,j), take its 8 neighboring points (i.e., the gray values of its adjacent pixels): (i-1,j-1), I(i-1,j), I(i-1,j+1), I(i,j-1), I(i,j+1), I(i+1,j-1), I(i+1,j+1), and I(i+1,j+1), and obtain the corresponding gray values. It can be understood that this step does not process image edge points. The minimum and maximum values of the above 8 points are compared to determine the maximum and minimum values, and then compared with the current point I(i,j) (i.e., the gray value of a non-edge pixel). If I(i,j) is greater than the maximum value or less than the minimum value, then the current point I(i,j) can be taken as the first target point.
[0037] It is understandable that if I(i,j) does not meet the condition of being greater than the maximum value or less than the minimum value, then the current point is considered not a bad point and no correction is performed.
[0038] In operation S103, differential gradient calculations are performed in multiple directions (horizontal and vertical) for the first target point in each single-channel image to obtain the calculation results corresponding to each first target point.
[0039] It is understandable that in order to more accurately identify defective pixels, it is necessary to further screen the first target point and use the second target point determined after screening as the defective pixel identified by this invention.
[0040] For example, the calculation results obtained by differential gradient calculation are used to filter the first target point.
[0041] For example, differential gradient calculations are performed on the first target point in each single-channel image in multiple horizontal and vertical directions to obtain the calculation results corresponding to each first target point. This includes: for any first target point, obtaining the gray values of the neighboring pixels around the first target point; wherein, the gray values of the neighboring pixels around the first target point include the first gray value of the neighboring pixels to the west of the first target point, the second gray value of the neighboring pixels to the east of the first target point, the third gray value of the neighboring pixels to the north of the first target point, the fourth gray value of the neighboring pixels to the south of the first target point, the fifth gray value of the neighboring pixels to the northwest of the first target point, the sixth gray value of the neighboring pixels to the southeast of the first target point, and the sixth gray value of the neighboring pixels to the southeast of the first target point. The algorithm obtains the seventh gray value of the neighboring pixels in the northeast direction and the eighth gray value of the neighboring pixels in the southwest direction of the first target point; it also obtains the gray value of the first target point; based on the gray values of the first target point, the first gray value, and the second gray value, it obtains the first calculated value of the differential gradient; based on the gray values of the first target point, the third gray value, and the fourth gray value, it obtains the second calculated value of the differential gradient; based on the gray values of the first target point, the fifth gray value, and the sixth gray value, it obtains the third calculated value of the differential gradient; based on the gray values of the first target point, the seventh gray value, and the eighth gray value, it obtains the fourth calculated value of the differential gradient; and it uses the first calculated value, the second calculated value, the third calculated value, and the fourth calculated value as the calculation result corresponding to the first target point.
[0042] For example, perform differential gradient calculations in multiple directions for the first target point that meets the conditions, specifically: when I(i,j) is greater than the maximum value.
[0043] diffVer(i,j)=2*I(i,j)-I(i-1,j)-I(i+1,j)
[0044] diffHor(i,j)=2*I(i,j)-I(i,j-1)-I(i,j+1)
[0045] diffDiag1(i,j)=2*I(i,j)-I(i-1,j-1)-I(i+1,j+1)
[0046] diffDiag2(i,j)=2*I(i,j)-I(i-1,j+1)-I(i+1,j+1)
[0047] When I(i,j) is less than the minimum value,
[0048] diffVer(i,j)=I(i-1,j)+I(i+1,j)-2*I(i,j)
[0049] diffHor(i,j)=I(i,j-1)+I(i,j+1)-2*I(i,j)
[0050] diffDiag1(i,j)=I(i-1,j-1)+I(i+1,j+1)-2*I(i,j)
[0051] diffDiag2(i,j)=I(i-1,j+1)+I(i+1,j+1)-2*I(i,j)
[0052] For example, where I(i,j) is the gray value of the first target point, I(i-1,j) is the first gray value of the adjacent pixel to the west of the first target point, I(i+1,j) is the second gray value of the adjacent pixel to the east of the first target point, I(i,j-1) is the third gray value of the adjacent pixel to the north of the first target point, I(i,j+1) is the fourth gray value of the adjacent pixel to the south of the first target point, and I(i-1,j-1) is the eighth gray value of the adjacent pixel to the southwest of the first target point. The gray values are: I(i+1,j+1) is the seventh gray value of the neighboring pixel located northeast of the first target point, I(i-1,j+1) is the fifth gray value of the neighboring pixel located northwest of the first target point, I(i+1,j+1) is the neighboring pixel located southeast of the first target point, diffVer(i,j) is the first calculated value, diffHor(i,j) is the second calculated value, diffDiag1(i,j) is the fourth calculated value, and diffDiag2(i,j) is the third calculated value.
[0053] Furthermore, the first calculated value, the second calculated value, the third calculated value, and the fourth calculated value are used as the calculation results corresponding to the first target point.
[0054] In operation S104, a threshold is obtained, and based on each calculation result and the threshold, a second target point is determined from the first target points.
[0055] It is understandable that in this step, bad pixel detection continues. A threshold is used to determine the second target point among the first target points.
[0056] For example, obtaining a threshold and determining a second target point among the first target points based on each calculation result and the threshold includes: determining the maximum value among the first calculated value, the second calculated value, the third calculated value, and the fourth calculated value; and determining the second target point among the first target points based on the comparison result between the maximum value and the threshold.
[0057] For example, the maximum value in the calculation result corresponding to the first target point will be taken and compared with the threshold T.
[0058] Maximum value: DiffMax = max(DiffVer(i,j),diffHor(i,j),
[0059] DiffDiag1(i,j),DiffDiag1(i,j))
[0060]
[0061] The second target point can be determined from the first target point by comparing the maximum value with the threshold T. For example, T = 20.
[0062] It is understandable that, since noise in an image has local extremum characteristics, lowering the threshold T can not only correct bad pixels but also reduce noise to a certain extent.
[0063] In operation S105, the grayscale value of each second target point is corrected to obtain multiple corrected single-channel images.
[0064] For example, the grayscale value of each second target point is corrected to obtain multiple corrected single-channel images, including: for any second target point, determining the target value corresponding to the second target point for correction; and converting the grayscale value of the second target point into the target value to obtain the corrected single-channel image.
[0065] Specifically, the original grayscale value of the pixel identified as a bad pixel (i.e., the second target point) is updated by calculating the target value using the following formula.
[0066]
[0067] in, This is the target value used for correction.
[0068] Furthermore, a target image can be generated based on multiple corrected single-channel images.
[0069] It is understandable that, for example, in this step, the corrected single-channel image is reconstructed into a color filter matrix image IM∈RM×N.
[0070] The image processing method provided by this invention can correct target points and reduce image noise. For example, by splitting the color channels of an image and recombining them into multiple single-channel images, target points are detected and corrected in the single-channel images to obtain corrected single-channel images, which can effectively suppress target point pixels and correct their grayscale values. At the same time, determining target points by setting a threshold can reduce image noise. Furthermore, the image processing method provided by this invention only performs correction processing on determined target points, which can improve the speed of target point correction.
[0071] Figure 2 A schematic block diagram of an image processing apparatus according to an embodiment of the present invention is shown.
[0072] like Figure 2 As shown, the image processing apparatus 200 of this embodiment includes a first obtaining module 210, a first determining module 220, a second obtaining module 230, a second determining module 240, and a third obtaining module 250.
[0073] The first obtaining module 210 is used to obtain multiple single-channel images corresponding to the image to be processed in response to obtaining the image to be processed; the first determining module 220 is used to determine a first target point corresponding to each single-channel image based on the gray value of each non-edge pixel in each single-channel image; the second obtaining module 230 is used to perform differential gradient calculation in multiple horizontal and vertical directions for the first target point in each single-channel image to obtain a calculation result corresponding to each first target point; the second determining module 240 is used to obtain a threshold and determine a second target point among the first target points based on each calculation result and the threshold; and the third obtaining module 250 is used to correct the gray value of each second target point to obtain multiple corrected single-channel images.
[0074] According to embodiments of the present invention, any plurality of modules among the first obtaining module 210, the first determining module 220, the second obtaining module 230, the second determining module 240, and the third obtaining module 250 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least a portion of the functionality of one or more of these modules may be combined with at least a portion of the functionality of other modules and implemented in one module. According to embodiments of the present invention, at least one of the first obtaining module 210, the first determining module 220, the second obtaining module 230, the second determining module 240, and the third obtaining module 250 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, at least one of the first obtaining module 210, the first determining module 220, the second obtaining module 230, the second determining module 240, and the third obtaining module 250 may be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.
[0075] Figure 3 A block diagram schematically illustrates an electronic device suitable for implementing an image processing method according to an embodiment of the present invention.
[0076] like Figure 3 As shown, an electronic device 300 according to an embodiment of the present invention includes a processor 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage portion 308 into a random access memory (RAM) 303. The processor 301 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 301 may also include onboard memory for caching purposes. The processor 301 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0077] RAM 303 stores various programs and data required for the operation of electronic device 300. Processor 301, ROM 302, and RAM 303 are interconnected via bus 304. Processor 301 executes various operations of the method flow according to embodiments of the present invention by executing programs in ROM 302 and / or RAM 303. It should be noted that the programs may also be stored in one or more memories other than ROM 302 and RAM 303. Processor 301 may also execute various operations of the method flow according to embodiments of the present invention by executing programs stored in said one or more memories.
[0078] According to an embodiment of the present invention, the electronic device 300 may further include an input / output (I / O) interface 305, which is also connected to a bus 304. The electronic device 300 may also include one or more of the following components connected to the I / O interface 305: an input section 306 including a keyboard, mouse, etc.; an output section 307 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN card, modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as needed. A removable medium 311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 310 as needed so that computer programs read from it can be installed into the storage section 308 as needed.
[0079] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of the present invention.
[0080] According to embodiments of the present invention, a computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of the present invention, a computer-readable storage medium may include ROM 302 and / or RAM 303 and / or one or more memories other than ROM 302 and RAM 303 described above.
[0081] Embodiments of the present invention also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to enable the computer system to implement the image processing method provided in the embodiments of the present invention.
[0082] When the computer program is executed by the processor 301, it performs the functions defined in the system / apparatus of this invention. According to embodiments of the invention, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0083] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via communication section 309, and / or installed from removable medium 311. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0084] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 309, and / or installed from the removable medium 311. When the computer program is executed by the processor 301, it performs the functions defined in the system of this embodiment of the invention. According to embodiments of the invention, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0085] According to embodiments of the present invention, program code for executing the computer programs provided in the embodiments of the present invention can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0086] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0087] Those skilled in the art will understand that the features described in the various embodiments and / or claims of the present invention can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, the features described in the various embodiments and / or claims of the present invention can be combined and / or combined in various ways without departing from the spirit and teachings of the present invention. All such combinations and / or combinations fall within the scope of the present invention.
[0088] The embodiments of the present invention have been described above. However, these embodiments are merely illustrative and not intended to limit the scope of the invention. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of the invention is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of the invention, and all such substitutions and modifications should fall within the scope of the invention.
Claims
1. An image processing method, comprising: In response to acquiring the image to be processed, multiple single-channel images corresponding to the image to be processed are obtained based on the image to be processed; For each non-edge pixel in a single-channel image, determine the first target point corresponding to each single-channel image based on the gray value of each non-edge pixel; For the first target point in each single-channel image, perform differential gradient calculations in multiple horizontal and vertical directions to obtain the calculation results corresponding to each first target point; Obtain the threshold, and determine the second target point among the first target points based on each calculation result and the threshold; as well as The grayscale value of each second target point is corrected to obtain multiple corrected single-channel images; The step of determining the first target point corresponding to each single-channel image based on the grayscale value of each non-edge pixel in each single-channel image includes: For any non-edge pixel, obtain the grayscale values of the neighboring pixels around the non-edge pixel to obtain the grayscale values of multiple neighboring pixels. Determine the maximum and minimum grayscale values among the plurality of adjacent pixels; Obtain the grayscale value of the non-edge pixels; Based on the comparison between the maximum value and the grayscale value of the non-edge pixel, determine whether to use the non-edge pixel as the first target point; and Based on the comparison result between the minimum value and the gray value of the non-edge pixel, it is determined whether to use the non-edge pixel as the first target point.
2. The method according to claim 1, further comprising: A target image is generated based on the multiple corrected single-channel images.
3. The method according to claim 1, wherein, The step of performing differential gradient calculations in multiple horizontal and vertical directions for the first target point in each single-channel image to obtain the calculation result corresponding to each first target point includes: For any first target point, obtain the grayscale values of the neighboring pixels around the first target point; wherein, the grayscale values of the neighboring pixels around the first target point include the first grayscale value of the neighboring pixels to the west of the first target point, the second grayscale value of the neighboring pixels to the east of the first target point, the third grayscale value of the neighboring pixels to the north of the first target point, the fourth grayscale value of the neighboring pixels to the south of the first target point, the fifth grayscale value of the neighboring pixels to the northwest of the first target point, the sixth grayscale value of the neighboring pixels to the southeast of the first target point, the seventh grayscale value of the neighboring pixels to the northeast of the first target point, and the eighth grayscale value of the neighboring pixels to the southwest of the first target point. Obtain the grayscale value of the first target point; Based on the gray value of the first target point, the first gray value, and the second gray value, the first calculated value of the differential gradient is obtained; Based on the gray value of the first target point, the third gray value, and the fourth gray value, the second calculated value of the differential gradient is obtained; Based on the gray value of the first target point, the fifth gray value, and the sixth gray value, the third calculated value of the differential gradient is obtained; Based on the grayscale value of the first target point, the seventh grayscale value, and the eighth grayscale value, a fourth calculated value for the differential gradient is obtained; and The first calculated value, the second calculated value, the third calculated value, and the fourth calculated value are used as the calculation results corresponding to the first target point.
4. The method according to claim 3, wherein, The step of obtaining the threshold and determining the second target point among the first target points based on each calculation result and the threshold includes: Determine the maximum value among the first, second, third, and fourth calculated values; and Based on the comparison between the maximum value and the threshold, a second target point is determined from the first target points.
5. The method according to claim 1, wherein, The grayscale value of each second target point is corrected to obtain multiple corrected single-channel images, including: For any second target point, determine the target value corresponding to the second target point for correction; and The grayscale value of the second target point is converted into the target value to obtain the corrected single-channel image.
6. An image processing apparatus, comprising: The first acquisition module is used to obtain multiple single-channel images corresponding to the image to be processed based on the image to be processed in response to acquiring the image to be processed. The first determining module is used to determine the first target point corresponding to each single-channel image based on the gray value of each non-edge pixel in each single-channel image. The second acquisition module is used to perform differential gradient calculations in multiple horizontal and vertical directions for the first target point in each single-channel image, and obtain the calculation results corresponding to each first target point. The second determining module is used to obtain a threshold and determine a second target point among the first target points based on each calculation result and the threshold. as well as The third acquisition module is used to correct the gray value of each second target point to obtain multiple corrected single-channel images. The first determining module uses the following method to determine the first target point corresponding to each single-channel image based on the grayscale value of each non-edge pixel in each single-channel image: For any non-edge pixel, obtain the grayscale values of the neighboring pixels around the non-edge pixel to obtain the grayscale values of multiple neighboring pixels. Determine the maximum and minimum grayscale values among the plurality of adjacent pixels; Obtain the grayscale value of the non-edge pixels; Based on the comparison result between the maximum value and the gray value of the non-edge pixel, determine whether to use the non-edge pixel as the first target point; as well as Based on the comparison result between the minimum value and the gray value of the non-edge pixel, it is determined whether to use the non-edge pixel as the first target point.
7. The apparatus according to claim 6, further comprising: The generation module is used to generate a target image based on the plurality of corrected single-channel images.
8. An electronic device, comprising: One or more processors; Storage device for storing one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the method according to any one of claims 1 to 5.
9. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Defective pixel detection method and device and electronic equipment
CN110035281A
Image dead pixel processing method, electronic equipment and storage medium
CN116506746A