Embodiment
Embodiment of the present invention is described with reference to the accompanying drawings.Should be noted that for purpose clearly, omitted the parts that have nothing to do with the present invention, those of ordinary skills are known and the expression and the description of processing in accompanying drawing and the explanation.
Fig. 1 shows the block diagram according to the designated color layer extracting device 100 of embodiment of the present invention.
As shown in Figure 1, designated color layer equipment 100 comprises that background colour estimator 101, interference colour estimator 102, aim colour estimator 103, axis of projection are provided with benchmark acquisition unit 104, axis of projection is provided with device 105, aim colour extraction apparatus 106.
Be example with the color document images below, the processing of 100 pairs of coloured images of designated color layer equipment of embodiment of the present invention is described.
In the present embodiment; Suppose that the coloured image of input represented by three color component RGB; The background area total area of coloured image is much larger than the foreground area total area, and image is except that containing the color that background color and user specify extraction, and image contains some other known colors.In the gray level image of equipment output, the gray level representative belongs to the confidence level or the probability of intended target look, and gray level is high more, represents confidence level high more.
Fig. 2 shows the process flow diagram of the estimated background color center of background colour estimator 101 according to the preferred embodiment of the present invention.The method of estimated background color center is a lot, for example can adopt average drifting method that color component histogram method, clustering methodology, back also can mention etc.Among Fig. 2 illustration color component histogram method simply fast.Because the area of background area is much larger than the foreground area total area, therefore in the statistic histogram of pixel color component (for example R, G and B three-component), the peak-peak in the corresponding histogram in background color center.Thereby, as shown in Figure 2, at first, added up the histogram of the R component of image pixel, and histogram curve has been done average or gaussian filtering in step 201.Peak-peak in the step 202 search histogram, and write down its pairing R component value R
0Similarly, step 203 with 204 and step 205 and 206 can find G component value G respectively
0With B component value B
0At last, in step 207 color P
0=(R
0, G
0, B
0) color center output as a setting.
Should note; Though in Fig. 2; Histogram, the step of step (step 205 and 206) of searching for the position of peak-peak of step (step 203 and 204) and calculating B component of step (step 201 and 202) and the position of the histogram that calculates the G component, search peak-peak of position of calculating histogram, the search peak-peak of R component walks abreast and carries out, but also can be in sequence.
When the estimated background look, also can adopt clustering methodology.For example; Can adopt mean cluster (K-Means Cluster) or hierarchical cluster (Hierarchical Cluster); Automatically be divided into several classifications to the point of image in color space, and the maximum corresponding background colour of classification of number, the corresponding background colour of its average center.
On the other hand, having imported background colour or not being under the very high situation to the extraction accuracy requirement of designated color layer, also can omit background colour estimator 101.
The operation of the aim colour estimator 103 and the interference colour estimator 102 of embodiment of the present invention is described below in conjunction with Fig. 3.Because aim colour estimator 103 and interference colour estimator 102 can adopt identical method realization, thereby followingly only detailed explanation is carried out in the operation of aim colour estimator 103.In addition, as previously mentioned, background colour estimator 101 also can adopt identical operations.
Fig. 3 shows the process flow diagram of the estimating target color center of aim colour estimator 103 according to the preferred embodiment of the present invention.The method of estimating target color center is also a lot, for example clustering methodology, average drifting (Mean Shift) method etc., among Fig. 3 illustration average drifting (Mean Shift) method.The average drifting method can in color space (for example RGB three dimensions), make the initial target look of appointment converge on the cluster centre of aim colour through the mode of iteration.
Though carrying out designated color layer when extracting, the user generally can the intended target color or is disturbed color, generally speaking; This moment is to the appointment of color of object or interference color; All be qualitatively, for example " black, red, yellow, green, blue or green, blue, purple " is actually a kind of color gamut in other words; Thereby need the color of specified color layers further be quantized, determine interference colour with the center of the aim colour that will extract.
When the estimating target look, also can adopt clustering methodology.For example; Can adopt mean cluster (K-Means Cluster) or hierarchical cluster (Hierarchical Cluster); Automatically be divided into several classifications to the point of image in color space, and from the corresponding color of object of the nearest classification of initial designated color, its classification average can be the center of aim colour.
Having imported the specific aim color value or not being under the very high situation to the extraction accuracy requirement of designated color layer, also can omit aim colour estimator 103 and interference colour estimator 102.
Below in conjunction with Fig. 3 detailed description is carried out in the processing of aim colour estimator 103.
Step 301 is with the color of object initialization aim colour center of user's appointment, P
1(0)=(R
1(0), G
1(0), B
1(0)), wherein 0 represents iterations t=0.
Step 302 is obtained target chromosphere collection, promptly when the t time iteration, with the currency P at aim colour center
1(t)=(R
1(t), G
1(t), B
1(t)) be the centre of sphere, make a spheroid at the RGB color space with certain radius d.
In a kind of scheme, can use fixing radius d to obtain this target chromosphere collection.In another program, can the radius d that adopted be associated with iterating the number of times that has carried out, promptly at the iteration initial stage, the centre of sphere is positioned at the more sparse zone of pixel, and radius d establishes greatlyyer; In the iteration later stage, the centre of sphere is positioned at the zone of pixel comparatively dense, and radius d establishes lessly.
In addition, can set the interval [d of a d value
Min, d
Max], equal interval quantizing goes out one group of d value, when the t time iteration, adds up the d value distribution plan of all pixels, searches the feasible interval [d that falls into of a suitable d (t)
Min, d (t)] in number of pixels reach predetermined number.The pixel set of collecting may be defined as
I(t)={i|‖(r
i,g
i,b
i)-(R
1(t),R
1(t),R
1(t))‖≤d(t)}
Wherein, t representes iteration the t time, and I representes to fall into the set of pixel index, the ‖ of target chromosphere ... ‖ representes 2 Euclidean distance.
Step 303 is calculated ball and is comprised the color of pixel average, and upgrade the aim colour center with it, promptly
Wherein the element number among the I (t) is gathered in n (t) expression.
Step 304 is upgraded iteration variable t.
Step 305 judges whether the iteration result reaches end condition.Although the termination condition shown in the figure is that the drift value at color of object center is enough little, i.e. ‖ P
1(t+1)-P
1(t) ‖<ε (ε is little positive number), but also can utilize maximum iteration time T to limit, promptly t>T perhaps adopts the combination of above two conditions to confirm whether iteration can finish.If fail to satisfy end condition, then change step 302, get into the iterative process of next round.
Step 306, with the result of last iteration as the color of object center P
1=(R
1, G
1, B
1).
The axis of projection of describing first embodiment of the invention below in conjunction with Fig. 4 and Fig. 5 is provided with benchmark and obtains the processing that unit 104, axis of projection are provided with device 105 and aim colour extraction apparatus 106.In first embodiment of the invention; To comprising the file and picture of interference colour; The color center that axis of projection is provided with each color in the set that benchmark obtains unit 104 to be formed by said background colour and said interference colour is connected with straight line; Make every kind of color center at least through straight line, said straight line is provided with datum line as said axis of projection.By axis of projection the unit 105 said axis of projection of mind-set from color of object is set and benchmark is set carries out projection, said projection line is set to axis of projection; At last by aim colour extraction apparatus 106 through with each pixel of said coloured image to said axis of projection projection, and extract aim colour color layers gray level image.
The axis of projection that Fig. 4 shows first embodiment of the invention is provided with benchmark and obtains first embodiment that unit 104, axis of projection are provided with the processing of device 105 and aim colour extraction apparatus 106.In first embodiment of first embodiment of the invention shown in Figure 4, to comprising a kind of file and picture of interference colour, axis of projection is set datum line is set, according to the axis of projection datum line axis of projection is set, extract the principle of color of object layer according to axis of projection.
Particularly, in the example depicted in fig. 4, background colour is a white, and color of object is a black, and interference colour is red.
In the RGB of three-dimensional color space, background colour center and interference colour center represent that with some P0, P01 the aim colour center is with some P
1Expression has axis of projection that benchmark is set and obtains unit 104 P0, P01 are linked to each other with straight line, is designated as line 1, and by axis of projection device 105 is set and crosses the aim colour centers and do the straight line perpendicular to line 1, is designated as line A1, and this line A1 is an axis of projection.
Then, certain the pixel P in the image can find corresponding rgb value with its color in color space, also is a point.Cross this point by aim colour extraction apparatus 106 and do projection to axis of projection.Clearly; The length of the projection of background colour and interference colour (white and red) (is also claimed projection value; Be that it is the probable value of background colour) bigger, and the resulting projection value of the projection of aim colour is less, thus can confirm that by projection value this pixel is the probability of background colour in gray space.
Like this, the projection value linear normalization of all pixels to interval [0,255], is promptly added up the resulting projection value g of projection
i, confirm its maximal value g
MaxWith minimum value g
Min, then that all pixels are corresponding projection value g
iLinear mapping is to 0-255, i.e. 255* (g
i-g
Min)/(g
Max-g
Min), export the gray level image after the normalization at last, the image of the color of object layer that this gray level image promptly extracts.
Fig. 5 has illustrated second embodiment of first embodiment of the invention.In a second embodiment,, obtain the axis of projection datum line, axis of projection is set, extract the principle of color of object layer according to axis of projection for the file and picture of the interference colour that comprises two or more.
Particularly, in the example depicted in fig. 5, background colour is a white, and color of object is a black, and interference colour is respectively redness, blue and green.
In example as shown in Figure 5, in the RGB of three-dimensional color space, the background colour center is represented with some P0, and the interference colour center is represented with P01, P02, P03 respectively, and the aim colour center is represented with some P1.By axis of projection benchmark acquisition unit 104 is set P01, P02, P03...... are linked to each other with background colour center P 0 usefulness straight line respectively, obtain line 1, line 2, line 3, promptly axis of projection is provided with datum line.By crossing the aim colour center P
1Do vertical line perpendicular to line 1, line 2, line 3 as axis of projection, obtain axis of projection A1, axis of projection A2, axis of projection A3.
For certain the pixel P in the image; Can in color space, find corresponding rgb value with its color; It also is a point; Cross this point by aim colour extraction apparatus 106 and do projection, get the projection of this pixel of conduct in gray space of this pixel value minimum in the projected length (projection value) of each axis of projection to each axis of projection.Clearly, the resulting projection value of the projection of background color is bigger, and the resulting projection value of the projection of color of object is less, thereby can confirm that by projection value this pixel is the probability of background colour in gray space.
All grey scale pixel value linear normalizations to interval [0,255], are promptly added up the resulting projection value g of projection
i, confirm its maximal value g
MaxWith minimum value g
Min, then that all pixels are corresponding projection probable value g
iLinear mapping is to 0-255, i.e. 255* (g
i-g
Min)/(g
Max-g
Min), export the gray level image after the normalization at last.
In the above embodiments, interference colour (P01, P02, P03) is linked to each other with background colour center P 0 usefulness straight line respectively, obtain line 1, line 2, line 3.Cross the aim colour center P
1Do vertical line perpendicular to line 1, line 2, line 3 as axis of projection.But this is not restrictive, can regard background colour as a kind of common interference colour.In the set of background colour and interference colour formation, at will select a kind of color as the summit look, and each links to each other with this summit look other color with straight line, obtain line 1, line 2, line 3 etc.Cross the aim colour center P
1Do vertical line perpendicular to line 1, line 2, line 3 as axis of projection.
In another embodiment, can background colour and interference colour aim colour for example be divided into two groups that number equates randomly, the interference colour in two groups connects with straight line correspondingly, crosses the aim colour center P then
1Do vertical line perpendicular to these lines as axis of projection.For example for the situation of color image shown in Figure 5, can background colour and interference colour be divided into two groups (that is, white and red one group, blue and green one group), interconnect between two groups then, thereby obtain line 1 and line 2, and confirm axis of projection A1 and A2 thus.
Then,, cross this point and do projection, get the projection of this pixel of conduct in gray space of this pixel value minimum in the projected length (projection value) of each axis of projection to each axis of projection for certain the pixel P in the image.
If can not be divided into two groups that equate fully, then remaining a kind of color can link to each other with straight line with background colour or arbitrary other interference colour, crosses the aim colour center P then
1Do vertical line perpendicular to this line as axis of projection.
In addition; Similar with the situation of background color shown in Figure 5; The line of the color center of one or more color in the set of forming through background colour and interference colour can have many; A kind of color in promptly should set can link to each other with straight line with two kinds or more colors in this set, and so axis of projection is set.
In the superincumbent statement, Fig. 4 shows a kind of situation of interference colour, and Fig. 5 shows the situation of three kinds of interference colours, but the present invention is not limited, but goes for the situation of two kinds or four kinds or more kinds of interference colours.Owing to can obtain similarly to two kinds of interference colours with to the situation of interference colour more than three kinds, therefore not repeat them here.
Describing second embodiment of the invention axis of projection below in conjunction with Fig. 6 and Fig. 7 is provided with benchmark and obtains the handling principle that unit 104, axis of projection are provided with device 105 and aim colour extraction apparatus 106.In second embodiment of the invention; To comprising the file and picture of two kinds or more kinds of interference colours; Axis of projection is provided with benchmark and obtains the determined plane of color center that unit 104 obtains three kinds of colors in the set that said background colours and said interference colour form; As said axis of projection reference field is set, and makes the color center of every kind of color in the said set through a said axis of projection reference field is set at least.By axis of projection the unit 105 said axis of projection of mind-set from color of object is set and benchmark is set carries out projection, said projection line is set to axis of projection; At last by aim colour extraction apparatus 106 through with each pixel of said coloured image to said axis of projection projection, and extract aim colour color layers gray level image.
Fig. 6 shows axis of projection according to second embodiment of the present invention and benchmark is set obtains first embodiment that unit 104, axis of projection are provided with the processing of device 105 and aim colour extraction apparatus 106.In this first embodiment, for the file and picture that comprises 2 kinds of interference colours, the axis of projection reference field is set, axis of projection is set according to the axis of projection reference field, extract the color of object layer according to axis of projection.
Particularly, in the example depicted in fig. 6, background colour is a white, and color of object is a black, and interference colour is respectively red and green.
In the example depicted in fig. 6, in the RGB of three-dimensional color space, the background colour center representes that with some P0 interference colour representes that with P01 and P02 the aim colour center is represented with some P1.Axis of projection is provided with benchmark and obtains unit 104 plane of P01, P02,3 formations of P0 is made as the axis of projection reference field.Axis of projection is provided with device 105 and crosses the straight line that aim colour center P 1 is done perpendicular to this plane, is designated as line A1, and this line is an axis of projection.In the present invention, planes (plane that for example P01, P02, P0 formed) background colour and interference colour composition or that a plurality of interference colours are formed are called axis of projection reference field is set.Axis of projection is provided with datum line and axis of projection to be provided with reference field and to become the axis of projection benchmark.
Then, with above-described similar, certain the pixel P in the image can find corresponding rgb value with its color in color space, also is a point.Cross this point by aim colour extraction apparatus 106 and do projection to axis of projection.The projection value linear normalization of all pixels to interval [0,255], is exported the gray level image after the normalization, the image of the color of object layer that this gray level image promptly extracts at last.
Fig. 7 shows axis of projection according to second embodiment of the present invention and benchmark is set obtains second embodiment that unit 104, axis of projection are provided with the processing of device 105 and aim colour extraction apparatus 106.In this second embodiment, for the file and picture that comprises 3 kinds of interference colours, the axis of projection reference field is set, axis of projection is set according to the axis of projection reference field, extract the color of object layer according to axis of projection.
Particularly, in the example depicted in fig. 7, background colour is a white, and color of object is a black, and interference colour is respectively redness, green and blue.
In the example depicted in fig. 7, in the RGB of three-dimensional color space, the background colour center representes that with some P0 interference colour representes that with P01, P02 and P03 the aim colour center is represented with some P1.3 of P01, P02, P0 constitute a plane, cross the straight line that aim colour center P 1 is done perpendicular to this plane, i.e. axis of projection A1, and simultaneously, P03, P02,3 of P0 constitute another plane, cross the straight line that aim colour center P 1 is done perpendicular to this plane, i.e. axis of projection A2.
Then, with above-described similar, certain the pixel P in the image can find corresponding rgb value with its color in color space, also is a point.Cross this point and do projection respectively, get one less in two projection values to axis of projection A1 and A2, as this pixel final projection value.The projection value linear normalization of all pixels to interval [0,255], is exported the gray level image after the normalization, the image of the color of object layer that this gray level image promptly extracts at last.
In the superincumbent statement, Fig. 6 shows the situation of 2 kinds of interference colours, and Fig. 7 shows the situation of three kinds of interference colours, but the present invention is not limited, but goes for the situation of four kinds or more kinds of interference colours.Because the situation to four kinds or more kinds of interference colours can obtain similarly, therefore do not repeat them here.
Fig. 8 shows the process flow diagram according to the designated color layer method for distilling of one embodiment of the present invention.
At first, in step 801, confirm the background colour center.As stated, the method for confirming the background colour center can be histogram method, clustering procedure or average drifting method.
Then, in step 802, confirm each interference colour center.
Subsequently, in step 803, confirm the aim colour center.
The method of confirming each interference colour center and aim colour center can adopt clustering procedure and average drifting method.
Though step 801-803 is in sequence in the drawings, these steps can walk abreast and carry out.And, when ratio of precision not high in desired precision or background colour, aim colour and the interference colour imported is higher, can omit these steps.
Step 801-803 can be accomplished by background colour estimator 101, interference colour estimator 102 and aim colour estimator 103 respectively.
Subsequently, obtain the processing that axis of projection is provided with benchmark in step 804.
In one embodiment, benchmark is set is that axis of projection is provided with datum line to said axis of projection.Particularly, can the color center of each color in the set of background colour and interference colour composition be interconnected with straight line, make every kind of color center pass through straight line at least.
In a kind of concrete embodiment, respectively each interference colour center is connected with the background colour center with straight line.These straight lines have constituted axis of projection datum line have been set.
In another concrete embodiment, a certain interference colour center as the summit look, is connected with the background colour center other interference colour center respectively with straight line with this interference colour center.These straight lines have constituted axis of projection datum line have been set.
In another concrete embodiment, the color center through a kind of or more colors in interference colour and the set that background colour is formed is connected with other color straight line in two or more this set.
In another embodiment, benchmark is set is that axis of projection is provided with reference field to said axis of projection.Particularly, the color center of each color in the set of forming with background colour and interference colour is confirmed one or more plane, on the plane that every kind of color center is positioned at least determined.
Step 804 is provided with benchmark acquiring unit 104 by axis of projection and realizes.
Then, in step 805, axis of projection is set.
Particularly, cross the aim colour center do perpendicular to these axis of projections benchmark is set vertical line as axis of projection.
Step 805 can be provided with device 105 by axis of projection and accomplish.
In step 806,, cross this point and do projection then, get the projection value of pixel value on axis of projection of this pixel, as the gray-scale value of this pixel in gray space to axis of projection for each pixel P in the image.When a plurality of axis of projection, get the projection value of this pixel value minimum in the projection value of each axis of projection, as the gray-scale value of this pixel in gray space.
At last, in step 907, the gray-scale value linear normalization of all pixels to interval [0,255], is promptly added up the resulting projection value g of projection
i, confirm its gray-scale value g
MaxWith minimum value g
Min, then with all pixel corresponding gray g
iLinear mapping is to 0-255, i.e. 255* (g
i-g
Min)/(g
Max-g
Min), export the gray level image after the normalization at last.
Fig. 9 has schematically provided the designated color layer extracting device that utilizes Fig. 1 or has adopted designated color layer method for distilling shown in Figure 8 to handle the concrete example of coloured image.Particularly, Fig. 9 has schematically shown concrete coloured image and the result of handling according to the mode of the embodiment of Fig. 4 thereof.In original colorful image, in the input color file and picture shown in Fig. 9 top, background color is a white, and the literal and the redness that contain black are affixed one's seal.Show at Fig. 9 middle part utilize Fig. 4 institute specifically the method for example be designated color layer with the black layer, be the gray level image that interference colour was extracted with red seal.It is designated color layer that Fig. 9 bottom shows with red seal, is interference colour with the black layer, utilize Fig. 4 the gray level image that extracts of the method for concrete example.In the gray level image that processing obtains, background white and interference colour all become white, have obtained inhibition, and color of object becomes black, has obtained reservation.The lap of target white and interference colour becomes grey.The gray-scale value of pixel has just embodied it and has belonged to the power of designated color.
Figure 10 has schematically provided the designated color layer extracting device that utilizes Fig. 1 or has adopted designated color layer method for distilling shown in Figure 8 to handle the concrete example of coloured image.Particularly, Figure 10 has schematically shown concrete coloured image and the result of handling according to the mode of the embodiment of Fig. 6 thereof.In the illustrative original colorful image of Figure 10 left side institute, background color is a white, specifies and extracts black layer.The viridescent form line of interference colour, redness are affixed one's seal, and this image can be the image of bmp form.On Figure 10 right side in the gray level image after the illustrative extraction, background white and interference colour all become white, have obtained inhibition, target black becomes black, has obtained reservation.Aim colour becomes grey with the lap that disturbs redness.The gray-scale value of pixel has just embodied it and has belonged to the power of designated color (being black here).
Figure 11 has schematically provided the designated color layer extracting device that utilizes Fig. 1 or has adopted designated color layer method for distilling shown in Figure 8 to handle the concrete example of coloured image.Particularly, Figure 11 has schematically shown concrete coloured image and the result of handling according to the mode of the embodiment of Fig. 5 or Fig. 7 thereof.In the shown original bmp coloured image of Figure 11 topmost, background color is a white, comprises red seal, green invoice title, the invoice number (0073140) of black and blue exabyte etc.
Illustrating to have provided with the green at the middle part of Figure 11 is interference colour, is the gray level image that aim colour extracted with black.Can find out that from this gray level image background white and green all become white, and not as all the other colors of interference colour, have obtained good reservation like redness, blueness etc., occur with the form with respect to the different gray scales of aim colour.
What illustrate in the bottom of Figure 11 to provide is interference colour with green, redness, is the gray level image that aim colour extracted with black.Can find out that from this gray level image background white, green and redness all become white, and all the other several kinds of color of objects have all obtained good reservation, occur with the form with respect to the different gray scales of aim colour.
Can find out also that from Figure 11 the present invention can effectively remove particular color.
The description that should be noted that the front is exemplary, is not limitation of the present invention.For example, the present invention also can adopt the method for other expression color, for example CMY, YUV, YCrCb space etc., and the scheme of extracting color layers this moment can be identical with the front.
According to embodiments of the invention, can from coloured image, extract the color layers of appointment.It can make full use of the information of input, and the required information of knowing is also less.In certain embodiments, only need know color of object attribute and interference colour to be extracted, and need not know the content of coloured image and other color that is comprised.It is output as gray level image; The strong and weak represent pixel color of gray scale belongs to the confidence level (perhaps probability) of color of object; Even in the overlapping region of color of object and other color, also can isolate the color of object zone, can handle the overlapping region of different colours preferably.
The technician who is familiar with the field of the invention should be appreciated that; Any processing in the process flow diagram of this paper or that otherwise describe or method description or square frame can be understood that promptly to comprise by simple hard-wired parts, element, device, unit etc.; The code that also comprises one or more executable instruction of the concrete logic function that is used for realizing this processing or step is expressed module, code segment or code portions, promptly also can be realized by software.In addition, also can realize through the combination of computer software and hardware.
Logic in the process flow diagram of this paper or that otherwise describe and/or step for example can be considered the orderly expression of the executable instruction that is used to realize logic function; Can through or combined command executive system, equipment or device (for example, the other system of this instruction maybe can called and carry out in computer-based system, the system that contains processor from instruction execution system, equipment or device) in any computer-readable medium that uses, realize these logics and/or step.In the context of this paper, " computer-readable medium " can be can comprise, store, pass on, propagate or transmit through or any device of the program used of combined command executive system, equipment or device.Computer-readable medium for example can but be not limited to electricity, magnetic, optics, electromagnetism, infrared or semiconductor system, unit or propagation medium.The embodiment more specifically (non exhaustive) of computer-readable medium comprises the following: have one or more leads electrical connection (electricity), portable computer diskette (magnetic), random-access memory (ram) (electricity), ROM (read-only memory) (ROM) (electricity) but erasing type programmable read only memory (EPROM or flash memory) (electricity), optical fiber (optics) and portable optic disk ROM (read-only memory) (CDROM) (optics).Note; Computer-readable medium even can be paper spare or other the suitable media that is printed on program above that; Because can come this program of electron capture via for example paper spare or other media being carried out optical scanning; Then compiling, explain or in a suitable manner this program carried out other processing as required, then with this procedure stores in computer memory.
With reference to specific embodiment the present invention has been described in the instructions in front.Yet those of ordinary skill in the art understands, and under the prerequisite that does not depart from the scope of the present invention that limits like claims, can carry out various modifications and change.