Mosaic detection method, device, electronic device and readable storage medium
By dividing the image to be detected into multiple image areas and determining the target pixel of the mosaic anchor point, the problems of high error rate and high computational complexity of the existing mosaic detection methods are solved, and higher detection accuracy and lower computational complexity are achieved.
Patent Information
- Application Number
- CN202110976809.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-24
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2041-08-24
AI Technical Summary
The existing mosaic detection methods have high misjudgment rate, high calculation complexity and low detection accuracy, making it difficult to effectively detect mosaic blocks in videos or images.
By converting the image to be detected into a grayscale image and dividing it into a plurality of image areas, the mosaic anchor target pixel is determined based on the pixel grayscale values of each area, and then the detection result of the mosaic block is obtained based on the pixel interval between the target pixels.
It reduces the misjudgment rate of mosaic detection, improves the accuracy of detection, reduces the computational complexity, and can effectively identify and locate mosaic blocks.
Smart Images

Figure CN113850757B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to the field of artificial intelligence technology such as cloud services and image processing. A mosaic detection method, device, electronic device and readable storage medium are provided. Background Art
[0002] In order to protect or hide some information in a video or image, mosaic processing is performed, and the result of the processing is to add an area consisting of adjacent code blocks to the video or image.
[0003] In some application scenarios that require high video or image quality, mosaic blocks need to be detected to prevent videos or images containing mosaic blocks from being displayed to viewers. However, existing detection methods have problems such as high misjudgment rate, high computational complexity, and low detection accuracy. Summary of the invention
[0004] According to a first aspect of the present disclosure, a mosaic detection method is provided, comprising: acquiring an image to be detected, and converting the image to be detected into a grayscale image; dividing the grayscale image into a plurality of image areas, and determining target pixels belonging to mosaic anchor points in each image area according to the grayscale values of pixels contained in each image area; and obtaining a detection result of a mosaic block in the image to be detected according to the pixel intervals between the target pixels.
[0005] According to a second aspect of the present disclosure, a mosaic detection device is provided, comprising: an acquisition unit, used to acquire an image to be detected and convert the image to be detected into a grayscale image; a processing unit, used to divide the grayscale image into multiple image areas, and determine the target pixels belonging to the mosaic anchor points in each image area according to the grayscale values of the pixels contained in each image area; and a detection unit, used to obtain the detection result of the mosaic block in the image to be detected according to the pixel interval between the target pixels.
[0006] According to a third aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.
[0007] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method as described above.
[0008] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program implements the method as described above when executed by a processor.
[0009] It can be seen from the above technical solution that this embodiment can determine the target pixels belonging to the mosaic anchor point in each image area by dividing the grayscale image into multiple image areas, and then obtain the detection result of the mosaic block according to the determined target pixels, which can avoid misjudgment when detecting mosaics, reduce the computational complexity of mosaic detection, and improve the accuracy of mosaic detection.
[0010] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0012] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure;
[0013] Figure 2 is a schematic diagram according to a second embodiment of the present disclosure;
[0014] Figure 3 is a schematic diagram according to a third embodiment of the present disclosure;
[0015] Figure 4 is a schematic diagram according to a fourth embodiment of the present disclosure;
[0016] Figure 5 is a schematic diagram according to a fifth embodiment of the present disclosure;
[0017] Figure 6 It is a block diagram of an electronic device used to implement the mosaic detection method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0018] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and mechanisms is omitted in the following description.
[0019] Figure 1 Schematic diagram of the first embodiment of the present disclosure. Figure 1 As shown, the mosaic detection method of this embodiment may specifically include the following steps:
[0020] S101, obtaining an image to be detected, and converting the image to be detected into a grayscale image;
[0021] S102, dividing the grayscale image into a plurality of image regions, and determining a target pixel belonging to a mosaic anchor point in each image region according to the grayscale value of the pixels contained in each image region;
[0022] S103 . Obtain a detection result of a mosaic block in the image to be detected according to a pixel interval between the target pixels.
[0023] The mosaic detection method of the present embodiment, after converting the acquired image to be detected into a grayscale image, first divides the grayscale image into multiple image areas, determines the target pixels belonging to the mosaic anchor points in each image area according to the grayscale values of the pixels contained in each image area, and then obtains the detection result of the mosaic block in the image to be detected according to the pixel interval between the determined target pixels. The present embodiment can determine the target pixels belonging to the mosaic anchor points in each image area by dividing the grayscale image into multiple image areas, and then obtains the detection result of the mosaic block according to the determined target pixels, which can avoid misjudgment when detecting mosaics and improve the accuracy of mosaic detection.
[0024] In this embodiment, when executing S101 to obtain the image to be detected, the image input by the user can be used as the image to be detected, each image frame in the video input by the user can be used as the image to be detected, or an image selected from the network can be used as the image to be detected.
[0025] In this embodiment, after executing S101 to obtain the image to be detected, the obtained image to be detected is converted into a grayscale image. This embodiment does not limit the method of converting the image.
[0026] After executing S101 to convert the acquired image to be detected into a grayscale image, this embodiment executes S102 to divide the grayscale image into multiple image areas, and determines the target pixels belonging to the mosaic anchor points in each image area according to the grayscale values of the pixels included in each image area.
[0027] The mosaic anchor point in this embodiment represents a position point in the mosaic block, and the determined target pixel belonging to the mosaic anchor point is a pixel in the mosaic block, specifically a pixel in a mosaic code block in the mosaic block.
[0028] The image area divided by executing S102 in this embodiment is a square area composed of four first areas, each of which contains a plurality of equally divided sub-areas, and the plurality of equally divided sub-areas contains a target sub-area. In other words, the image area divided by this embodiment is the area for mosaic anchor point detection.
[0029] In this embodiment, the number of sub-regions included in the first region does not exceed the number of pixels included in the mosaic code block, and the number can be preset. For example, if the size of the mosaic code block is 6 pixels×6 pixels, the number of sub-regions in this embodiment can be 9, 16, 25 or 36.
[0030] In addition, when executing S102 to select a sub-region from multiple sub-regions as a target sub-region, the present embodiment can select a randomly selected sub-region as the target sub-region; or a sub-region located at a preset position can be used as the target sub-region, for example, the sub-region located in the upper left corner of the center position of the image area is used as the target sub-region, the sub-region located in the upper right corner of the center position of the image area is used as the target sub-region, the sub-region located in the lower left corner of the center position of the image area is used as the target sub-region, or the sub-region located in the lower right corner of the center position of the image area is used as the target sub-region.
[0031] Since the grayscale standard deviations between pixels in each mosaic code block in the mosaic block are relatively small, and the grayscale means between pixels in adjacent mosaic code blocks are relatively large, this embodiment divides the grayscale image into multiple image areas according to the above characteristics of the mosaic block, and the four first areas in the image area are used to represent a corner of four adjacent mosaic code blocks, and the target sub-area is used to represent the corner point of the mosaic code block corresponding to the first area where it is located.
[0032] That is to say, this embodiment determines the target pixels belonging to the mosaic anchor points in the grayscale image by dividing the image area. Since the divided image area fully matches the characteristics of the mosaic block itself, the accuracy of the determined target pixels can be improved.
[0033] Specifically, when executing S102 to divide the grayscale image into multiple image areas and determining the target pixels belonging to the mosaic anchor points in each image area according to the grayscale values of the pixels contained in each image area, the present embodiment can adopt an optional implementation method as follows: when it is determined that the standard deviation of the grayscale values of the pixels in each first area of the image area is less than a first threshold value, and the difference between the mean grayscale values of the pixels in any two adjacent first areas is greater than a second threshold value, the pixels located at the position of the target sub-area in the image area are taken as the target pixels belonging to the mosaic anchor point.
[0034] Since the division of image areas is designed based on the structural characteristics of mosaics, this embodiment determines the target pixels belonging to the mosaic anchor points in the grayscale image by dividing the image areas, which can effectively eliminate the influence of the cross-edges of objects and will not cause missed judgments due to the misalignment of mosaic edges caused by image compression, thereby improving the accuracy of the determined target pixels.
[0035] In this embodiment, when executing S102 to take the pixel located at the position of the target sub-region in the image area as the target pixel belonging to the mosaic anchor point, an optional implementation method that can be adopted is: when it is determined that the difference between the mean grayscale values of the pixels in the first area located at the diagonal corner of the image area is greater than the third threshold, the pixel located at the position of the target sub-region in the image area is taken as the target pixel belonging to the mosaic anchor point.
[0036] Since the colors of the diagonal blocks in the chessboards of Go and chess are all the same, when detecting mosaics, when the difference between the mean gray values of the pixels in the diagonal blocks is determined to be small, it is considered to be a chessboard, and when the difference between the mean gray values of the pixels in the diagonal blocks is determined to be large, it is considered to be a mosaic block. Therefore, this embodiment can avoid the problem of misjudging the chessboard as a mosaic block through the above steps.
[0037] After executing S102 to determine the target pixels belonging to the mosaic anchor points in each image area, this embodiment executes S103 to obtain the detection result of the mosaic block in the image to be detected according to the pixel intervals between the target pixels.
[0038] Specifically, when the present embodiment executes S103 to obtain the detection result of the mosaic block in the image to be detected according to the pixel interval between the target pixels, an optional implementation method that can be adopted is: respectively counting the pixel intervals between adjacent target pixels in each row and each column to obtain the number of target pixels corresponding to different pixel intervals in each row and each column, and the number of target pixels is obtained by accumulating the number of target pixels with the same pixel interval in each row and each column; according to the pixel interval with the largest number of target pixels, the size of the mosaic block in the image to be detected is obtained; and the size of the mosaic block obtained is used as the detection result of the mosaic block in the image to be detected.
[0039] Usually, the mosaic blocks in the image are square blocks. Therefore, when executing S103 to obtain the size of the mosaic block according to the pixel interval with the largest number of target pixels, this embodiment may use (pixel interval×pixel interval) as the size of the mosaic block.
[0040] If the pixel interval between target pixels cannot be determined when executing S103 in this embodiment, that is, there is no target pixel or there is only one target pixel, it can be determined that there is no mosaic block in the image to be detected.
[0041] Through the above method provided by this embodiment, after determining the target pixels belonging to the mosaic anchor points in the image to be detected by dividing the grayscale image into multiple image areas, the detection result of the mosaic block in the image to be detected is obtained according to the pixel interval between the target pixels, thereby avoiding misjudgment of the mosaic block, improving the detection accuracy of the mosaic block, and based on the detection of the mosaic block, it is also possible to determine the size of the mosaic block.
[0042] Figure 2 is a schematic diagram according to the second embodiment of the present disclosure. Figure 2 As shown, the mosaic detection method of this embodiment, when executing S103 "using the size of the mosaic block as the detection result of the mosaic block in the image to be detected", may specifically include the following steps:
[0043] S201, obtaining the upper boundary position and the lower boundary position of the target pixel in the image to be detected according to the pixel interval between adjacent target pixels in each row;
[0044] S202, obtaining the left boundary position and the right boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each column;
[0045] S203, obtaining the boundary position of the mosaic block in the image to be detected according to the boundary position of the target pixel in the image to be detected, the size of the mosaic block in the image to be detected and the structural information of the image area;
[0046] S204: Using the size and boundary position of the mosaic block as a detection result of the mosaic block in the image to be detected.
[0047] That is to say, in the present embodiment, when the image to be detected contains mosaic blocks, the boundary positions of the mosaic blocks in the image to be detected are further determined, so as to obtain not only the sizes of the mosaic blocks in the image to be detected but also the positions of the mosaic blocks in the image to be detected.
[0048] When executing S201 in this embodiment to obtain the upper boundary position and the lower boundary position of the target pixels in the image to be detected according to the pixel intervals between adjacent target pixels in each row, an optional implementation method that can be adopted is: according to the pixel intervals between adjacent target pixels in each row, obtain the number of row target pixels corresponding to different pixel intervals in each row; according to the maximum value of the number of row target pixels, in order from top to bottom, take the first row in each row that meets the first preset condition as the upper boundary position, and take the last row in each row that meets the first preset condition as the lower boundary position.
[0049] The first preset condition in this embodiment may be that the number of row target pixels exceeds a first preset ratio of the maximum value, and the first preset ratio may be preset, for example, 25%.
[0050] When executing S201 in this embodiment to obtain the left boundary position and the right boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each column, an optional implementation method that can be adopted is: according to the pixel intervals between adjacent target pixels in each column, obtain the number of column target pixels corresponding to different pixel intervals in each column; according to the maximum value of the number of column target pixels, in order from left to right, take the first column in each column that meets the second preset condition as the left boundary position, and take the last column in each column that meets the second preset condition as the right boundary position.
[0051] The second preset condition in this embodiment may be that the number of target pixels in a column exceeds a second preset ratio of the maximum value. The second preset ratio may be preset, for example, 25%.
[0052] Since the target pixel in this embodiment only represents a pixel in the mosaic block and is not necessarily a pixel located at the boundary of the mosaic block, this embodiment also needs to adjust the boundary position of the determined target pixel according to the size of the mosaic block and the structural information of the divided image area, so as to obtain the boundary position of the mosaic block in the image to be detected.
[0053] When executing S203, this embodiment can adjust the boundary position of the target pixel according to the number of sub-areas in the divided image area and the position of the target sub-area, for example, moving the boundary position to the left, right, up, or down; when it is determined that the size corresponding to the adjusted boundary position is consistent with the size of the mosaic block, the adjusted boundary position is used as the boundary position of the mosaic block.
[0054] After executing S203 to obtain the boundary position of the mosaic block in the image to be detected, this embodiment may further include the following contents: updating the boundary position of the mosaic block according to the mosaic code block located at the boundary position of the mosaic block.
[0055] That is to say, this embodiment can also update the boundary position of the obtained mosaic block, so that the boundary position of the mosaic block finally obtained is more accurate.
[0056] When executing S203, this embodiment updates the boundary position of the mosaic block according to the mosaic code blocks located at the boundary position of the mosaic block, and the following method can be adopted: for each boundary of the mosaic block, two code blocks located on the boundary are selected, and the selected code blocks can be located at preset positions on the boundary, for example, two code blocks at 1 / 3 and 3 / 2 on the boundary are selected; when it is determined that the standard deviation of the gray values of pixels in the two code blocks is less than the fourth threshold, one code block is expanded outward to continue the judgment until it is determined that the standard deviation of the gray values of pixels in the two code blocks is greater than the fourth threshold, and the boundary position of the code block at the time of the previous judgment is used as the updated boundary position.
[0057] When executing S203, this embodiment updates the boundary position of the mosaic block according to the mosaic code blocks located at the boundary position of the mosaic block, and can also adopt the following method: for each boundary of the mosaic block, two code blocks located at the boundary are selected; when it is determined that the gray value standard deviation of the pixels in the two code blocks is greater than the fourth threshold, one code block is expanded inward to continue the judgment until it is determined that the gray value standard deviation of the pixels in the two code blocks is less than the fourth threshold, and the boundary position of the code block at the time of this judgment is used as the updated boundary position.
[0058] Figure 3 is a schematic diagram according to the third embodiment of the present disclosure. Figure 3 , a schematic diagram of the image area divided in this embodiment is shown in FIG. 1 ; the image area includes four first areas 00, 01, 10 and 11, each of which includes nine sub-areas, each of which corresponds to one pixel, and the sub-area in the lower right corner of 00 is taken as the target sub-area, which is marked as a black solid block.
[0059] Figure 4 is a schematic diagram according to the fourth embodiment of the present disclosure. Figure 4 , a schematic diagram of an image to be detected obtained in this embodiment is shown; in the figure, there is a square mosaic block composed of multiple mosaic code blocks.
[0060] Figure 5 is a schematic diagram according to the fifth embodiment of the present disclosure. Figure 5 As shown, the mosaic detection device 500 of this embodiment includes:
[0061] The acquisition unit 501 is used to acquire the image to be detected and convert the image to be detected into a grayscale image;
[0062] A processing unit 502 is used to divide the grayscale image into multiple image regions, and determine the target pixel belonging to the mosaic anchor point in each image region according to the grayscale value of the pixels contained in each image region;
[0063] The detection unit 503 is used to obtain a detection result of the mosaic block in the image to be detected according to the pixel interval between the target pixels.
[0064] When acquiring the image to be detected, the acquisition unit 501 may use the image input by the user as the image to be detected, or may use each image frame in the video input by the user as the image to be detected, or may use an image selected from the network as the image to be detected.
[0065] After acquiring the image to be detected, the acquisition unit 501 converts the acquired image to be detected into a grayscale image. This embodiment does not limit the method of converting the image.
[0066] In this embodiment, after the acquisition unit 501 converts the acquired image to be detected into a grayscale image, the processing unit 502 divides the grayscale image into multiple image areas, and determines the target pixels belonging to the mosaic anchor points in each image area according to the grayscale values of the pixels contained in each image area.
[0067] The image area divided by the processing unit 502 is a square area composed of four first areas, each of which includes a plurality of equally divided sub-areas, and the plurality of equally divided sub-areas includes a target sub-area.
[0068] When the processing unit 502 selects a sub-region from multiple sub-regions as the target sub-region, it may select a randomly selected sub-region as the target sub-region; or it may select a sub-region located at a preset position as the target sub-region.
[0069] Since the grayscale standard deviations between pixels in each mosaic code block in the mosaic block are relatively small, and the grayscale means between pixels in adjacent mosaic code blocks are relatively large, the processing unit 502 divides the grayscale image into multiple image areas according to the above characteristics of the mosaic block, and the four first areas in the image area are used to represent a corner of four adjacent mosaic code blocks, and the target sub-area is used to represent the corner point of the mosaic code block corresponding to the first area where it is located.
[0070] That is to say, this embodiment determines the target pixels belonging to the mosaic anchor points in the grayscale image by dividing the image area. Since the divided image area fully matches the characteristics of the mosaic block itself, the accuracy of the determined target pixels can be improved.
[0071] Specifically, when the processing unit 502 divides the grayscale image into multiple image areas and determines the target pixels belonging to the mosaic anchor point in each image area according to the grayscale values of the pixels contained in each image area, an optional implementation method that can be adopted is: when it is determined that the standard deviation of the grayscale values of the pixels located in each first area of the image area is less than a first threshold value, and the difference between the mean grayscale values of the pixels in any two adjacent first areas is greater than a second threshold value, the pixel located at the position of the target sub-area in the image area is taken as the target pixel belonging to the mosaic anchor point.
[0072] Since the division of the image area is designed based on the structural characteristics of the mosaic, the processing unit 502 determines the target pixels belonging to the mosaic anchor points in the grayscale image by dividing the image area, which can effectively eliminate the influence of the cross-edges of the object and will not cause missed judgments due to the misalignment of the mosaic edges caused by image compression, thereby improving the accuracy of the determined target pixels.
[0073] When the processing unit 502 takes the pixel located at the position of the target sub-region in the image area as the target pixel belonging to the mosaic anchor point, an optional implementation method that can be adopted is: when it is determined that the difference between the mean grayscale values of pixels in the first area located at the diagonal corner of the image area is greater than a third threshold, the pixel located at the position of the target sub-region in the image area is taken as the target pixel belonging to the mosaic anchor point.
[0074] Since the colors of the diagonal blocks in the chessboard of Go, chess, etc. are all the same, when performing mosaic detection, when the difference between the grayscale value means of the pixels in the diagonal blocks is determined to be small, it is considered to be a chessboard, and when the difference between the grayscale value means of the pixels in the diagonal blocks is determined to be large, it is considered to be a mosaic block. Therefore, the processing unit 502 can avoid the problem of misjudging the chessboard as a mosaic block through the above steps.
[0075] In this embodiment, after the processing unit 502 determines the target pixels belonging to the mosaic anchor points in each image area, the detection unit 503 obtains the detection result of the mosaic block in the image to be detected according to the pixel interval between the target pixels.
[0076] Specifically, when the detection unit 503 obtains the detection result of the mosaic block in the image to be detected based on the pixel interval between the target pixels, an optional implementation method that can be adopted is: respectively counting the pixel intervals between adjacent target pixels in each row and each column to obtain the number of target pixels corresponding to different pixel intervals in each row and each column; obtaining the size of the mosaic block in the image to be detected based on the pixel interval with the largest number of target pixels; and using the obtained size of the mosaic block as the detection result of the mosaic block in the image to be detected.
[0077] If the detection unit 503 is unable to determine the pixel interval between the target pixels, that is, there is no target pixel or there is only one target pixel, it can be determined that there is no mosaic block in the image to be detected.
[0078] When the detection unit 503 uses the obtained size of the mosaic block as the detection result of the mosaic block in the image to be detected, the following method can be adopted: according to the pixel interval between adjacent target pixels in each row, the upper boundary position and the lower boundary position of the target pixel in the image to be detected are obtained; according to the pixel interval between adjacent target pixels in each column, the left boundary position and the right boundary position of the target pixel in the image to be detected are obtained; according to the boundary position of the target pixel in the image to be detected, the size of the mosaic block in the image to be detected and the structural information of the image area, the boundary position of the mosaic block in the image to be detected is obtained; and the size and boundary position of the mosaic block are used as the detection result of the mosaic block in the image to be detected.
[0079] That is to say, when determining that the image to be detected contains mosaic blocks, this embodiment will further determine the boundary positions of the mosaic blocks in the image to be detected, so as to obtain not only the sizes of the mosaic blocks in the image to be detected but also the positions of the mosaic blocks in the image to be detected.
[0080] When the detection unit 503 obtains the upper boundary position and the lower boundary position of the target pixel in the image to be detected according to the pixel interval between adjacent target pixels in each row, an optional implementation method that can be adopted is: according to the pixel interval between adjacent target pixels in each row, obtain the number of row target pixels corresponding to different pixel intervals in each row; according to the maximum value of the number of row target pixels, in order from top to bottom, take the first row in each row that meets the first preset condition as the upper boundary position, and take the last row in each row that meets the first preset condition as the lower boundary position.
[0081] The first preset condition in the detection unit 503 may be that the number of row target pixels exceeds a first preset ratio of the maximum value, and the first preset ratio may be preset, for example, 25%.
[0082] When the detection unit 503 obtains the left boundary position and the right boundary position of the target pixel in the image to be detected according to the pixel interval between adjacent target pixels in each column, an optional implementation method that can be adopted is: according to the pixel interval between adjacent target pixels in each column, obtain the number of column target pixels corresponding to different pixel intervals in each column; according to the maximum value of the number of column target pixels, in order from left to right, take the first column in each column that meets the second preset condition as the left boundary position, and take the last column in each column that meets the second preset condition as the right boundary position.
[0083] The second preset condition in the detection unit 503 may be that the number of target pixels in a column exceeds a second preset ratio of the maximum value, and the second preset ratio may be preset, for example, 25%.
[0084] Since the target pixel in this embodiment only represents a pixel in the mosaic block and is not necessarily a pixel located at the boundary of the mosaic block, the detection unit 503 also needs to adjust the boundary position of the determined target pixel according to the size of the mosaic block and the structural characteristics of the divided image area, so as to obtain the boundary position of the mosaic block in the image to be detected.
[0085] The detection unit 503 can adjust the boundary position of the target pixel according to the number of sub-regions in the image area and the position of the target sub-region; when it is determined that the size corresponding to the adjusted boundary position is consistent with the size of the mosaic block, the adjusted boundary position is used as the boundary position of the mosaic block.
[0086] The mosaic detection device 500 of this embodiment may further include an updating unit 504, which is used to perform the following contents after the detection unit 503 obtains the boundary position of the mosaic block in the image to be detected: updating the boundary position of the mosaic block according to the mosaic code block located at the boundary position of the mosaic block.
[0087] That is to say, the updating unit 504 may also update the boundary position of the obtained mosaic block, so that the boundary position of the finally obtained mosaic block is more accurate.
[0088] When the updating unit 504 updates the boundary position of the mosaic block according to the mosaic code block located at the boundary position of the mosaic block, the following method can be adopted: for each boundary of the mosaic block, two code blocks located on the boundary are selected; when it is determined that the standard deviation of the grayscale values of the pixels in the two code blocks is less than the fourth threshold, one code block is expanded outward to continue the judgment until it is determined that the standard deviation of the grayscale values of the pixels in the two code blocks is greater than the fourth threshold, and the boundary position of the code block at the time of the previous judgment is used as the updated boundary position.
[0089] When updating the boundary position of the mosaic block according to the mosaic code block located at the boundary position of the mosaic block, the updating unit 504 may also adopt the following method: for each boundary of the mosaic block, two code blocks located on the boundary are selected; when it is determined that the standard deviation of the grayscale values of the pixels in the two code blocks is greater than the fourth threshold, one code block is expanded inward to continue the judgment until it is determined that the standard deviation of the grayscale values of the pixels in the two code blocks is less than the fourth threshold, and the boundary position of the code block at the time of this judgment is used as the updated boundary position.
[0090] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0091] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0092] like Figure 6 , is a block diagram of an electronic device according to a mosaic detection method according to an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0093] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0094] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0095] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as the mosaic detection method. For example, in some embodiments, the mosaic detection method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608.
[0096] In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the mosaic detection method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the mosaic detection method in any other appropriate manner (e.g., by means of firmware).
[0097] Various implementations of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0098] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable mosaic detection device, so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0099] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0100] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0101] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0102] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server for a distributed system, or a server combined with a blockchain.
[0103] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0104] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A mosaic detection method, comprising: Acquire an image to be detected, and convert the image to be detected into a grayscale image; Dividing the grayscale image into a plurality of image regions, and determining a target pixel belonging to a mosaic anchor point in each image region according to the grayscale value of the pixels contained in each image region; Obtaining a detection result of a mosaic block in the image to be detected according to a pixel interval between the target pixels; Wherein, the image area is a square area composed of four first areas, each of which includes a plurality of equally divided sub-areas, and the plurality of equally divided sub-areas includes a target sub-area; Determining the target pixels belonging to the mosaic anchor points in each image area according to the grayscale values of the pixels included in each image area includes: When it is determined that the standard deviation of the grayscale values of pixels in each first area of the image area is less than a first threshold, and the difference between the mean grayscale values of pixels in any two adjacent first areas is greater than a second threshold, the pixel located at the position of the target sub-area in the image area is used as the target pixel belonging to the mosaic anchor point.
2. The method according to claim 1, wherein: The step of taking a pixel located at a position of a target sub-region in the image region as a target pixel belonging to a mosaic anchor point comprises: When it is determined that the difference between the grayscale value means of pixels in the first area located at the diagonal corner of the image area is greater than a third threshold, the pixel located at the position of the target sub-area in the image area is used as the target pixel belonging to the mosaic anchor point.
3. The method according to claim 1, wherein: The step of obtaining the detection result of the mosaic block in the image to be detected according to the pixel interval between the target pixels includes: Counting the pixel intervals between adjacent target pixels in each row and each column respectively, and obtaining the number of target pixels corresponding to different pixel intervals in each row and each column; Obtaining the size of the mosaic block in the image to be detected according to the pixel interval with the largest number of target pixels; The size of the mosaic block is used as a detection result of the mosaic block in the image to be detected.
4. The method according to claim 3, wherein: The step of using the size of the mosaic block as the detection result of the mosaic block in the image to be detected includes: Obtaining the upper boundary position and the lower boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each row; Obtaining the left boundary position and the right boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each column; Obtaining the boundary position of the mosaic block in the image to be detected according to the boundary position of the target pixel in the image to be detected, the size of the mosaic block in the image to be detected and the structural information of the image area; The size and boundary position of the mosaic block are used as the detection result of the mosaic block in the image to be detected.
5. The method according to claim 4, wherein: The step of obtaining the upper boundary position and the lower boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each row includes: According to the pixel intervals between adjacent target pixels in each row, the number of row target pixels corresponding to different pixel intervals in each row is obtained; According to the maximum value of the row target pixel number, in order from top to bottom, the first row in each row that meets the first preset condition is used as the upper boundary position, and the last row in each row that meets the first preset condition is used as the lower boundary position.
6. The method according to claim 4, wherein: The step of obtaining the left boundary position and the right boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each column comprises: According to the pixel intervals between adjacent target pixels in each column, the number of column target pixels corresponding to different pixel intervals in each column is obtained; According to the maximum value of the target pixel number of the column, in order from left to right, the first column in each column that meets the second preset condition is used as the left boundary position, and the last column in each column that meets the second preset condition is used as the right boundary position.
7. The method according to claim 4, further comprising: After the boundary position of the mosaic block in the image to be detected is obtained, the boundary position of the mosaic block is updated according to the mosaic code block located at the boundary position of the mosaic block.
8. A mosaic detection device, comprising: An acquisition unit, used for acquiring an image to be detected and converting the image to be detected into a grayscale image; A processing unit, configured to divide the grayscale image into a plurality of image regions, and determine a target pixel belonging to a mosaic anchor point in each image region according to the grayscale value of the pixels contained in each image region; A detection unit, used for obtaining a detection result of a mosaic block in the image to be detected according to a pixel interval between the target pixels; The image area divided by the processing unit is a square area composed of four first areas, each of which contains a plurality of equally divided sub-areas, and the plurality of equally divided sub-areas contain a target sub-area; When the processing unit determines the target pixel belonging to the mosaic anchor point in each image area according to the grayscale value of the pixel included in each image area, the processing unit specifically performs: When it is determined that the standard deviation of the grayscale values of pixels in each first area of the image area is less than a first threshold, and the difference between the mean grayscale values of pixels in any two adjacent first areas is greater than a second threshold, the pixel located at the position of the target sub-area in the image area is used as the target pixel belonging to the mosaic anchor point.
9. The device according to claim 8, wherein: When the processing unit uses the pixel located at the position of the target sub-region in the image region as the target pixel belonging to the mosaic anchor point, the processing unit specifically performs: When it is determined that the difference between the grayscale value means of pixels in the first area located at the diagonal corner of the image area is greater than a third threshold, the pixel located at the position of the target sub-area in the image area is used as the target pixel belonging to the mosaic anchor point.
10. The device according to claim 8, wherein: When the detection unit obtains the detection result of the mosaic block in the image to be detected according to the pixel interval between the target pixels, the detection unit specifically performs: Counting the pixel intervals between adjacent target pixels in each row and each column respectively, and obtaining the number of target pixels corresponding to different pixel intervals in each row and each column; Obtaining the size of the mosaic block in the image to be detected according to the pixel interval with the largest number of target pixels; The size of the mosaic block is used as a detection result of the mosaic block in the image to be detected.
11. The device according to claim 10, wherein: When the detection unit uses the size of the mosaic block as the detection result of the mosaic block in the image to be detected, the detection unit specifically performs: Obtaining the upper boundary position and the lower boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each row; Obtaining the left boundary position and the right boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each column; Obtaining the boundary position of the mosaic block in the image to be detected according to the boundary position of the target pixel in the image to be detected, the size of the mosaic block in the image to be detected and the structural information of the image area; The size and boundary position of the mosaic block are used as the detection result of the mosaic block in the image to be detected.
12. The device according to claim 11, wherein When the detection unit obtains the upper boundary position and the lower boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each row, the detection unit specifically performs: According to the pixel intervals between adjacent target pixels in each row, the number of row target pixels corresponding to different pixel intervals in each row is obtained; According to the maximum value of the row target pixel number, in order from top to bottom, the first row in each row that meets the first preset condition is used as the upper boundary position, and the last row in each row that meets the first preset condition is used as the lower boundary position.
13. The device according to claim 11, wherein: When the detection unit obtains the left boundary position and the right boundary position of the target pixel in the image to be detected according to the pixel intervals between adjacent target pixels in each column, the detection unit specifically performs: According to the pixel intervals between adjacent target pixels in each column, the number of column target pixels corresponding to different pixel intervals in each column is obtained; According to the maximum value of the target pixel number of the column, in order from left to right, the first column in each column that meets the second preset condition is used as the left boundary position, and the last column in each column that meets the second preset condition is used as the right boundary position.
14. The apparatus according to claim 11, further comprising an updating unit, After the detection unit obtains the boundary position of the mosaic block in the image to be detected, the boundary position of the mosaic block is updated according to the mosaic code block located at the boundary position of the mosaic block.
15. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
16. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 7.
17. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Image processing device and method, and imaging device
CN104380726A
Video image mosaic detection method
CN106372584A