Image glare detection method and apparatus
By dividing the image into blocks and obtaining the brightness and gradient information of each block to determine the starting point type of the mark, the problem of unable to detect any shape glare area in the existing technology can be solved, and the efficient glare area testing is achieved.
Patent Information
- Application Number
- PCT/CN2024/091491
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-07-24
- Filing Date
- 2024-05-07
- Publication Date
- 2025-01-30
AI Technical Summary
In the prior art, glare detection methods cannot detect glare areas of any shape, but can only detect the smallest area of the entire column.
By dividing the image into a block of the set size, traversing and obtaining the average brightness, brightness variation, and color gradient of each image block, determine the starting point type of the mark according to these parameters, and determine after the detection of all the image blocks is determined after all the image blocks are detected. Border between glare areas.
The detection of arbitrarily glare areas is achieved, the detection efficiency is improved, and the glare area boundary of the image can be determined in a complete detection.
Smart Images

Figure CN2024091491_30012025_PF_FP_ABST
Abstract
Description
Image glare detection method and device
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This disclosure is based on Chinese patent application CN202310915347.8, filed on July 24, 2023, entitled “Image Glare Detection Method and Device,” and claims the priority of the patent application, all of the contents disclosed therein are incorporated into this disclosure by reference. Technical Field
[0003] The embodiments of the present invention relate to the field of communications, and in particular, to a method and device for detecting image glare. Background Art
[0004] The current glare detection method mainly calculates the local cumulative gradient of each pixel in the video image, constructs a local cumulative gradient image with the local cumulative gradient value at each pixel position in the video image as the pixel value, calculates the grayscale average of each column of pixels in the local cumulative gradient image and the grayscale average of all pixels, and calculates the ratio of the grayscale average of each column of pixels in the local cumulative gradient image to the grayscale average of all pixels, and determines the glare column based on this ratio.
[0005] However, the minimum area that can be detected by this method is only the entire column, and it is unable to detect glare areas of arbitrary shapes.
[0006] Summary of the Invention
[0007] The embodiments of the present invention provide an image glare detection method and apparatus to at least solve the problem that the minimum area detected by the glare detection method in the related art can only be an entire column, and cannot detect glare areas of arbitrary shapes.
[0008] According to one embodiment of the present invention, a method for detecting glare in an image is provided, comprising:
[0009] Traverse the image row by row from left to right in blocks of a set size, and obtain the average brightness of the current image block, the difference between the average brightness of the current image block and the average brightness of the previous adjacent image block, and the color gradient difference of the current image block during the traversal process;
[0010] When the average brightness of the current image block meets a preset brightness threshold and there is a marked starting point of an undetermined type, the type of the marked starting point is determined based on the difference between the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block; the marked starting point types include non-glare starting points and glare starting points;
[0011] The type of the reserved marked starting point is a glare starting point, and after traversing all image blocks of the image, the boundary of the glare area of the image is determined according to the reserved glare starting point.
[0012] According to another embodiment of the present invention, there is provided an image glare detection device, the device comprising:
[0013] A first acquisition module is configured to traverse the image row by row from left to right in blocks of a set size, and obtain, during the traversal process, the average brightness of the current image block, the difference between the average brightness of the current image block and the average brightness of the previous adjacent image block, and the color gradient difference of the current image block;
[0014] a first determination module configured to, when the average brightness of the current image block satisfies a preset brightness threshold and there is a marked starting point of an undetermined type, determine the type of the marked starting point based on a change between the average brightness of the current image block and the average brightness of the previous adjacent image block or a color gradient difference of the current image block; the marked starting point types include non-glare starting points and glare starting points;
[0015] The second determining module is configured to retain the marked starting point as a glare starting point, and after traversing all image blocks of the image, determine the boundary of the glare area of the image according to the retained glare starting point.
[0016] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when run.
[0017] According to another embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any one of the above method embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] FIG1 is a hardware structure block diagram of a mobile terminal for image glare detection according to an embodiment of the present invention;
[0019] FIG2 is a flow chart of a method for detecting image glare according to an embodiment of the present invention;
[0020] FIG3 is a flowchart (I) of performing image glare detection according to an embodiment of the present invention;
[0021] FIG4 is a flowchart (II) of performing image glare detection according to an embodiment of the present invention;
[0022] FIG5 is a flowchart (III) of performing image glare detection according to an embodiment of the present invention;
[0023] FIG6 is a structural block diagram of an image glare detection device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0024] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with embodiments.
[0025] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0026] The method embodiments provided in the embodiments of the present disclosure can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, FIG1 is a hardware structure block diagram of a mobile terminal for image glare detection according to an embodiment of the present invention. As shown in FIG1 , the mobile terminal may include one or more (only one is shown in FIG1 ) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It will be understood by those skilled in the art that the structure shown in FIG1 is only for illustration and does not limit the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than those shown in FIG1 , or have a configuration different from that shown in FIG1 .
[0027] Memory 104 can be used to store computer programs, such as software programs and modules of application software, such as the computer program corresponding to the image glare detection method in the embodiments of the present invention. Processor 102 executes the computer programs stored in memory 104 to perform various functional applications and data processing, thereby implementing the aforementioned method. Memory 104 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, memory 104 may further include memory remotely located relative to processor 102, which can be connected to the mobile terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0028] The transmission device 106 is used to receive or send data via a network. A specific example of the aforementioned network may include a wireless network provided by the mobile terminal's communications provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0029] In this embodiment, a method for detecting glare in an image is provided. FIG2 is a flow chart of the method for detecting glare in an image according to an embodiment of the present invention. As shown in FIG2 , the flow chart includes the following steps:
[0030] In step S201, the image is traversed row by row from left to right in blocks of a set size, and during the traversal process, the average brightness of the current image block, the difference between the average brightness of the current image block and the average brightness of the previous adjacent image block, and the color gradient difference of the current image block are obtained.
[0031] In an embodiment of the present invention, an image can be traversed row by row from left to right in blocks of a set size. When the traversed blocks of the set size reach a certain image region, detection of that image region begins. As an example, during the traversal process, the average brightness of the current image block, the difference between the average brightness of the current image block and the average brightness of the previous adjacent image block, and the color gradient difference of the current image block can be obtained.
[0032] It should be noted that the block of set size in the embodiment of the present invention can be equivalent to the scanning window, and the image area currently scanned by the scanning window is the current image block. The process of scanning the image with the block of set size is the process of traversing the image.
[0033] As an example, a scan with a step size of 1 may be performed in units of blocks of a set size.
[0034] As an example, in the process of traversing row by row from left to right, the brightness change of the first image block in each row obtained may be set to 0 by default.
[0035] For example, a block of size w*h can be set to scan the image to be detected, where w can be the width of the image block and h can be the length of the image block. When the image block J is scanned, the average brightness M of the image block J can be obtained. j , the change D between the average brightness of image block J and the average brightness of the previous adjacent image block J-1, and the color gradient difference C of image block J:
[0036] 1) For an image block J of size w*h, calculate the brightness value J corresponding to each position coordinate in the image block J based on the RGB three channels y , the calculation formula is as follows:
[0037] Wherein, ω1, ω2, and ω3 are weight factors, which are generally set to 1 / 3 respectively. Specifically, those skilled in the art can set them according to actual conditions, and the embodiment of the present invention does not limit them here; Represent the R, G, and B channel values of each (i, j) position in image block J respectively.
[0038] 2) Calculate the mean brightness value of image block J, that is, the average brightness M of image block J j .
[0039] The calculation method of the average brightness is a conventional technique and will not be described in detail in this embodiment.
[0040] 3) Calculate the difference D between the average brightness of image block J and the average brightness of the previous adjacent image block J-1:
[0041] D=|M j -M j-1 |
[0042] Among them, M j is the average brightness of the current image block, M j-1 is the average brightness of the previous adjacent image block.
[0043] 4) Calculate the color gradient difference C of image block J:
[0044] Calculate the RGB three-channel value of each position (i, j) in the image block J, and calculate the difference between the maximum and minimum values of the RGB three-channel at each position (i, j). Then, determine the maximum difference from the difference between the maximum and minimum values of the RGB three-channel at each position (i, j). This maximum difference is the color gradient difference C of the image block J, and its calculation formula is:
[0045] in, It is the RGB three-channel value of each position (i, j) in the image block J.
[0046] Step S202, when the average brightness of the current image block meets a preset brightness threshold and there is a starting point of a mark of undetermined type, the type of the starting point of the mark is determined based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block; the starting point types of the mark include non-glare starting points and glare starting points.
[0047] In an embodiment of the present invention, there may be multiple preset brightness thresholds. For example, the preset brightness thresholds include a first brightness threshold, a second brightness threshold, a third brightness threshold, etc. During traversal of an image block, when the average brightness of the image block meets the first brightness threshold, the center position coordinates of the image block may be marked as the starting point.
[0048] In the embodiment of the present invention, the starting point of the mark may include a non-glare starting point and a glare starting point. The starting point of the undetermined type of mark refers to the starting point of the mark that has not yet been determined to be a non-glare starting point or a glare starting point. As an example, the non-glare starting point may be discarded.
[0049] As an example, when the average brightness of the current image block meets a preset brightness threshold and there is a starting point of a mark of an undetermined type, the type of the starting point of the mark can be determined based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block.
[0050] As an example, when the average brightness of the current image block meets a preset brightness threshold and there is a starting point of a mark of undetermined type, the type of the starting point of the mark can be determined according to the color gradient difference of the current image block.
[0051] As an example, when the average brightness of the current image block meets a preset brightness threshold and there is a starting point of a mark of undetermined type, the type of the starting point of the mark can be determined based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block and the color gradient difference of the current image block.
[0052] The following are some examples of the process of determining the starting point of the mark:
[0053] FIG3 is a flowchart (I) of performing image glare detection according to an embodiment of the present invention. After an image frame is input, the image can be scanned and detected line by line from left to right in blocks of a set size. The execution logic of the blocks of the set size is as follows:
[0054] 301) detecting the current image block;
[0055] 302) When the average brightness M of the current image block is greater than m1, mark the current image block as the starting point, and traverse to the next image block for detection, while recording the number S of blocks that continuously meet the average brightness M of the image block greater than m1;
[0056] 303) Determine whether S is greater than S1;
[0057] 304) If not, discard the marked starting point, continue traversing to the next image block, and return to step 301);
[0058] 305) If yes, determine whether the difference D between the average brightness of the current image block moved to and the average brightness of the previous adjacent image block is greater than or equal to d1;
[0059] 306) If yes, discard the marked starting point, continue traversing to the next image block, and return to step 301);
[0060] 307) If not, determine whether D satisfies d2<D<d1;
[0061] 308) If not, continue traversing to the next image block and return to step 301);
[0062] 309) If yes, determine whether the color gradient difference C of the current image block is less than c1;
[0063] 310) If yes, determine that the starting point of the mark is a non-glare starting point, discard the starting point of the mark, continue traversing to the next image block, and return to step 301);
[0064] 311) If not, the starting point of the mark is determined to be the colored glare starting point.
[0065] As an example, the glare starting point may include a colored glare starting point and a white glare starting point.
[0066] The following further illustrates the execution process of FIG3 through some optional embodiments:
[0067] In an optional embodiment, when the average brightness of the current image block meets a preset brightness threshold and there is a marked starting point of an undetermined type, before determining the type of the marked starting point based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block, the method further includes: when the average brightness of the current image block is greater than a first average brightness threshold, marking the starting point and traversing to the next image block position.
[0068] As an example, during image detection, when it is detected that the average brightness M of the current image block is greater than the first average brightness threshold m1, the center position coordinates of the current image block can be marked as the starting point and traverse to the next image block position.
[0069] In an optional embodiment, it further includes: recording the number of blocks of the current image block whose average brightness is continuously greater than a first average brightness threshold during the traversal process; discarding the starting point of the mark when the number of blocks of the current image block whose average brightness is continuously greater than the first brightness threshold is less than a preset block number threshold; and determining that there is a starting point of an undetermined type of mark when the number of blocks of the current image block whose average brightness is continuously greater than the first brightness threshold is greater than or equal to a preset block number threshold.
[0070] As an example, during the traversal process, the number of blocks S whose average brightness M continuously satisfies M>m1 can be recorded. If S<preset block number threshold s1, the starting point of the current mark can be directly discarded; if S≥s1, the traversal can continue to the next image block.
[0071] As an example, when S≥s1, the detection and recording may continue to the next image block, and the recording may be stopped when the average brightness of the next image block is less than or equal to the first average brightness threshold m1.
[0072] In an optional embodiment, when the average brightness of the current image block meets a preset brightness threshold and there is a marked starting point of an undetermined type, determining the type of the marked starting point based on a change between the average brightness of the current image block and the average brightness of a previous adjacent image block or a color gradient difference of the current image block includes:
[0073] When the average brightness of the current image block is less than or equal to the first average brightness threshold and greater than the second average brightness threshold, and there is a starting point of a mark of undetermined type, the type of the starting point of the mark is determined based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block; wherein the second average brightness threshold is less than the first average brightness threshold.
[0074] As an example, when the average brightness M of the current image block is less than or equal to the first average brightness threshold m1 and greater than the second average brightness threshold m2, and there is a starting point of an undetermined type of mark, the type of the starting point of the mark can be determined based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block; wherein, m2<m1.
[0075] In an optional embodiment, when the average brightness of the current image block is less than or equal to the first average brightness threshold and greater than the second average brightness threshold, and there is a marked starting point of an undetermined type, determining the type of the marked starting point based on a change between the average brightness of the current image block and the average brightness of a previous adjacent image block or a color gradient difference of the current image block includes:
[0076] Determining whether a change between the average brightness of the current image block and the average brightness of the previous adjacent image block is greater than or equal to a first brightness change threshold;
[0077] When the difference between the average brightness of the current image block and the average brightness of the previous adjacent image block is greater than or equal to a first brightness change threshold, the type of the marked starting point is determined to be the non-glare starting point, and the marked starting point is discarded.
[0078] As an example, when m2<M≤m1 and there is a starting point of an undetermined type of mark, it can be determined whether the change D between the average brightness of the current image block and the average brightness of the previous adjacent image block is greater than or equal to the first brightness change threshold d1, and when D≥d1, the type of the starting point of the mark is determined to be a non-glare starting point, and the starting point of the mark is discarded.
[0079] In an optional embodiment, when the average brightness of the current image block is less than or equal to the first average brightness threshold and greater than the second average brightness threshold, and there is a marked starting point of an undetermined type, determining the type of the marked starting point based on a change between the average brightness of the current image block and the average brightness of a previous adjacent image block or a color gradient difference of the current image block includes:
[0080] Determine whether a change between the average brightness of the current image block and the average brightness of the previous adjacent image block is less than a first brightness change threshold and greater than a second brightness change threshold;
[0081] When the change in the average brightness of the current image block and the average brightness of the previous adjacent image block is less than a first brightness change threshold and greater than a second brightness change threshold, the type of the marked starting point is determined according to the color gradient difference of the current image block.
[0082] As an example, it is possible to determine whether the change D between the average brightness of the current image block and the average brightness of the previous adjacent image block is less than a first brightness change threshold d1 and greater than a second brightness change threshold d2, and when d2<D<d1 is satisfied, determine the type of the starting point of the mark based on the color gradient difference C of the current image block.
[0083] In an optional embodiment, when a change in the average brightness of the current image block and the average brightness of the previous adjacent image block is less than a first brightness change threshold and greater than a second brightness change threshold, determining the type of the marked starting point based on the color gradient difference of the current image block includes:
[0084] Determining whether the color gradient difference of the current image block is less than a color gradient difference threshold;
[0085] When the color gradient difference of the current image block is less than a color gradient difference threshold, determining that the type of the marked starting point is the non-glare starting point, and discarding the marked starting point;
[0086] In a case where the color gradient difference of the current image block is greater than or equal to a color gradient difference threshold, the type of the marked starting point is determined to be the colored glare starting point.
[0087] As an example, when d2<D<d1 is satisfied, it can be determined whether the color gradient difference C of the current image block is less than the color gradient difference threshold c1.
[0088] If C<c1, the type of the marked starting point can be determined to be a non-glare starting point, and the marked starting point is discarded; if C≥c1, the type of the marked starting point can be determined to be a colored glare starting point.
[0089] FIG4 is a flowchart (II) of performing image glare detection according to an embodiment of the present invention. After executing the process shown in FIG3 , if the image has not been fully detected, the block of the set size can continue to traverse to the next image block position for detection. The execution logic is as follows:
[0090] 400) detecting the current image block;
[0091] 401) determining whether the average brightness M of the current image block is less than m2, where m2 < m1;
[0092] 402) If not, traverse to the next image block and return to step 400);
[0093] 403) If yes, determine whether there is a starting point of a mark of undetermined type;
[0094] 404) If there is no starting point of a mark of an undetermined type, traverse to the next image block and return to step 400);
[0095] 405) If there is a starting point of an undetermined type of mark, determine whether the color gradient difference C of the current image block is less than c1;
[0096] 406) If yes, then determine the starting point of the mark as the white glare starting point;
[0097] 407) If not, determine that the starting point of the mark is the colored glare starting point.
[0098] The following further illustrates the execution process of FIG4 through some optional embodiments:
[0099] In an optional embodiment, when the average brightness of the current image block meets a preset brightness threshold and there is a marked starting point of an undetermined type, determining the type of the marked starting point based on a change between the average brightness of the current image block and the average brightness of a previous adjacent image block or a color gradient difference of the current image block further includes:
[0100] When the average brightness of the current image block is less than the second average brightness threshold and there is a starting point of a mark of undetermined type, the type of the starting point of the mark is determined based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block.
[0101] As an example, when the average brightness M of the current image block satisfies M<m2 and there is a starting point of a mark of undetermined type, the type of the starting point of the mark can be determined based on the change D between the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference C of the current image block.
[0102] In an optional embodiment, when the average brightness of the current image block is less than the second average brightness threshold and there is a marked starting point of an undetermined type, determining the type of the marked starting point based on a change between the average brightness of the current image block and the average brightness of a previous adjacent image block or a color gradient difference of the current image block includes:
[0103] Determining whether the color gradient difference of the current image block is less than a color gradient difference threshold;
[0104] When the color gradient difference of the current image block is less than a color gradient difference threshold, determining that the type of the marked starting point is a white glare starting point;
[0105] In a case where the color gradient difference of the current image block is greater than or equal to a color gradient difference threshold, it is determined that the type of the marked starting point is a colored glare starting point.
[0106] As an example, when the average brightness M of the current image block satisfies M<m2 and there is a starting point of an undetermined type of mark, it can be determined whether the color gradient difference of the current image block is less than the color gradient difference threshold, that is, C<c1.
[0107] If C<c1, it can be determined that the type of the marked starting point is a white glare starting point;
[0108] If C≥c1, it can be determined that the type of the marked starting point is a colored glare starting point.
[0109] Step S203 , retaining the marked starting point as a glare starting point; and after detecting all image blocks of the image, determining the boundary of the glare area of the image according to the retained glare starting point.
[0110] As an example, it is possible to determine whether the marked starting point is a glare starting point or a non-glare starting point according to the above method, and discard the non-glare starting point, while retaining the starting point of the marked starting point as a glare starting point, thereby obtaining the boundary of the glare area formed by the glare starting point after detecting all image blocks of the image.
[0111] FIG5 is a flowchart (III) of performing image glare detection according to an embodiment of the present invention. After retaining the starting point marked as a glare starting point, the glare starting points may be further filtered. Referring to FIG5 , the logic of the filtering process is as follows:
[0112] 500) detecting the current image block;
[0113] 501) When the average brightness M of the current image block is greater than m3, obtaining the glare starting point P1 closest to the current image block, where m3 < m2;
[0114] 502) calculating the Euclidean distance o2 between the current image block and the nearest glare starting point P1;
[0115] 503) determining whether the Euclidean distance o2 is less than a second preset distance L2 and the current image block is to the left of the nearest glare starting point P1;
[0116] 504) If not, continue traversing to the next image block and return to step 500);
[0117] 505) If yes, determine whether the difference D between the average brightness of the current image block and the average brightness of the previous adjacent image block satisfies D>d1;
[0118] 506) If D>d1 is satisfied, then delete the glare starting point P1 closest to the current image block, continue traversing to the next image block, and return to step 500);
[0119] 507) If D>d1 is not satisfied, then determine whether D satisfies d2<D≤d1 and the color gradient difference C of the current image block is less than c1;
[0120] 508) If satisfied, delete the glare starting point P1 closest to the current image block, continue traversing to the next image block, and return to step 500);
[0121] 509) If not satisfied, continue traversing to the next image block and return to execute step 500).
[0122] The following further illustrates the execution process of FIG5 through some optional embodiments:
[0123] In an optional embodiment, after retaining the starting point of the marked starting point of the type being the glare starting point, the method further includes:
[0124] Traversing to the next image block, and if the average brightness of the current image block is greater than a third brightness threshold, obtaining the glare starting point closest to the center position coordinates of the current image block, and obtaining a second Euclidean distance between the center position coordinates of the current image block and the closest glare starting point; wherein the third brightness threshold is less than the second brightness threshold;
[0125] When the second Euclidean distance is less than a second preset distance and the center position coordinates of the current image block are to the left of the nearest glare starting point, the nearest glare starting point is deleted based on a change in the average brightness of the current image block and the average brightness of the image block at the previous adjacent position or a color gradient difference of the current image block.
[0126] As an example, after retaining the starting point of which the type of the marked starting point is a glare starting point, traverse to the next image block position.
[0127] When the average brightness of the current image block is greater than the third brightness threshold, that is, when M>m3, the glare starting point P1 closest to the center position coordinates of the current image block can be obtained, and the second Euclidean distance o2 between the center position coordinates of the current image block and the nearest glare starting point P1 can be calculated.
[0128] As an example, when the second Euclidean distance o2 is less than the second preset distance L2 and the current image block is to the left of the nearest glare starting point, the nearest glare starting point P1 can be deleted based on the change D between the average brightness of the current image block and the average brightness of the image block at the previous adjacent position or the color gradient difference C of the current image block, so as to retain the glare starting point on the left side of the image.
[0129] In an optional embodiment, deleting the most recent glare starting point based on the amount of change between the average brightness of the current image block and the average brightness of the image block at the previous adjacent position, and the color gradient difference of the current image block, includes: deleting the most recent glare starting point if the amount of change between the average brightness of the current image block and the average brightness of the image block at the previous adjacent position is greater than the first brightness change threshold.
[0130] As an example, when the difference D between the average brightness of the current image block and the average brightness of the image block at the previous adjacent position is greater than the first brightness change threshold d1, the most recent glare starting point P1 may be deleted.
[0131] In an optional embodiment, deleting the most recent glare starting point based on the amount of change between the average brightness of the current image block and the average brightness of the image block at the previous adjacent position, and the color gradient difference of the current image block, includes: deleting the most recent glare starting point if the amount of change between the average brightness of the image block and the average brightness of the image block at the previous adjacent position is less than or equal to the first brightness change threshold and greater than the second brightness change threshold, and the color gradient difference of the image block is less than the preset color gradient difference threshold.
[0132] As an example, the most recent glare starting point P1 may be deleted when the difference D between the average brightness of the current image block and the average brightness of the previous adjacent image block satisfies d2<D≤d1 and the color gradient difference C of the current image block is less than c1.
[0133] In an optional embodiment, after deleting the most recent glare starting point, the method further includes:
[0134] Obtaining a first Euclidean distance between the current glare starting point and all glare starting points recorded before the current glare starting point;
[0135] From all glare starting points recorded before the current glare starting point, determining whether there is a target glare starting point whose first Euclidean distance to the current glare starting point is less than a first preset distance;
[0136] If the target glare starting point exists, marking the current glare starting point and the target glare starting point as the same glare source cluster;
[0137] If the target glare starting point does not exist, the current glare starting point is marked as a new glare source cluster.
[0138] As an example, all glare starting points recorded before the current glare starting point may be obtained, and the first Euclidean distance between the current glare starting point and all glare starting points recorded before the current glare starting point may be calculated.
[0139] As an example, a glare starting point P2 recorded before the current glare starting point that satisfies the first Euclidean distance less than the first preset distance can be determined, and the glare starting point P2 can be used as the target glare starting point, and the current glare starting point and the target glare starting point P2 can be marked as the same glare source cluster.
[0140] As an example, if the target glare starting point does not exist, the current glare starting point may be marked as a new glare source cluster.
[0141] In an optional embodiment, after traversing all image blocks of the image, the method further includes:
[0142] determining whether the number of colored glare starting points in the glare source cluster is greater than or equal to the number of white glare starting points in the glare source cluster;
[0143] If the number of colored glare starting points in the glare source cluster is greater than or equal to the number of white glare starting points in the glare source cluster, then determining that the glare source cluster is a colored glare source cluster;
[0144] If the number of colored glare points in the glare source cluster is less than the number of white glare starting points in the glare source cluster, determining that the glare source cluster is a white glare source cluster;
[0145] An area formed by the colored glare light cluster and / or the white glare light cluster is determined as a left boundary of the glare area of the image.
[0146] In this embodiment, the number of colored glare starting points and the number of white glare starting points recorded for different light source clusters can be used to distinguish whether the light source cluster is emitting colored glare or white glare. If the number of colored glare starting points in the glare source cluster is greater than or equal to the number of white glare starting points in the glare source cluster, the glare source cluster can be determined to be a colored glare source cluster. If the number of colored glare points in the glare source cluster is less than the number of white glare starting points in the glare source cluster, the glare source cluster can be determined to be a white glare source cluster.
[0147] As an example, the area formed by the colored glare light clusters and / or the white glare light clusters may be determined as the left boundary of the glare area of the image.
[0148] In an optional embodiment, determining the area formed by the colored glare light cluster and / or the white glare light cluster as the left boundary of the glare area of the image includes:
[0149] determining the total number of glare starting points in the colored glare source cluster and the white glare source cluster respectively;
[0150] If the total number of glare starting points in the colored glare light source cluster is greater than a first glare total number threshold, determining that the colored glare light source cluster is a valid colored light source cluster;
[0151] If the total number of glare starting points in the colored glare source cluster is less than or equal to a first glare total number threshold, deleting the colored glare cluster;
[0152] If the total number of glare starting points in the white glare light source cluster is greater than a second glare total number threshold, determining that the white glare light source cluster is a valid white light source cluster;
[0153] If the total number of glare points in the colored glare source cluster is less than or equal to a second glare total number threshold, deleting the colored glare cluster;
[0154] An area formed by the effective colored glare source clusters and / or the effective white glare source clusters is determined as a left boundary of the glare area of the image.
[0155] In this embodiment, the determined type of glare source clusters may be further screened to determine valid glare source clusters, and the area formed by the valid glare source clusters may be determined as the left boundary of the glare area of the image.
[0156] In an embodiment of the present invention, when performing row-by-row detection from left to right on an image equally divided into multiple image blocks, the average brightness of the current image block, the difference between the average brightness of the current image block and the average brightness of the previous adjacent image block, and the color gradient difference of the current image block are obtained. If the average brightness of the current image block meets a preset brightness threshold and there is a marked starting point of an undetermined type, the type of the marked starting point is determined based on the difference between the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block. The marked starting point types include non-glare starting points and glare starting points. This enables detection of glare areas of arbitrary shapes, resolving the problem in related art glare detection methods that the minimum detectable area can only be an entire column and cannot detect glare areas of arbitrary shapes. Furthermore, by retaining the starting point type of the marked starting point as a glare starting point, and after detecting all image blocks of the image, determining the boundary of the glare area of the image based on the retained glare starting point, only one complete detection of the image is required, thereby improving detection efficiency.
[0157] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0158] This embodiment also provides an image glare detection device for implementing the above-described embodiments and preferred implementations. Details already described will not be repeated. As used below, the term "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0159] FIG6 is a structural block diagram of an image glare detection device according to an embodiment of the present invention. As shown in FIG6 , the device includes:
[0160] A first acquisition module 601 is configured to traverse the image row by row from left to right in blocks of a set size, and obtain, during the traversal process, the average brightness of the current image block, the difference between the average brightness of the current image block and the average brightness of the previous adjacent image block, and the color gradient difference of the current image block;
[0161] A first determination module 602 is configured to determine the type of the marked starting point based on a difference between the average brightness of the current image block and the average brightness of the previous adjacent image block or a color gradient difference of the current image block, if the average brightness of the current image block meets a preset brightness threshold and there is a marked starting point of an undetermined type; the marked starting point types include non-glare starting points and glare starting points;
[0162] The second determining module 603 is configured to retain the marked starting point type as a glare starting point, and after detecting all image blocks of the image, determine the boundary of the glare area of the image according to the retained glare starting point.
[0163] In an optional embodiment, the method further includes:
[0164] The marking module is configured to, when the average brightness of the current image block meets a preset brightness threshold and there is a starting point of the mark of an undetermined type, mark the starting point and traverse to the next image block if the average brightness of the current image block is greater than a first average brightness threshold before determining the type of the starting point of the mark based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block.
[0165] In an optional embodiment, the method further includes:
[0166] a recording module configured to record the number of blocks whose average brightness of the current image block is continuously greater than a first average brightness threshold during the traversal process;
[0167] a discarding module configured to discard the marked starting point when the number of blocks whose average brightness of the current image block is continuously greater than the first brightness threshold is less than a preset block number threshold;
[0168] The third determining module is configured to determine that there is a starting point of an undetermined type of mark when the number of blocks whose average brightness of the current image block is continuously greater than the first brightness threshold is greater than or equal to a preset block number threshold.
[0169] In an optional embodiment, the first determining module 602 includes:
[0170] The first determination submodule is configured to determine the type of the starting point of the mark based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block when the average brightness of the current image block is less than or equal to the first average brightness threshold and greater than a second average brightness threshold, and there is a starting point of the mark of undetermined type; wherein the second average brightness threshold is less than the first average brightness threshold.
[0171] In an optional embodiment, the first determining submodule includes:
[0172] a first judging unit configured to judge whether a difference between the average brightness of the current image block and the average brightness of the previous adjacent image block is greater than or equal to a first brightness difference threshold;
[0173] The first discarding unit is configured to determine that the type of the marked starting point is the non-glare starting point and discard the marked starting point when the change in the average brightness of the current image block and the average brightness of the previous adjacent image block is greater than or equal to a first brightness change threshold.
[0174] In an optional embodiment, the first determining submodule includes:
[0175] a second judging unit configured to judge whether a change between the average brightness of the current image block and the average brightness of the previous adjacent image block is less than a first brightness change threshold and greater than a second brightness change threshold;
[0176] The first determination unit is configured to determine the type of the starting point of the mark according to the color gradient difference of the current image block when the change in the average brightness of the current image block and the average brightness of the previous adjacent image block is less than a first brightness change threshold and greater than a second brightness change threshold.
[0177] In an optional embodiment, the first determining unit includes:
[0178] A first judging subunit is configured to judge whether the color gradient difference of the current image block is less than a color gradient difference threshold;
[0179] a first discarding subunit, configured to, when the color gradient difference of the current image block is less than a color gradient difference threshold, determine that the type of the marked starting point is the non-glare starting point, and discard the marked starting point;
[0180] The first determining subunit is configured to determine that the type of the marked starting point is the colored glare starting point when the color gradient difference of the current image block is greater than or equal to a color gradient difference threshold.
[0181] In an optional embodiment, the first determining submodule further includes:
[0182] The second determination unit is configured to determine the type of the starting point of the mark based on the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block when the average brightness of the current image block is less than the second average brightness threshold and there is a starting point of the mark of undetermined type.
[0183] In an optional embodiment, the second determining unit includes:
[0184] A second judging subunit is configured to judge whether the color gradient difference of the current image block is less than a color gradient difference threshold;
[0185] a second determining subunit, configured to determine that the type of the marked starting point is a white glare starting point when the color gradient difference of the current image block is less than a color gradient difference threshold;
[0186] The third determining subunit is configured to determine that the type of the marked starting point is a colored glare starting point when the color gradient difference of the current image block is greater than or equal to a color gradient difference threshold.
[0187] In an optional embodiment, the method further includes:
[0188] a second acquisition module configured to, after retaining the starting point of the marked starting point of the type being a glare starting point, traverse to the next image block, and, if the average brightness of the current image block is greater than a third brightness threshold, acquire the glare starting point closest to the center position coordinates of the current image block, and acquire a second Euclidean distance between the center position coordinates of the current image block and the closest glare starting point; wherein the third brightness threshold is less than the second brightness threshold;
[0189] and a deleting module configured to delete the most recent glare starting point based on a change in the average brightness of the current image block and the average brightness of the image block at the previous adjacent position or a color gradient difference of the current image block when the second Euclidean distance is less than a second preset distance and the center position coordinates of the current image block are to the left of the most recent glare starting point.
[0190] In an optional embodiment, the deletion module includes:
[0191] The first deletion submodule is configured to delete the most recent glare starting point when a change in the average brightness of the current image block and the average brightness of the image block at the previous adjacent position is greater than the first brightness change threshold.
[0192] In an optional embodiment, the deletion module includes:
[0193] The second deletion submodule is configured to delete the most recent glare starting point if the change in the average brightness of the image block and the average brightness of the image block at the previous adjacent position is less than or equal to the first brightness change threshold and greater than the second brightness change threshold, and the color gradient difference of the image block is less than the preset color gradient difference threshold.
[0194] In an optional embodiment, the method further includes:
[0195] an acquisition submodule, configured to acquire, after deleting the most recent glare starting point, a first Euclidean distance between the current glare starting point and all glare starting points recorded before the current glare starting point;
[0196] a judgment submodule configured to judge whether there is a target glare starting point whose first Euclidean distance to the current glare starting point is less than a first preset distance from all glare starting points recorded before the current glare starting point;
[0197] a first marking submodule, configured to mark the current glare starting point and the target glare starting point as the same glare source cluster if the target glare starting point exists;
[0198] The second marking submodule is configured to mark the current glare starting point as a new glare source cluster if the target glare starting point does not exist.
[0199] In an optional embodiment, after traversing all image blocks of the image, the method further includes:
[0200] a judgment module configured to judge whether the number of colored glare starting points in the glare light cluster is greater than or equal to the number of white glare starting points in the glare light cluster;
[0201] a fourth determining module configured to determine that the glare source cluster is a colored glare source cluster if the number of colored glare starting points in the glare source cluster is greater than or equal to the number of white glare starting points in the glare source cluster;
[0202] a fifth determining module configured to determine that the glare source cluster is a white glare source cluster if the number of colored glare points in the glare source cluster is less than the number of white glare starting points in the glare source cluster;
[0203] The sixth determining module is configured to determine the area formed by the colored glare light cluster and / or the white glare light cluster as the left boundary of the glare area of the image.
[0204] In an optional embodiment, the sixth determining module includes:
[0205] a second determining submodule, configured to respectively determine the total number of glare starting points in the colored glare source cluster and the white glare source cluster;
[0206] a third determining submodule, configured to determine that the colored glare cluster is a valid colored light source cluster if the total number of glare starting points in the colored glare light source cluster is greater than a first glare total number threshold;
[0207] a third deletion submodule, configured to delete the colored glare cluster if the total number of glare starting points in the colored glare source cluster is less than or equal to a first glare total number threshold;
[0208] a fourth determining submodule, configured to determine that the white glare cluster is a valid white light source cluster if the total number of glare starting points in the white glare light source cluster is greater than a second glare total number threshold;
[0209] a fourth deletion submodule, configured to delete the colored glare cluster if the total number of glare points in the colored glare source cluster is less than or equal to a second glare total number threshold;
[0210] The fifth determining submodule is configured to determine the area formed by the effective colored glare source cluster and / or the effective white glare source cluster as the left boundary of the glare area of the image.
[0211] It should be noted that the above modules can be implemented through software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0212] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when running.
[0213] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0214] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0215] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0216] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail here.
[0217] Obviously, those skilled in the art will appreciate that the various modules or steps of the present invention described above can be implemented using a general-purpose computing device, can be centralized on a single computing device, or can be distributed across a network of multiple computing devices. They can be implemented using program code executable by the computing device, and thus, can be stored in a storage device and executed by the computing device. In some cases, the steps shown or described herein can be performed in a different order than that shown, or can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0218] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention are intended to be within the scope of protection of the present invention.
Claims
1. A method for detecting glare in an image, comprising: Traverse the image row by row from left to right in blocks of a set size, and obtain the average brightness of the current image block, the change between the average brightness of the current image block and the average brightness of the previous adjacent image block, and the color gradient difference of the current image block during the traversal process; When the average brightness of the current image block meets a preset brightness threshold and there is a marked starting point of an undetermined type, determining the type of the marked starting point according to a change between the average brightness of the current image block and the average brightness of the previous adjacent image block or a color gradient difference of the current image block; The starting point types of the mark include non-glare starting point and glare starting point; The type of the starting point of the reserved mark is a starting point of the glare starting point, and after traversing all the image blocks of the image, the boundary of the glare area of the image is determined according to the reserved glare starting point.
2. The method according to claim 1, wherein: In a case where the average brightness of the current image block meets a preset brightness threshold and there is a starting point of a mark of an undetermined type, before determining the type of the starting point of the mark according to a change in the average brightness of the current image block and the average brightness of the previous adjacent image block or a color gradient difference of the current image block, the method further includes: When the average brightness of the current image block is greater than a first average brightness threshold, the starting point is marked and the next image block is traversed.
3. The method according to claim 2, wherein: Also includes: Recording the number of blocks whose average brightness of the current image block is continuously greater than a first average brightness threshold during the traversal process; When the number of blocks whose average brightness of the current image block is continuously greater than the first brightness threshold is less than a preset block number threshold, discarding the marked starting point; When the number of blocks whose average brightness of the current image block is continuously greater than the first brightness threshold is greater than or equal to a preset block number threshold, it is determined that there is a starting point of a mark of an undetermined type.
4. The method according to claim 2, wherein: The method further comprises: determining the type of the marked starting point according to a change between the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block when the average brightness of the current image block meets a preset brightness threshold and there is a marked starting point of an undetermined type. When the average brightness of the current image block is less than or equal to the first average brightness threshold and greater than the second average brightness threshold, and there is a starting point of a mark of undetermined type, the type of the starting point of the mark is determined according to the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block; wherein the second average brightness threshold is less than the first average brightness threshold.
5. The method according to claim 4, wherein: The method further comprises: determining the type of the marked starting point according to a change between the average brightness of the current image block and the average brightness of the previous adjacent image block or a color gradient difference of the current image block, when the average brightness of the current image block is less than or equal to the first average brightness threshold and greater than the second average brightness threshold, and there is a marked starting point of an undetermined type. Determine whether a change between the average brightness of the current image block and the average brightness of the previous adjacent image block is greater than or equal to a first brightness change threshold; The difference between the average brightness of the current image block and the average brightness of the previous adjacent image block is greater than or equal to the first brightness When the glare change amount threshold is exceeded, the type of the marked starting point is determined to be the non-glare starting point, and the marked starting point is discarded.
6. The method according to claim 4, wherein: The method further comprises: determining the type of the marked starting point according to a change between the average brightness of the current image block and the average brightness of the previous adjacent image block or a color gradient difference of the current image block, when the average brightness of the current image block is less than or equal to the first average brightness threshold and greater than the second average brightness threshold, and there is a marked starting point of an undetermined type. Determine whether a change between the average brightness of the current image block and the average brightness of the previous adjacent image block is less than a first brightness change threshold and greater than a second brightness change threshold; When the change in the average brightness of the current image block and the average brightness of the previous adjacent image block is less than a first brightness change threshold and greater than a second brightness change threshold, the type of the marked starting point is determined according to the color gradient difference of the current image block.
7. The method according to claim 6, wherein: The method of determining the type of the marked starting point according to the color gradient difference of the current image block when the amount of change between the average brightness of the current image block and the average brightness of the previous adjacent image block is less than a first brightness change threshold and greater than a second brightness change threshold comprises: Determine whether the color gradient difference of the current image block is less than a color gradient difference threshold; In a case where the color gradient difference of the current image block is less than a color gradient difference threshold, determining the type of the marked starting point to be the non-glare starting point, and discarding the marked starting point; In a case where the color gradient difference of the current image block is greater than or equal to a color gradient difference threshold, the type of the marked starting point is determined to be the colored glare starting point.
8. The method according to claim 4, wherein: The method further comprises: determining the type of the starting point of the mark according to a change between the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block when the average brightness of the current image block meets a preset brightness threshold and there is a starting point of the mark of an undetermined type. When the average brightness of the current image block is less than the second average brightness threshold and there is a starting point of a mark of undetermined type, the type of the starting point of the mark is determined according to the change in the average brightness of the current image block and the average brightness of the previous adjacent image block or the color gradient difference of the current image block.
9. The method according to claim 8, wherein: The method further comprises: determining the type of the marked starting point according to a change between the average brightness of the current image block and the average brightness of the previous adjacent image block or a color gradient difference of the current image block when the average brightness of the current image block is less than the second average brightness threshold and there is a marked starting point of an undetermined type. Determine whether the color gradient difference of the current image block is less than a color gradient difference threshold; In a case where the color gradient difference of the current image block is less than a color gradient difference threshold, determining that the type of the marked starting point is a white glare starting point; In a case where the color gradient difference of the current image block is greater than or equal to a color gradient difference threshold, it is determined that the type of the marked starting point is a colored glare starting point.
10. The method according to claim 4, wherein: After the start point of the reserved marked start point of type glare start point, also include: Traverse to the next image block, and when the average brightness of the current image block is greater than the third brightness threshold, obtain the glare starting point closest to the center position coordinates of the current image block, and obtain the center position coordinates of the current image block. A second Euclidean distance between the target and the nearest glare starting point; wherein the third brightness threshold is less than the second brightness threshold; When the second Euclidean distance is less than the second preset distance and the center position coordinates of the current image block are to the left of the nearest glare starting point, the nearest glare starting point is deleted according to the change in the average brightness of the current image block and the average brightness of the image block at the previous adjacent position or the color gradient difference of the current image block.
11. The method according to claim 10, wherein: The deleting the most recent glare starting point according to the change in the average brightness of the current image block and the average brightness of the image block at the previous adjacent position, and the color gradient difference of the current image block, comprises: When the difference between the average brightness of the current image block and the average brightness of the image block at the previous adjacent position is greater than the first brightness difference threshold, the most recent glare starting point is deleted.
12. The method according to claim 10, wherein: The deleting the most recent glare starting point according to the change in the average brightness of the current image block and the average brightness of the image block at the previous adjacent position, and the color gradient difference of the current image block, comprises: When the change in the average brightness of the image block and the average brightness of the image block at the previous adjacent position is less than or equal to the first brightness change threshold and greater than the second brightness change threshold, and the color gradient difference of the image block is less than the preset color gradient difference threshold, the most recent glare starting point is deleted.
13. The method according to claim 10, wherein: After deleting the most recent glare starting point, the method further includes: Obtaining a first Euclidean distance between the current glare starting point and all glare starting points recorded before the current glare starting point; From all glare starting points recorded before the current glare starting point, determining whether there is a target glare starting point whose first Euclidean distance from the current glare starting point is less than a first preset distance; If the target glare starting point exists, marking the current glare starting point and the target glare starting point as the same glare source cluster; If the target glare starting point does not exist, the current glare starting point is marked as a new glare source cluster.
14. The method according to claim 13, wherein: After traversing all the image blocks of the image, the method further includes: Determining whether the number of colored glare starting points in the glare source cluster is greater than or equal to the number of white glare starting points in the glare source cluster; If the number of colored glare starting points in the glare source cluster is greater than or equal to the number of white glare starting points in the glare source cluster, then determining that the glare source cluster is a colored glare source cluster; If the number of colored glare points in the glare source cluster is less than the number of white glare starting points in the glare source cluster, then determining that the glare source cluster is a white glare source cluster; An area formed by the colored glare source cluster and / or the white glare source cluster is determined as a left boundary of the glare area of the image.
15. The method according to claim 14, wherein: The step of determining the area formed by the colored glare source cluster and / or the white glare source cluster as the left boundary of the glare area of the image includes: respectively determining the total number of glare starting points in the colored glare source cluster and the white glare source cluster; If the total number of glare starting points in the colored glare source cluster is greater than a first glare total number threshold, determining the colored glare cluster as a valid colored light source cluster; If the total number of glare starting points in the colored glare source cluster is less than or equal to a first glare total number threshold, deleting the colored glare cluster; If the total number of glare starting points in the white glare light source cluster is greater than a second glare total number threshold, determining that the white glare light source cluster is a valid white light source cluster; If the total number of glare points in the colored glare source cluster is less than or equal to a second total glare threshold, deleting the colored glare cluster; An area formed by the effective colored glare source cluster and / or the effective white glare source cluster is determined as a left boundary of the glare area of the image.
16. An image glare detection device, comprising: A first acquisition module is configured to traverse the image row by row from left to right according to blocks of a set size, and obtain the average brightness of the current image block, the change between the average brightness of the current image block and the average brightness of the previous adjacent image block, and the color gradient difference of the current image block during the traversal process; A first determination module is configured to determine the type of the marked starting point according to a change in the average brightness of the current image block and the average brightness of the previous adjacent image block or a color gradient difference of the current image block when the average brightness of the current image block meets a preset brightness threshold and there is a marked starting point of an undetermined type; The starting point types of the mark include non-glare starting point and glare starting point: The second determining module is configured to retain the marked starting point of a type that is a glare starting point, and after traversing all image blocks of the image, determine the boundary of the glare area of the image according to the retained glare starting point.
17. A computer-readable storage medium having a computer program stored therein, wherein: When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 15 are implemented.
18. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of claims 1 to 15 when executing the computer program.
Citation Information
Patent Citations
Stain detection method and device for camera module
CN106791804A
Ceramic product surface spot detection method and equipment based on machine vision
CN112037175A
Method for detecting position of invisible laser spot near 850nm
CN112950511A
Glare detection method and device, equipment and storage medium
CN113674217A
System and method for non-cooperative iris image acquisition
US20110150334A1