Method, device, computer equipment and storage medium for identifying black and white pictures

By splitting the picture into RGB three channels and calculating the pixel difference value of the channel, and counting the pixel difference ratio, the problem of complexity of black and white picture identification in the prior art is solved, and simple and effective black and white picture recognition is achieved.

CN109949376BActive Publication Date: 2024-11-05PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910136657.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-02-25
Publication Date
2024-11-05
Estimated Expiration
2039-02-25

Smart Images

  • Figure CN109949376B_ABST
    Figure CN109949376B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing, and discloses a method, device, computer equipment and storage medium for identifying black and white images. The method comprises: obtaining an image, and separating the image into three channels of RGB to obtain three channels of R channel, G channel and B channel; respectively calculating the effective pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel; determining the color type of the image according to the effective pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel. The present application can effectively identify black and white images by splitting the image into three channels of RGB and calculating the channel pixel difference; and counting the proportion of the pixel area with the pixel difference within the threshold range to the total area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to a method, device, computer equipment and storage medium for identifying black and white images. Background Art

[0002] Digital image processing, as a discipline, was formed in the early 1960s. It refers to the process of using computers and related technologies to perform certain operations on images to achieve a certain desired purpose. The purpose of early image processing was to improve the quality of images or human visual effects. With the rapid development of computer technology, digital image processing technology has not only made great progress in theory, but has also been widely valued in many application fields and achieved significant pioneering achievements.

[0003] In the existing technology of image recognition, there is currently no simple and effective solution for identifying black and white images. Although the existing image detection technology based on neural networks can be implemented, it requires model training and the calculation is complex, which is not suitable for simple recognition of black and white images. Summary of the invention

[0004] The purpose of the present application is to address the deficiencies in the prior art and to provide a method, device, computer equipment and storage medium for identifying black and white images. The method can effectively identify black and white images by splitting the image into three RGB channels and calculating the channel pixel difference; and by counting the proportion of the pixel area whose pixel difference is within the threshold range to the total area.

[0005] In order to achieve the above-mentioned purpose, the technical solution of the present application provides a method, device, computer equipment and storage medium for identifying black and white pictures.

[0006] The present application discloses a method for identifying black and white images, comprising the following steps:

[0007] Get an image, and separate the RGB three channels of the image to obtain three channels: R channel, G channel and B channel;

[0008] Calculate the pixel difference of each pixel between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel respectively, and obtain the effective pixel difference of each pixel between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel according to the pixel difference of each pixel between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel;

[0009] The color type of the picture is determined according to the effective pixel difference of each pixel point between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel.

[0010] Preferably, respectively calculating the pixel difference of each pixel point between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, comprises:

[0011] Obtain the pixel value of each pixel point in the R channel, the G channel and the B channel respectively, and generate the pixel matrices of the R channel, the G channel and the B channel respectively according to the pixel values;

[0012] The pixel matrices of the R channel, the G channel, and the B channel are subtracted in pairs to obtain pixel matrix differences between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the absolute value of the pixel matrix difference is taken.

[0013] Preferably, determining the color type of the picture according to the effective pixel difference between each pixel point of the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, comprises:

[0014] According to the effective pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel, respectively obtain the number of effective difference pixels between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel;

[0015] The color type of the picture is determined according to the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel.

[0016] Preferably, the obtaining the number of effective difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, respectively, according to the effective pixel difference of each pixel point between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, comprises:

[0017] Preset pixel threshold of difference pixel;

[0018] Compare the pixel difference of each pixel point between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, with the preset pixel threshold of the difference pixel;

[0019] The difference pixels that are smaller than the preset pixel threshold of the difference pixels are recorded, and the number of difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, that are smaller than the preset pixel threshold of the difference pixels are counted respectively.

[0020] Preferably, determining the color type of the picture according to the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, comprises:

[0021] Obtaining the total number of pixels of the picture, and obtaining the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture according to the total number of pixels of the picture and the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture;

[0022] The color type of the picture is determined according to the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture.

[0023] Preferably, determining the color type of the picture according to the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture, comprises:

