Based on the problems referred to above, fundamental purpose of the present invention provides a kind of automatic image cutting out method, has the object image of broken edge with automatic cutting, and then improves the using value of scanner.
Another object of the present invention provides a kind of high efficiency automatic image cutting out method, the scope of cutting can be approached the actual size of broken edge, reducing the data volume of required processing, and then improves the efficient of handling.
Another purpose of the present invention provides a kind ofly can directly remove the method for the background image of object by scanner, so that scanner is widely used in the processing of graph data.
In order to achieve the above object, a kind of automatic image cutting out method of being applied on the one scan device of the present invention comprises step at least: set up a loam cake base plate style database; Read the preposition scan image of scanned object; According to a pattern unit that sets, compare the reference data of this base plate style database and the RGB colour difference of this preposition scan image successively; When the RGB colour difference of judging two pattern units is in a setting range, judge the image that does not comprise this scanned object in this pattern unit; When the RGB colour difference of judging two pattern units exceeds in the setting range, judge the image that comprises this scanned object in this pattern unit, and write down the position of this pattern unit; After the comparison of finishing entire image, in the pattern unit of this record, link adjacent pattern unit, to form the array graph data; And, read this graph data according to this array graph data edge.
In order to achieve the above object, the another kind of automatic image cutting out method that the present invention is applied on the one scan device comprises step at least: the base plate style of a loam cake is provided, and this base plate style is made of several identical pattern units of size; Carry out the scanning in advance of this base plate style, to produce the preposition scan image of this base plate style; Seek the actual coordinate of the pattern unit of this base plate style; Calculate and store the reference coordinate of each pattern unit, and RGB mean value reaches the wherein coordinate position of each pixel; Read the preposition scan image of scanned object; According to this pattern unit, compare the rgb value of RGB mean value and this preposition scan image of the pattern unit of this base plate style successively; When the RGB colour difference of judging two pattern units exceeds in the setting range, judge the image that comprises this scanned object in this pattern unit, and write down the position of this pattern unit; After the comparison of finishing entire image, in the pattern unit of this record, link adjacent pattern unit, to form the array graph data; Reach graph data edge, read this graph data according to this array.
Based on above-mentioned purpose, the present invention proposes a kind of cutting automatically and has the method for the scanned object of broken edge.The present invention provides to have the fixedly pattern of style at the loam cake base plate of scanner, the reference coordinate when getting object to be used as frame, and as the usefulness of the comparison of color.When scanner is installed for the first time, just scan the pattern of base plate in advance, with position and RGB mean value and the variance (variance) of analyzing each pattern, and set up the database of this base plate style.Afterwards, all when carrying out the automatic cutting of scanned object image, as long as according to a pattern unit, in turn compare the data of being stored in this base plate style database and the RGB colour difference of this preposition scan image, just whether include the view data of scanned object in each pattern unit of decidable.If the RGB colour difference of judging two pattern units in a scope of setting the time, does not then comprise the image of this scanned object in this pattern unit of decidable.Otherwise, the position of then writing down this pattern unit.After the judgement of entire image is finished in wait, linking adjacent pattern unit, just is the image-region of scanned object.Prolong the cutting in addition of its edge then, just can obtain the image of scanned object.The present invention not only can be applicable to the automatic cutting of irregular figure, also can accelerate known frame for the square chart picture and get speed.
For addressing the above problem, the present invention provides one to have the fixedly pattern of style, shown in Fig. 2 A at the loam cake base plate of scanner.Reference coordinate when the purpose of this pattern is to be used as the cutting object, and as the usefulness of the comparison of color.As long as pattern itself has style and size is consistent, and the characteristic of queueing discipline gets final product, and is not limited to use the pattern of trellis.And should reduce overlapping fuzzy area between the pattern, the accuracy when increasing cutting.
Because the loam cake base plate of every scanner has error when mounted, therefore for trying to achieve reference coordinate accurately, must when the initial start-up scanner, read the pattern of base plate, debate the coordinate of knowing pattern, to set the database of a base plate style.Pattern with Fig. 2 A is an example, and the database building method of its base plate style as shown in Figure 3.
Step 31: with the low resolution of 50dpi, the style of run-down base plate in advance is to produce the preposition view data (pre-scanned image) of base plate style.
Step 32: seek the actual coordinate of pattern then, i.e. the position at pixel place.From the image of preposition scanning, begin to be used as the block of sampling by the upper left corner with a pocket.Then, from wherein looking for the most black block of gray scale.After finding,, make the coordinate of upper left corner black pattern, and find out the position (size of known pattern is all identical) of all black patterns according to this coordinate as the normal size of all black patterns.Then, find out the position (known have only two kinds of different gray scales) of all grey colored patterns with the same manner.The mode of looking for of pattern has many known algorithms to use, and repeats no more.
Step 33: reference coordinate and the RGB reference value of setting each pattern.Setting each pattern is a unit, because in each black pattern or grey colored pattern unit of being found out, therefore constituted by many pixels, with the RGB mean value and the variance of all pixels in this pattern unit, as the RGB reference value of this pattern unit.For example, have 20 pixels in each black pattern, just after the difference summation with the value of the red, green, blue colourity of 20 pixels in this unit, again respectively divided by 20, to be used as the RGB mean value of this black pattern unit, square margin then is that the red, green, blue chromatic value of 20 pixels in each pattern unit is subtracted each other back square with mean value respectively, in addition average again value.
Then, be used as a unit, to set its reference coordinate with the block of black pattern or grey colored pattern.With the enlarged drawing of Fig. 2 B is the example explanation, in the black pattern of finding out and grey colored pattern, set successively with reference to coordinate be (i, j).Because greater than its actual coordinate, the pattern comparison after therefore can making it is more quick effective with reference to the scope of coordinate.
Step 34: store the reference data of each pattern unit then, comprise: the position of each pixel in RGB reference value, this pattern unit, and the reference coordinate of this pattern unit.
So, just, set up base plate style data of database.The foundation of database only needs to set when scanner is installed for the first time once to get final product.Afterwards, just can carry out the processing of automatic cutting to the graph data of Any shape.
The principle of the automatic cutting of image of the present invention is that the reference data of the preposition scan image of scanned object and base plate style database is compared.The user can the punishment of the side of selection frames images get, or select a frame to get desired irregular figure.
The method of automatic cutting of the present invention is as shown in Figure 4:
Step 401: the reference data that is written into base plate style database.
Step 402: with same resolution,, carry out the program of sweeping in advance of scanned object, to produce the preposition view data of scanned object as 50dpi.
Step 403: according to the pattern unit that sets, in the position of comparison same units, the RGB colourity difference of the preposition image reference data of base plate pattern and the preposition scan image of scanned object.The purpose of this comparison is to find out the position at scanned object place.Because be not scanned the part that object hides, the feature of necessary meeting display backpanel type pattern.In like manner, the part of the pattern characteristics of display backpanel pattern just is not the position at scanned object place.And the color in the same pattern unit is all very approaching, and the image of general scanned object does not then have this characteristic.In addition, the mean flow rate data in the same pattern unit are also close, the reference when can be used for as filtration.
During comparison be reference coordinate with pattern be unit relatively.In the position of same pattern unit, compare the RGB mean value and the variance (variance) of the preposition scan image of scanned object, with the RGB reference value of this pattern unit.
Step 404: if both RGB colour differences in a default error amount, execution in step 405; Otherwise, execution in step 406.
Step 405: judge the image that does not comprise institute's scanned object in this pattern unit.
Step 406:, represent that this pattern unit comprises the image of scanned object if both colourity difference exceeds a default error amount.So, the position of writing down this pattern unit.
Step 407: after finishing the comparison of whole pattern units, in the pattern unit that is write down, link adjacent pattern unit, to become same group figure.If the image of single pass three pictures, just have three groups figure.
Step 408: at this moment, if select square frame to get mode, just according to the reference coordinate of the pattern unit in the upper left corner and the lower right corner, the scope of calculation block, comparison is to actual figure primitive unit cell, with the view data in the cutting square frame then.
Step 409: if select a frame to get wherein irregular pattern, just need find out record pattern unit on, down, a left side, right reference coordinate cuts out the irregular figure that will read.The mode of cutting can utilize present existing many algorithms to carry out.
After having cut,, can take out desired figure as long as carry out the processing of Transparent color at the data at scanned object edge.The fineness of the irregular area that cuts out is relevant with the style size of base plate pattern.If pattern is less, cutting area is comparatively meticulous, and the required block scope of handling again is also little, and data volume is also less.But, then be difficult to find out feature, and can't effectively compare with scanned object if style is too little.
So, use method of the present invention, not only can be applicable to cutting out of any irregular figure, also can improve the using value of scanner, any such as art designing's figure all can be by the cutting out of scanner, and be applied to the processing of webpage, or other Flame Image Process.And method of the present invention is not limited to the figure quantity of single pass, therefore can significantly improve the efficient that scanner uni is cut out.
The above only is the preferred embodiments of the present invention, and has reached practical effect widely, and all equalizations of doing according to claims of the present invention change and distortion, within the scope that all still belongs to patent of the present invention and contained.