Disclosure of Invention
Aiming at the defects existing in the prior art, the invention aims to provide a method, a storage medium and a device for determining a multi-color overlapping intersection region of a printed matter, which adopt a non-contact detection mode, obtain an accurate detection result without damaging the surface characteristics of a detected printed matter, have high detection accuracy and stronger robustness, and are not influenced by the depth of ink.
In order to achieve the above purpose, the method for determining the multi-color overlapping intersection area of the printed matter provided by the invention specifically comprises the following steps:
acquiring an RGB image to be detected containing a multicolor superposition intersection area, converting the RGB image to be detected into an HSI image, and calculating to obtain a saturation characteristic image;
calculating a mask image with saturation characteristics based on the saturation characteristic image to obtain a foreground image of the RGB image to be detected;
Performing projection processing on the foreground image, converting the RGB image after projection into a Lab image, namely obtaining a projection characteristic Lab image, and fitting the distance between an endpoint and a non-endpoint in the projection characteristic Lab image to obtain a projection characteristic curve;
and obtaining the initial position and the boundary point of the multi-color superposition intersection area in the RGB image to be detected based on the projection characteristic curve obtained by calculation.
On the basis of the technical scheme, the RGB image to be detected is obtained by shooting the printed matter to be detected based on the CCD color camera, and the RGB image to be detected obtained by shooting is the RGB image.
On the basis of the technical scheme, the RGB image to be detected is converted into the HSI image, and the saturation characteristic image is obtained through calculation, wherein the calculation mode of the saturation characteristic image is as follows:
S(i.j)=M(i.j)-N(i.j)
M(i.j)=max(R(i.j),G(i.j),B(i.j))
N(i.j)=min(R(i.j),G(i.j),B(i.j))
wherein S (i.j) represents the saturation feature at the image coordinate (i.j), R (i.j) represents the gray value of the image at the R channel coordinate (i.j), G (i.j) represents the gray value of the image at the G channel coordinate (i.j), B (i.j) represents the gray value of the image at the B channel coordinate (i.j), R, G, B is three color channels of the RGB image to be detected, the size of the RGB image to be detected is m×n, M represents rows, and N represents columns.
Based on the technical scheme, the mask image with the saturation characteristic is obtained by calculating the saturation characteristic image, specifically:
carrying out Canny operation on the saturation characteristic image to obtain a saturation characteristic binary image;
and filling the seed points of the binary image of the saturation characteristic to obtain a mask image of the saturation characteristic.
On the basis of the technical scheme, the method for acquiring the foreground image of the RGB image to be detected comprises the following specific steps:
Performing an AND operation on the RGB image to be detected and the mask image with the saturation characteristic, wherein the obtained image is a foreground image, and performing an exclusive OR operation on the RGB image to be detected and the mask image with the saturation characteristic, wherein the obtained image is a background image, and the calculation mode is as follows:
FT=TRGB&Smask
BT=TRGB∧Smask
Wherein F T represents a foreground image, B T represents a background image, T RGB represents an RGB image to be detected, S mask represents a mask image of a saturation feature, & represents an and operation, & represents an exclusive or operation.
On the basis of the technical scheme, the projection processing is performed on the foreground image, the RGB image after projection is converted into the Lab image, namely, the projection characteristic Lab image is obtained, and the specific steps comprise:
performing vertical projection processing on the foreground image, converting the RGB image after projection into a Lab image to obtain a projection characteristic Lab image, wherein the vertical projection processing is to project a two-dimensional image in a horizontal direction according to a column, then calculate the mean value of each color channel as a projection value of the current column, and then convert the RGB image obtained after projection into the Lab image to obtain the projection characteristic Lab image;
And carrying out statistical average filtering treatment on the projection characteristic Lab image.
On the basis of the technical scheme, the fitting projection characteristic Lab image comprises the specific steps of:
converting the projection feature Lab image from the RGB color space to the CIE-Lab color space;
Calculating to obtain two endpoints of the projection characteristic Lab image, and calculating the distance between the non-endpoints in the projection characteristic Lab image;
Fitting the calculated distance so as to draw a projection characteristic curve, wherein the distance calculation mode is as follows:
Dl(i)=(a(i)-a(l))2+(b(i)-b(l))2
Dr(i)=(a(i)-a(r))2+(b(i)-b(r))2
Wherein l represents the left end point of the projection feature Lab image, r represents the right end point of the projection feature Lab image, i represents the i-th pixel point of the projection feature Lab image, D l (i) represents the distance between the i-th pixel point of the projection feature Lab image and the left end point of the projection feature Lab image, D r (i) represents the distance between the i-th pixel point of the projection feature Lab image and the right end point of the projection feature Lab image, a (i) represents the a-color component value of the i-th pixel point of the projection feature Lab image, a (l) represents the a-color component value of the left end point of the projection feature Lab image, a (r) represents the a-color component value of the i-th pixel point of the projection feature Lab image, b (i) represents the b-color component value of the left end point of the projection feature Lab image, a represents the redness of the color, a represents the range from-128 to +127, a (r) represents the b-color component value of the i-th pixel point of the projection feature Lab image, b (l) represents the b-color component value of the projection feature Lab image, b (l) represents the red-color component value of the red-color of the color-128-127, and a +127 represents the range from-128 to +127.
Based on the above technical solution, the obtaining, based on the projection characteristic curve obtained by calculation, a starting position and a boundary point of a multi-color overlapping intersection region in an RGB image to be detected specifically includes:
Based on the projection characteristic curve, the intersection point in the projection characteristic curve is the intersection point of the multi-color overlapping intersection region, and the starting position of the multi-color overlapping intersection region is determined according to the 3 sigma principle.
The present invention provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of determining a multi-color overlay intersection region of a printed matter described above.
The invention provides a device for determining a multi-color superposition intersection area of a printed matter, which comprises the following components:
The acquisition module is used for acquiring an RGB image to be detected containing a multicolor superposition intersection area, converting the RGB image to be detected into an HSI image and calculating to obtain a saturation characteristic image;
The computing module is used for computing a mask image with saturation characteristics based on the saturation characteristic image so as to obtain a foreground image of the RGB image to be detected;
The processing module is used for carrying out projection processing on the foreground image, converting the RGB image after projection into a Lab image, namely obtaining a projection characteristic Lab image, and fitting the distance between the end point and the non-end point in the projection characteristic Lab image to obtain a projection characteristic curve;
And the execution module is used for obtaining the starting position and the boundary point of the multi-color superposition intersection area in the RGB image to be detected based on the projection characteristic curve obtained by calculation.
Compared with the prior art, the method has the advantages that the method comprises the steps of converting a color image from an RGB color space to an HSI color space, calculating a saturation characteristic image, performing projection analysis on the saturation image, calculating a mask image with saturation characteristics based on the saturation characteristic image, obtaining a foreground image of the RGB image to be detected, performing projection processing on the foreground image, converting the projected RGB image into a Lab image, namely obtaining a projection characteristic Lab image, fitting the distance between an endpoint and a non-endpoint in the projection characteristic Lab image to obtain a projection characteristic curve, finally obtaining information of a multi-color superposition intersection area in the RGB image to be detected based on the projection characteristic curve, obtaining an accurate detection result without damaging the surface characteristics of a printed body to be detected by adopting a non-contact detection mode, and being high in detection accuracy, strong in robustness and free from the influence of ink color.
Detailed Description
The embodiment of the invention provides a method for determining a multi-color overlapping and intersecting area of a printed matter, which comprises the steps of converting a color image from an RGB color space to an HSI color space, calculating a saturation characteristic image, then carrying out projection analysis on the saturation image, then calculating a mask image with saturation characteristics based on the saturation characteristic image, obtaining a foreground image of an RGB image to be detected, carrying out projection processing on the foreground image, converting the projected RGB image into a Lab image, namely obtaining a projection characteristic Lab image, fitting the distance between an endpoint and a non-endpoint in the projection characteristic Lab image to obtain a projection characteristic curve, finally obtaining information of the multi-color overlapping and intersecting area in the RGB image to be detected based on the projection characteristic curve, and adopting a non-contact detection mode to obtain an accurate detection result without damaging the surface characteristics of the printed matter to be detected. The embodiment of the invention correspondingly provides a non-transitory computer readable storage medium and a device for determining the multi-color superposition intersection area of the printed matter.
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application.
Referring to fig. 1, the method for determining a multi-color overlapping intersection area of a printed matter provided by the embodiment of the invention specifically includes the following steps:
S1, acquiring an RGB image to be detected containing a multi-color superposition intersection area, converting the RGB image to be detected into an HSI image, and calculating to obtain a saturation characteristic image;
in the invention, the RGB image to be detected is obtained by shooting a printed matter to be detected based on a CCD (Charge Coupled Device ) color camera, and the RGB image to be detected obtained by shooting is an RGB image. The CCD color camera collects RGB data of the printed matter image, and the RGB color space belongs to the color space related to the equipment. In order to accurately describe colors, a color gamut space transformation of the CCD color camera is required, i.e. a device dependent color space of the CCD color camera is converted into a device independent color space.
For the RGB color space, RGB (red, green, blue) is a space defined according to colors recognized by human eyes, and can represent most colors. The RGB color space represents colors with a linear combination of three color components, to which any color is related, and which are highly correlated.
In the invention, an RGB image to be detected is converted into an HSI image, and a saturation characteristic image is obtained by calculation, wherein the calculation mode of the saturation characteristic image is as follows:
S(i.j)=M(i.j)-N(i.j)
M(i.j)=max(R(i.j),G(i.j),B(i.j))
N(i.j)=min(R(i.j),G(i.j),B(i.j))
wherein S (i.j) represents the saturation feature at the image coordinate (i.j), R (i.j) represents the gray value of the image at the R channel coordinate (i.j), G (i.j) represents the gray value of the image at the G channel coordinate (i.j), B (i.j) represents the gray value of the image at the B channel coordinate (i.j), R, G, B is three color channels of the RGB image to be detected, the size of the RGB image to be detected is m×n, M represents rows, and N represents columns.
For HSI, the HSI color space is proposed for better digitizing the colors. H represents hue, S represents saturation, and I represents intensity.
S2, calculating a mask image with saturation characteristics based on the saturation characteristic image to obtain a foreground image of the RGB image to be detected;
in the invention, a mask image with saturation characteristics is obtained based on saturation characteristic image calculation, specifically:
s201, carrying out Canny (an edge detection algorithm) operation on a saturation characteristic image to obtain a saturation characteristic binary image;
The Canny operation comprises the steps of Gaussian blur, gradient size and direction calculation, non-maximized suppression, double-threshold acquisition and weak edge connection. For non-maximized suppression, there should be only one response per edge, and for dual threshold acquisition, there is a separation of strong and weak edges.
S202, filling the seed points of the binary image of the saturation feature to obtain a mask image of the saturation feature.
The seed filling algorithm is generally implemented by using a stack data structure, namely, firstly stacking seed pixels, wherein the seed pixels are stack bottom pixels, if the stack is not empty, performing three steps of firstly popping the stack top pixels, secondly drawing the popped pixels according to filling colors, thirdly searching four (eight) pixels adjacent to the popped pixels according to left, right, lower, upper left, upper right, lower right and lower left in sequence, and if the color of the pixel is not boundary color and is not set into filling color, stacking the pixel, otherwise discarding the pixel.
The invention discloses a method for acquiring a foreground image of an RGB image to be detected, which comprises the specific steps of performing AND operation on the RGB image to be detected and a mask image with saturation characteristics, wherein the acquired image is the foreground image, performing exclusive OR operation on the RGB image to be detected and the mask image with saturation characteristics, and the acquired image is a background image, wherein the calculation mode is as follows:
FT=TRGB&Smask
BT=TRGB∧Smask
Wherein F T represents a foreground image, B T represents a background image, T RGB represents an RGB image to be detected, S mask represents a mask image of a saturation feature, & represents an and operation, & represents an exclusive or operation.
The method comprises the steps of performing AND operation on the RGB image to be detected and the mask image with the saturation characteristic to obtain a foreground image, wherein the coordinates of the RGB image to be detected are assumed to be (100 ), the pixel value is 192, the coordinates of the mask image with the saturation characteristic are assumed to be (100 ), the pixel value is 1, the coordinates of the image obtained by performing AND operation on the RGB image to be detected and the mask image with the saturation characteristic are assumed to be (100 ), the pixel value is 192, the coordinates of the RGB image to be detected are assumed to be (101 ), the pixel value is 85, the coordinates of the mask image with the saturation characteristic are assumed to be (101 ), the pixel value is 0, the coordinates of the image obtained by performing AND operation on the RGB image and the mask image with the saturation characteristic are assumed to be (101 ), and the pixel value is 0.
S3, performing projection processing on the foreground image, converting the RGB image after projection into a Lab image, namely obtaining a projection characteristic Lab image, and fitting the distance between an endpoint and a non-endpoint in the projection characteristic Lab image to obtain a projection characteristic curve;
in the invention, the foreground image is projected, the projected RGB image is converted into Lab image, namely, the projected characteristic Lab image is obtained, the specific steps include:
S301, performing vertical projection processing on a foreground image, converting a RGB image after projection into a Lab image to obtain a projection characteristic Lab image, wherein the vertical projection processing is to project a two-dimensional image in a horizontal direction according to a column, then calculate the mean value of each color channel as a projection value of a current column, and then convert the RGB image obtained after projection into the Lab image to obtain the projection characteristic Lab image;
S302, carrying out statistical mean filtering processing on the projection characteristic Lab image.
For step S301, the following is specifically described:
(1) Performing vertical projection processing on the foreground image, wherein for the vertical projection effect, the image is assumed to be M rows and N columns, and after the vertical projection is performed, the image is changed into 1 row and N columns;
(2) Calculating the average value of each color channel, wherein for the vertical projection calculation rule, specifically, the average value is calculated after accumulating the pixel values in the Y-axis (vertical) direction, for example, the color image has three pixels in the Y-axis direction, the pixel values of R channels are respectively 111, 120 and 129, the pixel value of R channels after projection is 120= (111+120+129)/3;G channels are respectively 135, 145 and 155, the pixel value of G channels after projection is 145= (135+145+155)/3;B channels are respectively 211, 220 and 199, and the pixel value of R channels after projection is 210= (211+220+199)/3;
(3) For calculating the mean value of each color channel, as the projection value of the current column, the foreground image is a color image, and the foreground image is still the color image after the processing is finished;
(4) The color image generally refers to an image formed by a plurality of color channels, and the number of the color channels is more than 1;
(5) For calculating the mean value of each color channel as the projection value of the current column, and then obtaining a projection characteristic Lab image through color space conversion, wherein the images processed in the invention are all digital images, and the digital images are images expressed in a two-dimensional digital group mode.
The projection characteristic Lab image is discontinuous in color, so that the color can jump in a large range to affect the segmentation effect, and therefore, the projection characteristic Lab image is required to be subjected to statistical mean filtering processing, and a smoother image is obtained. The statistical mean value filtering is equivalent to median value filtering and mean value filtering, and the specific implementation steps are that 8 pixels (or 24 pixels or 48 pixels) around the pixel point are used for removing the maximum value pixel point and the minimum value pixel point, the rest pixel points are subjected to average operation, and the average pixel value is used for replacing the pixel value of the point.
In the invention, a projection characteristic curve is obtained by fitting the distance between an endpoint and a non-endpoint in a projection characteristic Lab image, and the specific steps comprise:
S311, converting the projection characteristic Lab image from an RGB color space to a CIE-Lab color space;
For the CIE-Lab space, the CIE-Lab color model is a color model formulated by the CIE (International Commission on illumination).
S312, calculating two endpoints of the projection characteristic Lab image, and calculating the distance between the non-endpoints in the projection characteristic Lab image;
S313, fitting the calculated distance so as to draw a projection characteristic curve, wherein the distance calculation mode is as follows:
Dl(i)=(a(i)-a(l))2+(b(i)-b(l))2
Dr(i)=(a(i)-a(r))2+(b(i)-b(r))2
Wherein l represents the left end point of the projection feature Lab image, r represents the right end point of the projection feature Lab image, i represents the i-th pixel point of the projection feature Lab image, D l (i) represents the distance between the i-th pixel point of the projection feature Lab image and the left end point of the projection feature Lab image, D r (i) represents the distance between the i-th pixel point of the projection feature Lab image and the right end point of the projection feature Lab image, a (i) represents the a-color component value of the i-th pixel point of the projection feature Lab image, a (l) represents the a-color component value of the left end point of the projection feature Lab image, a (r) represents the a-color component value of the i-th pixel point of the projection feature Lab image, b (i) represents the b-color component value of the left end point of the projection feature Lab image, a represents the redness of the color, a represents the range from-128 to +127, a (r) represents the b-color component value of the i-th pixel point of the projection feature Lab image, b (l) represents the b-color component value of the projection feature Lab image, b (l) represents the red-color component value of the red-color of the color-128-127, and a +127 represents the range from-128 to +127.
After the projection characteristic Lab image is converted from RGB space to CIE-Lab space, each pixel point has a group of Lab values, when the projection characteristic Lab image is subjected to endpoint calculation, the left endpoint of the projection characteristic Lab image is firstly assumed to be the starting point, the right endpoint is the ending point, the distance between the endpoint and the non-endpoint is calculated, then the left endpoint of the projection characteristic Lab image is assumed to be the ending point, the right endpoint is the starting point, and the distance between the endpoint and the non-endpoint is calculated.
In the invention, the distance between the non-end point and the punctuation of the projection characteristic Lab image is calculated, and specifically, the distance between the non-end point and the end point in the projection characteristic Lab image is calculated.
In the invention, the least square method can be adopted to fit the calculated distance data, so that a corresponding curve, namely a projection characteristic curve, can be drawn.
And S4, obtaining the initial position and the boundary point of the multi-color superposition intersection area in the RGB image to be detected based on the projection characteristic curve obtained through calculation.
In the invention, based on the projection characteristic curve obtained by calculation, the initial position and the boundary point of the multi-color superposition intersection area in the RGB image to be detected are obtained, specifically:
Based on the projection characteristic curve, the intersection point in the projection characteristic curve is the intersection point of the multi-color overlapping intersection region, and the starting position of the multi-color overlapping intersection region is determined according to the 3 sigma principle.
The method specifically comprises the steps of 1, calculating the space distance between a starting point and other points by taking the left end point of a projection characteristic Lab image as a starting point, fitting the calculated space distance to obtain a curve, calculating the space distance between the starting point and other points by taking the right end point of the projection characteristic Lab image as the starting point, fitting the calculated space distance to obtain a curve, 2, wherein the interaction point of the two curves is the most important point of interaction of two colors, namely a boundary point, 3, when one color is mixed with the other color, the color component value of the color component is changed greatly (the method is reflected on the space distance), when the aliasing is finished, the color component value of the color component is changed into a stable value, the change is similar to normal distribution, the color component value of an aliasing area is changed suddenly, and the color value of a non-aliasing area is changed little.
In the projection characteristic curve example shown in fig. 2, the point a is the boundary point of the multi-color overlapping intersection region, and B, C is the multi-color overlapping intersection starting points of the two colors, respectively.
The multi-color overlapping intersection region refers to a region with only 2 kinds of color aliasing, so that 2 curves exist in the projection characteristic curve shown in fig. 2. In fig. 2, 2 curves each represent transition from one color to another, the intersection is the most severe point of color transition, and B, C points each represent a start intersection. The abscissa in fig. 2 represents the number of columns of the image, and the ordinate represents the spatial distance.
The invention converts RGB colors into HSI, separates foreground and background images by calculating saturation, projects the foreground images, converts the foreground images into LAB space, determines interaction points of multi-color overlapping intersection areas by calculating space distance, and determines starting points and end points of the multi-color overlapping intersection areas by 3 sigma principle. The method comprises the steps of adopting an AOI (Automated Optical Inspection, automatic optical detection) non-contact detection method, obtaining an accurate detection result while not damaging the surface characteristics of an object to be detected, converting RGB colors into HSI, distinguishing a foreground and a background by calculating saturation, and then converting a foreground image into LAB space to calculate the space distance between the two colors, so that the detection accuracy is high, the robustness is stronger, and the influence of ink color depth is avoided.
According to the method for determining the multi-color overlapping and intersecting region of the printed matter, the color image is transferred from the RGB color space to the HSI color space, the saturation characteristic image is calculated, then the saturation image is subjected to projection analysis, then the saturation characteristic mask image is obtained based on the saturation characteristic image, the foreground image of the RGB image to be detected is obtained, projection processing is carried out on the foreground image, the RGB image obtained after projection is converted into the Lab image, namely the projection characteristic Lab image is obtained, the distance between the end point and the non-end point in the projection characteristic Lab image is fitted to obtain the projection characteristic curve, finally the information of the multi-color overlapping and intersecting region in the RGB image to be detected can be obtained based on the projection characteristic curve, the accurate detection result is obtained without damaging the surface characteristics of the printed matter to be detected in a non-contact detection mode, the detection accuracy is high, the robustness is high, and the influence of ink color depth is avoided.
In a possible implementation manner, the embodiment of the invention further provides a non-transitory computer readable storage medium, wherein the readable storage medium is located in a PLC (Programmable Logic Controller ) controller, and a computer program is stored on the readable storage medium, and when the program is executed by a processor, the steps of the method for determining a multi-color superposition intersection area of a printed matter are implemented:
acquiring an RGB image to be detected containing a multicolor superposition intersection area, converting the RGB image to be detected into an HSI image, and calculating to obtain a saturation characteristic image;
calculating a mask image with saturation characteristics based on the saturation characteristic image to obtain a foreground image of the RGB image to be detected;
Performing projection processing on the foreground image, converting the RGB image obtained after projection into a Lab image, namely obtaining a projection characteristic Lab image, and fitting the distance between an endpoint and a non-endpoint in the projection characteristic Lab image to obtain a projection characteristic curve;
and obtaining the initial position and the boundary point of the multi-color superposition intersection area in the RGB image to be detected based on the projection characteristic curve obtained by calculation.
The storage media may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present invention may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The device for determining the multi-color overlapping intersection area of the printed matter provided by the embodiment of the invention comprises an acquisition module, a calculation module, a processing module and an execution module.
The system comprises an acquisition module, a calculation module, a processing module and an execution module, wherein the acquisition module is used for acquiring an RGB image to be detected containing a multicolor superposition intersection area, converting the RGB image to be detected into an HSI image and calculating to obtain a saturation characteristic image, the calculation module is used for calculating to obtain a mask image with saturation characteristics based on the saturation characteristic image so as to acquire a foreground image of the RGB image to be detected, the processing module is used for carrying out projection processing on the foreground image, converting the RGB image obtained after projection into a Lab image, namely acquiring a projection characteristic Lab image, fitting the distance between an endpoint and a non-endpoint in the projection characteristic Lab image to obtain a projection characteristic curve, and the execution module is used for obtaining the initial position and a boundary point of the multicolor superposition intersection area in the RGB image to be detected based on the calculated projection characteristic curve.
In the invention, RGB images to be detected are obtained by shooting printed matters to be detected based on a CCD color camera, and the shot RGB images to be detected are RGB images.
In the invention, an RGB image to be detected is converted into an HSI image, and a saturation characteristic image is obtained by calculation, wherein the calculation mode of the saturation characteristic image is as follows:
S(i.j)=M(i.j)-N(i.j)
M(i.j)=max(R(i.j),G(i.j),B(i.j))
N(i.j)=min(R(i.j),G(i.j),B(i.j))
wherein S (i.j) represents the saturation feature at the image coordinate (i.j), R (i.j) represents the gray value of the image at the R channel coordinate (i.j), G (i.j) represents the gray value of the image at the G channel coordinate (i.j), B (i.j) represents the gray value of the image at the B channel coordinate (i.j), R, G, B is three color channels of the RGB image to be detected, the size of the RGB image to be detected is m×n, M represents rows, and N represents columns.
In the invention, a mask image with saturation characteristics is obtained based on saturation characteristic image calculation, specifically:
carrying out Canny operation on the saturation characteristic image to obtain a saturation characteristic binary image;
and filling the seed points of the binary image of the saturation characteristic to obtain a mask image of the saturation characteristic.
In the invention, the foreground image of the RGB image to be detected is obtained, and the specific steps include:
Performing an AND operation on the RGB image to be detected and the mask image with the saturation characteristic, wherein the obtained image is a foreground image, and performing an exclusive OR operation on the RGB image to be detected and the mask image with the saturation characteristic, wherein the obtained image is a background image, and the calculation mode is as follows:
FT=TRGB&Smask
BT=TRGB∧Smask
Wherein F T represents a foreground image, B T represents a background image, T RGB represents an RGB image to be detected, S mask represents a mask image of a saturation feature, & represents an and operation, & represents an exclusive or operation.
In the invention, the foreground image is projected, the RGB image obtained after projection is converted into Lab image, namely, the projection characteristic Lab image is obtained, the specific steps include:
Performing vertical projection processing on the foreground image, converting the RGB image obtained after projection into a Lab image to obtain a projection characteristic Lab image, wherein the vertical projection processing is to project a two-dimensional image in a horizontal direction according to a column, then calculate the mean value of each color channel as a projection value of the current column, and then convert the RGB image obtained after projection into the Lab image to obtain the projection characteristic Lab image;
And carrying out statistical average filtering treatment on the projection characteristic Lab image.
In the invention, a projection characteristic curve is obtained by fitting the distance between an endpoint and a non-endpoint in a projection characteristic Lab image, and the specific steps comprise:
converting the projection feature Lab image from the RGB color space to the CIE-Lab color space;
Calculating to obtain two endpoints of the projection characteristic Lab image, and calculating the distance between the non-endpoints in the projection characteristic Lab image;
Fitting the calculated distance so as to draw a projection characteristic curve, wherein the distance calculation mode is as follows:
Dl(i)=(a(i)-a(l))2+(b(i)-b(l))2
Dr(i)=(a(i)-a(r))2+(b(i)-b(r))2
Wherein l represents the left end point of the projection feature Lab image, r represents the right end point of the projection feature Lab image, i represents the i-th pixel point of the projection feature Lab image, D l (i) represents the distance between the i-th pixel point of the projection feature Lab image and the left end point of the projection feature Lab image, D r (i) represents the distance between the i-th pixel point of the projection feature Lab image and the right end point of the projection feature Lab image, a (i) represents the a-color component value of the i-th pixel point of the projection feature Lab image, a (l) represents the a-color component value of the left end point of the projection feature Lab image, a (r) represents the a-color component value of the i-th pixel point of the projection feature Lab image, b (i) represents the b-color component value of the left end point of the projection feature Lab image, a represents the redness of the color, a represents the range from-128 to +127, a (r) represents the b-color component value of the i-th pixel point of the projection feature Lab image, b (l) represents the b-color component value of the projection feature Lab image, b (l) represents the red-color component value of the red-color of the color-128-127, and a +127 represents the range from-128 to +127.
In the invention, based on the projection characteristic curve obtained by calculation, the initial position and the boundary point of the multi-color superposition intersection area in the RGB image to be detected are obtained, specifically:
Based on the projection characteristic curve, the intersection point in the projection characteristic curve is the intersection point of the multi-color overlapping intersection region, and the starting position of the multi-color overlapping intersection region is determined according to the 3 sigma principle.
The foregoing is only a specific embodiment of the application to enable those skilled in the art to understand or practice the application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.