[0024] Preset difference pixel ratio threshold;

[0025] The ratios of the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, to the total number of pixels of the image are compared with the preset difference pixel ratio threshold, and the color type of the image is determined according to the comparison results.

[0026] Preferably, the comparing the ratios of the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, to the total number of pixels of the picture with the preset difference pixel ratio threshold, and determining the color type of the picture according to the comparison results, comprises:

[0027] When the ratio between the number of valid difference pixels between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture is greater than the preset difference pixel ratio threshold, the pairs of channels corresponding to the difference pixels are recorded;

[0028] When the ratio between the number of valid difference pixels between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the image is compared with the preset difference pixel ratio threshold, if the number of recorded pairs of channels is at least 2, the image is determined to be a black and white image.

[0029] The present application also discloses a black-and-white picture identification device, the device comprising:

[0030] Channel separation module: configured to obtain an image and separate the image into three channels of RGB to obtain three channels of R channel, G channel and B channel;

[0031] Pixel calculation module: configured to respectively calculate the pixel difference of each pixel point between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and obtain the effective pixel difference of each pixel point between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel according to the pixel difference of each pixel point between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel;

[0032] Identification module: configured to determine the color type of the image according to the effective pixel difference of each pixel point between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel.

[0033] The present application also discloses a computer device, which includes a memory and a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by one or more of the processors, the one or more processors execute the steps of the above-mentioned black-and-white image identification method.

[0034] The present application also discloses a storage medium, which can be read and written by a processor, and the storage medium stores computer instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the above-mentioned black-and-white image identification method.

[0035] The beneficial effects of the present application are as follows: the present application can effectively identify black and white images by splitting the image into three RGB channels and calculating the channel pixel differences; and counting the proportion of pixel areas whose pixel differences are within a threshold range to the total area. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 This is a schematic diagram of a first embodiment of a method for identifying black and white images according to an embodiment of the present application;

[0037] Figure 2 A schematic diagram of a second embodiment of a method for identifying black and white images according to an embodiment of the present application;

[0038] Figure 3 A schematic diagram of a third embodiment of a method for identifying black and white images according to an embodiment of the present application;

[0039] Figure 4A schematic diagram of a fourth embodiment of a method for identifying a black-and-white image according to an embodiment of the present application;

[0040] Figure 5 A schematic diagram of a fifth embodiment of a method for identifying black and white images according to an embodiment of the present application;

[0041] Figure 6 This is a schematic diagram of a sixth embodiment of a method for identifying a black-and-white image according to an embodiment of the present application;

[0042] Figure 7 This is a schematic diagram of a seventh embodiment of a method for identifying a black-and-white image according to an embodiment of the present application;

[0043] Figure 8 This is a schematic diagram of the structure of a black-and-white image identification device according to an embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0045] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0046] The process of a black-and-white picture identification method in the first embodiment of the present application is as follows: Figure 1 As shown, this embodiment includes the following steps:

[0047] Step s101, obtaining a picture, and performing RGB three-channel separation on the picture to obtain three channels: R channel, G channel and B channel;

[0048] Specifically, when a picture is obtained, the RGB three-channel separation can be performed on the picture by calling the openCVSplit function to obtain the three channels of R (red), G (green) and B (blue) respectively. Since all colors within the human visual range can be composed of the three primary colors of red, green and blue; in the computer processing process, the picture is saved and processed in the form of a pixel matrix, and each pixel stores a color value. The color image will store the values ​​of the three primary colors of red, green and blue, and the grayscale image will only store one grayscale value. Therefore, after the RGB three-channel separation, the pixel value of each pixel point of each channel in the RGB three channels can be obtained, and the pixel value of each channel can exist in the form of a pixel matrix.

[0049] Step s102, respectively calculating the pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel, and obtaining the effective pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel according to the pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel;

[0050] Specifically, after obtaining the pixel matrices of the R (red) channel, G (green) channel and B (blue) channel, the pixel matrices of the three channels can be subtracted from each other to obtain the pixel matrix difference between the R channel and the G channel, the pixel matrix difference between the G channel and the B channel, and the pixel matrix difference between the R channel and the B channel, respectively. The pixel matrix difference includes the pixel difference value of each pixel point between the two channels.

[0051] Specifically, after obtaining the pixel difference of each pixel point between the three channels, since the pixel difference of each pixel point is different, a condition can be preset to find a valid pixel difference value among the pixel differences. For example, a pixel difference threshold value is pre-set, and then the pixel difference value in the pixel matrix difference is compared with the pixel difference threshold value, and the pixel difference value that meets the condition is selected. The pixel difference value that meets the condition is the valid pixel difference value.

[0052] Step s103, determining the color type of the image according to the effective pixel difference between each pixel point between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel.

[0053] Specifically, after obtaining the effective pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel, the number of effective difference pixels can be counted according to the effective pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel, and then the proportion of the number of effective difference pixels in each channel to the total number of pixels of the picture is calculated according to the number of effective difference pixels between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel and the total number of pixels of the picture, and statistical analysis is performed according to the proportion of the number of effective difference pixels to the total number of pixels of the picture, and then the color type of the picture is determined according to the statistical analysis result.

[0054] In this embodiment, by splitting the image into three RGB channels and calculating the channel pixel difference; and counting the proportion of the pixel area whose pixel difference is within the threshold range to the total area, black and white images can be effectively identified.

[0055] Figure 2 This is a flow chart of a method for identifying a black and white image according to a second embodiment of the present application. As shown in the figure, step s102 calculates the pixel difference between each pixel point between the three channels, R channel and G channel, G channel and B channel, and R channel and B channel, respectively, including:

[0056] Step s201, respectively obtaining the pixel value of each pixel point in the R channel, the G channel and the B channel, and generating the pixel matrices of the R channel, the G channel and the B channel respectively according to the pixel values;

[0057] Specifically, after the image is channel-separated, the pixel value of each pixel point in each of the three RGB channels can be obtained respectively, and then the pixel values ​​of the three channels can be established in the form of a pixel matrix. The pixel matrix of the three channels should maintain a unified format. For example, if the total number of pixels of the image is 4, then the pixel matrices of the three RGB channels should all be 2×2.

[0058] Step s202, subtract the pixel matrices of the R channel, G channel and B channel in pairs, obtain the pixel matrix differences between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and take the absolute value of the pixel matrix differences.

[0059] Specifically, after obtaining the pixel matrices of the three channels of RGB, the three channels of RGB can be subtracted from each other in pairs. For example, the pixel matrices of the R channel and the G channel are subtracted from each other to obtain the pixel matrix difference between the R channel and the G channel, the pixel matrices of the G channel and the B channel are subtracted from each other to obtain the pixel matrix difference between the G channel and the B channel, and the pixel matrices of the R channel and the B channel are subtracted from each other to obtain the pixel matrix difference between the R channel and the B channel. Since the values ​​in the pixel matrix differences may have negative values, it is also necessary to take the absolute value of the pixel matrix differences to ensure that the values ​​in the pixel matrix differences between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, are all positive values.

[0060] In this embodiment, the pixel matrix difference can be effectively obtained by matrixing the pixels of the three channels and taking the absolute values ​​by subtraction.

[0061] Figure 3 This is a flow chart of a method for identifying a black and white image according to the third embodiment of the present application. As shown in the figure, step s103 determines the color type of the image according to the effective pixel difference between each pixel point of the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, including:

[0062] Step s301, respectively obtaining the number of difference pixels between the three channels, that is, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, according to the effective pixel difference of each pixel point between the three channels, that is, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel;

[0063] Specifically, after the pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel is obtained, the difference pixels that meet the conditions can be selected from the difference pixels, and the difference pixels that meet the conditions are valid difference pixels, and the number of valid difference pixels is counted. The valid difference pixels can be selected according to preset conditions, for example, a pixel difference threshold is preset, and then the obtained pixel difference is compared with the preset pixel difference threshold, and the difference pixels that meet the conditions after comparison are recorded. After all the difference pixels are compared, the number of difference pixels that meet the conditions between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel are counted respectively.

[0064] Step s302, determining the color type of the image according to the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel.

[0065] Specifically, after obtaining the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, the total number of pixels of the image can also be obtained, and then the proportion of the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, to the total number of pixels of the image is calculated respectively, and the color type of the image is determined according to the proportion result.

[0066] In this embodiment, by counting the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, a basis for determining the color classification of the picture can be provided.

[0067] Figure 4 This is a flow chart of a method for identifying a black-and-white image according to the fourth embodiment of the present application. As shown in the figure, the step s301, according to the effective pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel, respectively obtains the number of effective difference pixels between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel, including:

[0068] Step s401, presetting a pixel threshold of a difference pixel;

[0069] Specifically, in a picture, each pixel has a pixel value, which will be converted into another pixel value after three-channel separation; for example, the pixel value of an A pixel in a black and white picture is 125, 125, 125, while the pixel value of the same A pixel in a color picture is 255, 0, 0.

[0070] Specifically, before calculating the number of difference pixels, it is necessary to preset a pixel threshold of the difference pixels. Since the pixel difference of black and white pixels is smaller and the pixel difference of color pixels is larger, the pixel threshold of the difference pixels can be set smaller, such as setting the pixel threshold of the difference pixels to 10.

[0071] Step s402, comparing the pixel difference between each pixel point of the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, with the preset pixel threshold of the difference pixel;

[0072] Specifically, after obtaining the pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel, the pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel can be compared with the preset pixel threshold of the difference pixel.

[0073] Step s403, record the difference pixels that are smaller than the preset pixel threshold of the difference pixels, and count the number of difference pixels that are smaller than the preset pixel threshold of the difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel.

[0074] Specifically, when comparing difference pixels, if the pixel difference between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, is less than the preset pixel threshold of the difference pixel, the pixel point and the pair of channels corresponding to the pixel point are recorded. After the comparison of the difference pixels is completed, that is, after the pixel difference between all the pixel points between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, are compared with the preset pixel threshold of the difference pixel, the number of difference pixels between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, which are less than the preset pixel threshold of the difference pixel, is counted respectively.

[0075] In this embodiment, by presetting a pixel threshold of the difference pixel and comparing the pixel value of the difference pixel of the channel with the pixel threshold, the number of valid difference pixels in the channel can be effectively obtained.

[0076] Figure 5 This is a flowchart of a method for identifying a black-and-white image according to the fifth embodiment of the present application. As shown in the figure, step s302 determines the color type of the image according to the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, including:

[0077] Step s501, obtaining the total number of pixels of the picture, and obtaining the ratio between the number of valid difference pixels between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel and the total number of pixels of the picture according to the total number of pixels of the picture and the number of valid difference pixels between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel;

[0078] Specifically, after obtaining a picture, the total number of pixels of the picture can be calculated, and after obtaining the number of valid difference pixels between the three channels of the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, the ratio between the number of valid difference pixels between the three channels of the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel to the total number of pixels can be calculated respectively, and the ratio between the number of valid difference pixels between the R channel and the G channel and the total number of pixels, the ratio between the number of valid difference pixels between the G channel and the B channel and the total number of pixels, and the ratio between the number of valid difference pixels between the R channel and the B channel and the total number of pixels can be obtained respectively.

[0079] Step s502, determining the color type of the picture according to the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture.

[0080] Specifically, after obtaining the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture, the valid ratio can be counted between the three channels, and then the color type of the picture can be determined based on the valid ratio.

[0081] In this embodiment, the color type of the image can be effectively determined by obtaining the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the image.

[0082] Figure 6 This is a flow chart of a method for identifying a black and white image according to the sixth embodiment of the present application. As shown in the figure, the step s502 determines the color type of the image according to the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the image, including:

[0083] Step s601, preset a difference pixel ratio threshold;

[0084] Specifically, to determine whether the acquired image is a black and white copy, we can determine the ratio of the number of valid difference pixels to the total number of pixels in the image. Since it has been separated into three channels, the ratios of the three channels need to be determined. We can pre-set a difference pixel ratio threshold, such as 0.9. For example, when the ratio of the number of valid difference pixels between the R channel and the G channel to the total number of pixels in the image is greater than 0.9, we can determine that the two channels corresponding to the R channel and the G channel are black and white channels. Similarly, we can then determine the two two channels corresponding to the G channel and the B channel and the R channel and the B channel.

[0085] Step s602, compare the ratios of the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, to the total number of pixels of the image with the preset difference pixel ratio threshold, and determine the color type of the image based on the comparison results.

[0086] Specifically, when the ratios of the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, to the total number of pixels of the image are respectively compared with the preset difference pixel ratio threshold, the channel results of the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, can be judged respectively. For example, the channels corresponding to the R channel and the G channel are black and white channels, and the color type of the image is determined based on the channel results.

[0087] In this embodiment, by presetting a difference pixel ratio threshold and comparing the ratio between the data of the effective difference pixels of each channel and the total number of picture pixels with the difference pixel ratio threshold, the channel results of each channel can be effectively obtained, and the color type of the picture can be determined based on the channel results.

[0088] Figure 7 This is a flow chart of a method for identifying a black-and-white image according to the seventh embodiment of the present application. As shown in the figure, step s602 compares the ratios of the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, to the total number of pixels of the image with the preset difference pixel ratio threshold, and determines the color type of the image according to the comparison result, including:

[0089] Step s701, when the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture is greater than the preset difference pixel ratio threshold, recording the channels corresponding to the difference pixels;

[0090] Specifically, the ratios of the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, to the total number of pixels of the image can be compared with the preset difference pixel ratio threshold, and when the ratio of the number of valid difference pixels of the two channels to the total number of pixels of the image is greater than the preset difference pixel ratio threshold, the two channels are recorded. For example, if the ratio of the number of valid difference pixels between the R channel and the G channel to the total number of pixels of the image is greater than the preset difference pixel ratio threshold, the two channels corresponding to the R channel and the G channel are recorded.

[0091] Step s702, when the ratio between the number of valid difference pixels between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the image is compared with the preset difference pixel ratio threshold, if the number of the recorded pairs of channels is at least 2, the image is determined to be a black and white image.

[0092] Specifically, there are three pairwise channels, namely, R channel and G channel, G channel and B channel, and R channel and B channel. When the ratio of the number of valid difference pixels between the three pairwise channels of R channel and G channel, G channel and B channel, and R channel and B channel to the total number of pixels of the image is compared with the preset difference pixel ratio threshold, if the number of recorded pairwise channels is at least 2, the image can be determined as a black and white image.

[0093] In this embodiment, the color type of the image can be effectively determined by collecting statistics on the channel comparison results of each pair of channels.

[0094] The structure of a black and white picture identification device in the embodiment of the present application is as follows: Figure 8 As shown, including:

[0095] A channel separation module 801, a pixel calculation module 802 and an identification module 803; wherein the channel separation module 801 is connected to the pixel calculation module 802, and the pixel calculation module 802 is connected to the identification module 803; the channel separation module 801 is configured to obtain a picture, and separate the picture into three channels of RGB to obtain three channels of R channel, G channel and B channel; the pixel calculation module 802 is configured to respectively calculate the pixel difference of each pixel point between the three two-by-two channels of R channel and G channel, G channel and B channel, and R channel and B channel, and obtain the effective pixel difference of each pixel point between the three two-by-two channels of R channel and G channel, G channel and B channel, and R channel and B channel according to the pixel difference of each pixel point between the three two-by-two channels of R channel and G channel, G channel and B channel, and R channel and B channel; the identification module 803 is configured to determine the color type of the picture according to the effective pixel difference of each pixel point between the three two-by-two channels of R channel and G channel, G channel and B channel, and R channel and B channel.

[0096] An embodiment of the present application also discloses a computer device, which includes a memory and a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by one or more of the processors, the one or more processors execute the steps of the black-and-white image identification method described in the above embodiments.

[0097] An embodiment of the present application also discloses a storage medium, which can be read and written by a processor, and the memory stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the black and white image identification method described in the above embodiments.

[0098] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0099] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0100] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for identifying black and white images, characterized in that: The following steps are involved: Get an image, and separate the RGB three channels of the image to obtain three channels: R channel, G channel and B channel; Calculate the pixel difference of each pixel between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, respectively; compare the pixel difference of each pixel between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel with a preset pixel difference threshold, select the pixel difference that meets the condition, and obtain the effective pixel difference of each pixel between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel; According to the effective pixel difference of each pixel point between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel, respectively obtain the number of effective difference pixels between the three channels of R channel and G channel, G channel and B channel, and R channel and B channel; The color type of the picture is determined according to the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel.

2. The method for identifying black and white pictures according to claim 1, characterized in that: The pixel difference between each pixel point between the three channels, R channel and G channel, G channel and B channel, and R channel and B channel, is calculated respectively, including: Obtain the pixel value of each pixel point in the R channel, the G channel and the B channel respectively, and generate the pixel matrices of the R channel, the G channel and the B channel respectively according to the pixel values; The pixel matrices of the R channel, the G channel, and the B channel are subtracted in pairs to obtain pixel matrix differences between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the absolute value of the pixel matrix difference is taken.

3. The method for identifying black and white pictures according to claim 1, characterized in that: The method of obtaining the number of effective difference pixels between the three channels, that is, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, respectively, according to the effective pixel difference of each pixel point between the three channels, that is, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, comprises: A preset pixel threshold of difference pixels; Compare the pixel difference of each pixel point between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, with the preset pixel threshold of the difference pixel; The difference pixels that are smaller than the preset pixel threshold of the difference pixels are recorded, and the number of difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, that are smaller than the preset pixel threshold of the difference pixels are counted respectively.

4. The method for identifying black and white pictures according to claim 1, characterized in that: Determining the color type of the picture according to the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, comprises: Obtaining the total number of pixels of the picture, and obtaining the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture according to the total number of pixels of the picture and the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture; The color type of the picture is determined according to the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture.

5. The method for identifying black and white pictures according to claim 4, characterized in that: Determining the color type of the picture according to the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture includes: A preset difference pixel ratio threshold; The ratios of the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, to the total number of pixels of the image are compared with the preset difference pixel ratio threshold, and the color type of the image is determined according to the comparison results.

6. The method for identifying black and white pictures according to claim 5, characterized in that: The comparing the ratios of the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, to the total number of pixels of the picture with the preset difference pixel ratio threshold, and determining the color type of the picture according to the comparison results, includes: When the ratio between the number of valid difference pixels between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the picture is greater than the preset difference pixel ratio threshold, the pairs of channels corresponding to the difference pixels are recorded; When the ratio between the number of valid difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and the total number of pixels of the image is compared with the preset difference pixel ratio threshold, if the number of recorded channels is at least 2, the image is determined to be a black and white image.

7. A black and white picture identification device, characterized in that: The device comprises: Channel separation module: configured to obtain an image and separate the image into three channels of RGB to obtain three channels of R channel, G channel and B channel; A pixel calculation module: configured to respectively calculate the pixel difference of each pixel point between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, and compare the pixel difference of each pixel point between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel with a preset pixel difference threshold, select the pixel difference that meets the conditions, and obtain the effective pixel difference of each pixel point between the three pairs of channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel; An identification module is configured to obtain the number of effective difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel, according to the effective pixel difference of each pixel point between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel; and determine the color type of the image according to the number of effective difference pixels between the three channels, namely, the R channel and the G channel, the G channel and the B channel, and the R channel and the B channel.

8. A computer device, characterized in that: The computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by one or more of the processors, the one or more processors execute the steps of the black-and-white image identification method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that: The storage medium can be read and written by a processor, and the storage medium stores computer instructions. When the computer instructions are executed by one or more processors, the one or more processors execute the steps of the black-and-white image identification method as described in any one of claims 1 to 6.