CN103313015A - Image processing method and image processing device - Google Patents
- ️Wed Sep 18 2013
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that obtains under the creative work prerequisite.
The embodiment of the invention mainly is based on FPGA(Field Programmable Gate Array, field programmable gate array) technology realizes, is mainly used in intelligent optical projection system, such as intelligent projector etc.What the man-machine interaction mode on the intelligence projector system adopted is the mode that laser pen is controlled, and this mode of operation has been brought convenient to the user and directly controlled experience.CMOS sensor module in the intelligence optical projection system sends the image with laser spots information, image processing module receives after this image information through algorithm process, laser spots is extracted, change coordinate information into, then this coordinate information is passed to the operation that main frame is correlated with, thereby realize controlling of user.FPGA is as image processing module, and one of function wherein is to process the problem of connected domain.The image that camera photographed sends FPGA to according to the stream socket that contains the RGB component.Describe the technical scheme of the embodiment of the invention in detail below in conjunction with different embodiment.
As shown in Figure 1, the image processing method of the embodiment of the invention one comprises:
11, obtain the connected domain parameter corresponding to the first pixel column of pending image, wherein, described connected domain parameter comprises row cache space and at least one connected domain structure.
Wherein, the pixel column that described the first pixel column refers to the method that begins to utilize the embodiment of the invention when pending image is processed, for example it can be first pixel column of pending image, also can be any pixel column of pending image.
The connected domain of indication (connected_domain) refers to the set that has the pixel of correlation in the pending image in the embodiment of the invention.Be the various parameters that represent easily connected domain and the correlation between each pixel, in embodiments of the present invention, described connected domain parameter comprises row cache space and at least one connected domain structure.
Wherein, described row cache space is used for connected component labeling corresponding to each row pixel bright spot pixel of storage.For the dim spot pixel, not for it arranges connected component labeling, in the spatial cache of being expert at, the position corresponding with the dim spot pixel represents with 0 in the embodiment of the invention.Certainly, also can represent with other signs.In concrete the application, this row cache space can be a plurality of, and each row cache space is corresponding one by one with each pixel column, also is that each pixel provisional capital has corresponding row cache space; Perhaps the row cache space can be one, this row cache space is used for storing connected component labeling corresponding to bright spot pixel in all pixel columns, at this moment, current pixel capable in connected component labeling corresponding to bright spot pixel will cover and connect connected component labeling corresponding to a pixel in the pixel column.In embodiments of the present invention, be to save the space, be described as example so that a row cache space only to be set.
Wherein, described connected domain structure is the structure for the attribute that represents a connected domain, and as shown in Figure 2, its parameter can comprise:
SUM_DOT, SUM_X, SUM_Y, X_MAX, X_MIN, Y_MAX, Y_MIN, Another etc.
Wherein, SUM_DOT is the sum of pixel in the connected domain, also can be described as the area of this connected domain; SUM_X is the summation of all pixel abscissas in the connected domain; SUM_Y is the summation of all pixel ordinates in the connected domain; X_MAX is the maximum of all pixel abscissas in the connected domain; X_MIN is the minimum value of all pixel abscissas in the connected domain; Y_MAX is the maximum of all pixel ordinates in the connected domain; Y_MIN is the maximum of all pixel ordinates in the connected domain; The label of that connected domain that Another connected domain link parameter, its value are linked to for this connected domain.
Wherein, the quantity of described connected domain structure can arrange according to the maximum of connected component labeling corresponding to each bright spot pixel, also namely, the quantity of required connected domain structure equals the maximum of connected component labeling corresponding to each bright spot pixel in concrete application process.
Based on above explanation, whether be first pixel column of pending image according to described the first pixel column, can be divided into following dual mode and process:
(1) first pixel column of the described pending image of described the first pixel behavior that is to say that this step can comprise when beginning to process from first pixel column of pending image:
Step 111, determine bright spot pixel and dim spot pixel in described first pixel column.
RGB represents the color of three passages of red, green, blue, this standard comprised human eyesight can perception all colours, be to use at present one of the widest color system.In intelligent optical projection system, the laser color of the laser pen that it adopts is red, because laser color is purer, so the green component of this laser and blue component can not considered.Therefore, in this step mainly be by with the R value of certain pixel with preset the R threshold value and compare to determine whether this pixel is bright spot.Wherein, this default R threshold value can arrange arbitrarily.Concrete, if the R value of this pixel greater than default R threshold value, thinks that then this pixel is bright spot, otherwise think that this pixel is dim spot.
Certainly, be with the R value of pixel for the particularity of intelligent optical projection system just and preset R value and compare at this, in concrete application, can also come by other means to determine whether certain pixel is the bright spot pixel, does not make particular determination at this.
Step 112, according to the distribution of bright spot pixel and dim spot pixel in described first pixel column, determine the connected component labeling of described bright spot pixel, and the connected component labeling of described bright spot pixel is stored in memory location corresponding to bright spot pixel described in the described row memory space.
Concrete, can adopt the connected component labeling that connects a pixel in definite in such cases this first pixel column of following principle:
If the neighbor pixel on predetermined scanning sequency of the first bright spot pixel also is the bright spot pixel in described first pixel column, then utilize the connected component labeling of described neighbor pixel as the connected component labeling of described the first bright spot pixel; If the neighbor pixel on the predetermined scanning sequency of the first bright spot pixel is dim spot pixel or the neighbor pixel of nothing on predetermined scanning sequency in described first pixel column, then connected component labeling maximum in the described row cache space is added 1 connected component labeling as described the first bright spot pixel.
Wherein, described predetermined scanning sequency refers to the order that this first pixel column is scanned, for example from left to right, and perhaps from right to left.On custom, scanning sequency comparatively commonly used was for from left to right when certain pixel column was scanned.The predetermined scanning sequency of hereinafter mentioning is identical with predetermined scanning sequency at this.
For example, according to scanning sequency from left to right, suppose that first pixel in first pixel column is the bright spot pixel, also namely as the first bright spot pixel at this, according to above-mentioned treatment principle, because its left side is without neighbor pixel, and it is first bright spot pixel of this pixel column, and therefore, the connected component labeling of current maximum is 0, so this first pixel i.e. connected component labeling of the first bright spot pixel is 1.Then, the connected component labeling with described first bright spot pixel is stored in memory location corresponding to first bright spot pixel described in the described row memory space.Then, for second pixel, suppose that it also is the bright spot pixel, because its left pixel point is that first pixel is the bright spot pixel, therefore, the label of second pixel is identical with the label of first pixel, namely also is 1.Then, the connected component labeling with described second bright spot pixel is stored in second memory location that the bright spot pixel is corresponding described in the described row memory space.
Step 113, utilize the coordinate parameters of described bright spot pixel to upgrade the connected domain structure that connected component labeling corresponding to described bright spot pixel points to.
In the process that first pixel column is scanned, in definite each bright spot pixel and dim spot pixel, also can obtain the coordinate figure of each pixel.Therefore, mainly be to utilize the coordinate parameters of described the first bright spot pixel to upgrade the connected domain structure that connected component labeling corresponding to described the first bright spot pixel points in this step.
Concrete, at first, utilize the abscissa of described bright spot pixel and ordinate to upgrade respectively abscissa summation parameter and ordinate summation parameter in the described connected domain structure.Also namely, the basis of current abscissa summation adds the abscissa of the above bright spot pixel in the connected domain structure, and with after the addition and as the abscissa summation parameter after upgrading; The basis of current ordinate summation adds the ordinate of the above bright spot pixel in the connected domain structure, and with after the addition and as the ordinate summation parameter after upgrading.If the abscissa of described bright spot pixel or ordinate respectively greater than the maximum abscissa value in the described connected domain structure or maximum ordinate value, then utilize the abscissa of described bright spot pixel or ordinate to upgrade maximum abscissa value or maximum ordinate value in the described connected domain structure.At last, utilize the abscissa of described bright spot pixel and ordinate to upgrade connected domain area parameters in the described connected domain structure.
Institute's act situation is as example in the step 112, and for first pixel, utilizing its coordinate renew connected component labeling is each parameter in 1 the connected domain structure.For second pixel, being still and utilizing its coordinate renew connected component labeling is each parameter in 1 the connected domain structure.
(2) described the first pixel column first pixel column that is not described pending image, this step can comprise:
Step 211, determine bright spot pixel and dim spot pixel in described the second pixel column.
Wherein, described the second pixel column refers to next pixel column of described the first pixel column.For example, when described first first pixel column of pixel behavior, second pixel column of described the second pixel behavior.The detailed process of this step can be with reference to the description of step 111, and the processing object that different is in this step is the second pixel column.
Step 212, according to the distribution of bright spot pixel and dim spot pixel in described the second pixel column and according to described connected domain parameter, determine the connected component labeling of bright spot pixel in described the second pixel column, and the connected component labeling of described bright spot pixel is stored in memory location corresponding to bright spot pixel described in the described row memory space.
In this process, determine that the connected component labeling mode of bright spot pixel in described the second pixel column is as follows:
(1) pixel of described the second bright spot pixel in the first pixel column corresponding position is the dim spot pixel, and also namely at the upper pixel column of described the second pixel column namely in the first pixel column, the pixel of the position corresponding with the second bright spot pixel is the dim spot pixel.Wherein, described the second bright spot pixel is not to refer in particular to certain pixel, refers to any one the bright spot pixel in the second pixel column.
In the case, if the neighbor pixel on predetermined scanning sequency of the second bright spot pixel also is the bright spot pixel in described the second pixel column, then utilize the connected component labeling of described neighbor pixel as the connected component labeling of described the second bright spot pixel; If the neighbor pixel on the predetermined scanning sequency of the second bright spot pixel is dim spot pixel or the neighbor pixel of nothing on predetermined scanning sequency in described the second pixel column, then connected component labeling maximum in the described row cache space is added 1 connected component labeling as described the second bright spot pixel.
Wherein, the concept of predetermined scanning sequency can be with reference to above-mentioned explanation.
Special, if comprise the connected domain link identification in each connected domain structure of described connected domain parameter, so in this step, according to the connected domain link identification in each connected domain structure of the distribution of bright spot pixel and dim spot pixel in described the second pixel column and described connected domain parameter, determine the connected component labeling of bright spot pixel in described the second pixel column.
Concrete, can obtain the first connected domain link identification of described the second bright spot pixel in the corresponding connected domain structure of the connected component labeling of the pixel of the first pixel column corresponding position.
(11) be not linked to other connected domains if described the first connected domain link identification represents described the second bright spot pixel in the corresponding connected domain of the pixel of the first pixel column corresponding position, determine in the following ways the connected component labeling of bright spot pixel in described the second pixel column.
If the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column also is the bright spot pixel, then utilize the connected component labeling of described neighbor pixel as the connected component labeling of described the second bright spot pixel, and described the first connected domain link identification is expressed as described the second bright spot pixel is linked to described neighbor pixel in the connected domain of the pixel of the first pixel column corresponding position connected domain; If the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column is the dim spot pixel, then utilize described the second bright spot pixel at the connected component labeling of the pixel of the first pixel column corresponding position connected component labeling as described the second bright spot pixel.
(12) be linked to other connected domains if described the first connected domain link identification represents described the second bright spot pixel in the connected domain of the pixel of the first pixel column corresponding position, determine in the following ways the connected component labeling of bright spot pixel in described the second pixel column.
If if the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column also equals the value of described the first connected domain link identification for the connected component labeling of bright spot pixel and described neighbor pixel or the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column is the dim spot pixel, the connected component labeling of described the second bright spot pixel is labeled as the value of described the first connected domain link identification; If the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column also is not equal to the value of described the first connected domain link identification for the connected component labeling of bright spot pixel and described neighbor pixel, the connected component labeling of described the second bright spot pixel is labeled as the value of described the first connected domain link identification, and the connected domain link identification in the corresponding connected domain structure of described neighbor pixel is changed to the connected component labeling of described neighbor pixel.
Step 213, utilize the coordinate parameters of described bright spot pixel to upgrade the connected domain structure that connected component labeling corresponding to bright spot pixel described in the described connected domain parameter points to.
The detailed process of this step can be with reference to the description of step 113, and the processing object that different is in this step is the second pixel column.
12, utilize the second pixel column of described pending image to upgrade described connected domain parameter, the connected domain parameter after obtaining to upgrade.
According in the
step11 to the processing mode of the first pixel column, process described the second pixel column, and in processing procedure, upgrade described connected domain parameter in conjunction with connected domain parameter corresponding to described the first pixel column.
13, travel through other all pixel columns of described pending image according to the mode of above-mentioned two steps, until last pixel column of the described pending image of described the second pixel behavior, and the connected domain parameter after obtaining last pixel column finished dealing with.
After the second pixel column is finished dealing with according to the processing mode in
step11 and the
step12, other pixel columns in the pending image are still processed according to the mode of above-mentioned two steps record.For example, suppose first first pixel column of pixel behavior, second pixel column of the second pixel behavior is when processing for the 3rd pixel column so, as the first pixel column in the
step11, the 3rd pixel column is namely as the second pixel column in the
step12 with second pixel column.For other pixel columns in the tape handling image, by that analogy, until process last pixel column, obtain final connected domain parameter.
Can find out by step 11-13, in this process, along with the variation of pixel column, the connected domain parameter is also changing, but this variation is to carry out on the basis of connected domain parameter corresponding to pixel column.
14, determine connected domain in the described pending image according to described connected domain parameter after last pixel column is finished dealing with.
In this step, determine at first in the described connected domain parameter after last pixel column is finished dealing with that connected domain link identification in each connected domain structure is zero connected domain structure.Being positioned at preset range if described connected domain link identification is the connected domain area parameters of zero connected domain structure, then is that described connected domain link identification is that the zone that the pixel of zero connected domain structure forms is defined as connected domain with described label.
Preferably, in order further to guarantee the accuracy of definite connected domain, also can judge described connected domain link identification is when whether the connected domain area parameters of zero connected domain structure is positioned at preset range, judge that label is the whether default figure encirclement of scheduled size of the zone that forms of the pixel of the connected domain structure of described connected domain link identification.If two conditions satisfy simultaneously, then can be that described connected domain link identification is that the zone that the pixel of zero connected domain structure forms is defined as connected domain with described label.
As seen from the above, in embodiments of the present invention, only need the connected domain parameter of buffer memory the first pixel column, can be by the connected domain parameter of the second pixel column and buffer memory be compared when the second pixel column is processed, find out the relation of the second pixel column and the first pixel column, always obtain the connected domain information of pending image.Therefore, utilize the method for the embodiment of the invention, can determine fast the connected domain in the pending image, thereby improved the real-time of definite connected domain.
According to the description of above-described embodiment one, can the connected component labeling principle of each pixel in certain pixel column be summarized as follows:
(1) if current pixel point is dim spot, then not for it arranges connected component labeling, just its left pixel point as next pixel is carried out buffer memory.
(2) if current pixel point is bright spot, the mode of connected component labeling then is set mainly in the following several ways:
(21) if a upper pixel (current pixel point is at the pixel of a upper pixel column corresponding position) is dim spot with the left pixel point, think that so current pixel point is arranged in a new connected domain, the largest connected territory label that has arranged is at present added the connected component labeling that " 1 " is used as current pixel point.
(22) if a upper pixel is dim spot, but left pixel point is bright spot, is used as so the connected component labeling of current pixel point with the mark connected component labeling of left pixel point, and namely current pixel point and left pixel point are in same connected domain.
(23) if a upper pixel is bright spot, left pixel point also is bright spot, and when the value of the link of the connected domain in connected domain structure corresponding to upper pixel parameter A nother is zero, then the connected component labeling of current pixel point is the connected component labeling of left pixel point, the value of Another in the connected domain structure that a upper pixel is corresponding simultaneously is set to the connected component labeling of left pixel point, i.e. expression is linked to connected domain under the upper pixel connected domain at left pixel point place.
(24) if a upper pixel is bright spot, left pixel point is dim spot, and the value of the Another in the upper pixel enantiomorph is when being zero, and then the connected component labeling of current pixel point is the connected component labeling of a upper pixel.
(25) if a upper pixel is bright spot, left pixel point is dim spot, and the value of the Another in the upper pixel enantiomorph is when non-vanishing, and then the connected component labeling of current pixel point is the value of Another in the upper pixel enantiomorph.
(26) if a upper pixel is bright spot, left pixel point also is bright spot, but the value of the Another in the upper pixel enantiomorph is non-vanishing, and when the connected component labeling of left pixel point equaled the value of the Another in the pixel enantiomorph, the connected component labeling of current pixel point was the value of the Another in the upper pixel enantiomorph.
(27) if a upper pixel is bright spot, left pixel point also is bright spot, but the value of the Another in the upper pixel enantiomorph is non-vanishing, and when the connected component labeling of left pixel point was not equal to the value of Another, then the connected component labeling of current pixel point was set to the value of the Another in the pixel enantiomorph.Simultaneously, the value of the Another of left pixel point enantiomorph is set to the connected component labeling of left pixel point, and expression is linked to the affiliated connected domain of left pixel point in the connected domain under the upper pixel.
According to foregoing description, for after each pixel determines connected component labeling, when determining connected domain, utilize the abscissa of each bright spot pixel and ordinate to upgrade respectively abscissa summation parameter and ordinate summation parameter in the described connected domain structure.If the abscissa of described bright spot pixel or ordinate respectively greater than the maximum abscissa value in the described connected domain structure or maximum ordinate value, then utilize the abscissa of described bright spot pixel or ordinate to upgrade maximum abscissa value or maximum ordinate value in the described connected domain structure.At last, utilize the abscissa of described bright spot pixel and ordinate to upgrade connected domain area parameters in the described connected domain structure.
Describe the implementation procedure of the image processing method of the following embodiment of the invention in detail below in conjunction with concrete example.
The Sensor photosensitive array of 10 * 10 pixels shown in Figure 3, according to from top to bottom, from left to right order scans every row pixel, can determine bright spot pixel in each pixel column of this image and the distribution of dim spot pixel, for the bright spot pixel in the drawings the alphabetical A-Q of 3 usefulness mark.
In conjunction with Fig. 3, the image processing method of the embodiment of the invention two comprises:
First pixel column of step 31, the pending image of reception, owing to do not have bright spot in this row, so row cache space and each connected domain structure are init state, shown in Fig. 4 (A).
Second pixel column of step 32, the pending image of reception scans the bright spot pixel in this row and dim spot pixel.In scanning process, the mode of the connected component labeling that definite bright spot pixel of describing in one in conjunction with the embodiments is corresponding is determined the connected component labeling of each bright spot pixel, simultaneously its connected component labeling is stored in the correspondence position in row cache space.Then utilize the coordinate parameters of described bright spot pixel to upgrade the connected domain structure that connected component labeling corresponding to described bright spot pixel points to.
As follows in conjunction with Fig. 3 detailed process:
At first scan the A point.As seen from Figure 3, A point left side is dim spot; Can find out in conjunction with Fig. 4 (A), be expert in the spatial cache, the mark of A point corresponding position be zero, its pixel that is illustrated in first pixel column with A point corresponding position also is dim spot, therefore, the connected component labeling that A is ordered is ' 1 ', and A point corresponding position writes ' 1 ' in the spatial cache of being expert at, and the value of X, the Y of ordering according to A is upgraded, and connected component labeling is the structure of " 1 " in the connected domain structure group.
When scanning B point or C point, the state that B point or C are ordered is identical with the A point, so the connected component labeling that B, C are ordered is respectively ' 2 ' and ' 3 ', being expert at, B, C point corresponding position writes ' 2 ' and ' 3 ' in the spatial cache, the value of X, the Y of order according to B, C simultaneously upgrade connected component labeling in the connected domain structure group be ' 2 ' with ' 3 ' structure.
When scanning the D point, its left side C point is bright spot, can find out in conjunction with Fig. 4 (A), be expert at C point corresponding position in the spatial cache mark be zero, the pixel that is illustrated in first pixel column with C point corresponding position also is dim spot, so the connected component labeling that D is ordered is identical with the connected component labeling that its left pixel C is ordered, and is ' 3 '.Being expert at, D point corresponding position writes ' 3 ' in the spatial cache, and connected component labeling is ' 3 ' structure in the value renewal connected domain structure group of X, the Y of order according to D simultaneously.
Concrete, connected component labeling is added 1 for the SUM_DOT value in ' 3 ' the connected domain structure.The X of then D being ordered, Y value respectively with this structure in current SUM_X and the value addition among the SUM_Y, and utilize the numerical value that obtains to upgrade value among SUM_X and the SUM_Y.Then, X_MAX current in the X value that D is ordered and this structure compares, if X_MAX greater than X, then the value of X_MAX remains unchanged, if X_MAX less than X, then upgrades value among the X_MAX with the value of X; X_MIN current in the X value that D is ordered and this structure compares, if the value among the X_MIN less than X, then X_MIN remains unchanged, if the value of X_MIN greater than X, is then upgraded value among the X_MIN with X.The size of the Y value that in like manner relatively current Y_MAX, the value among the Y_MIN and D ordered in this structure: Y_MAX current in the Y value that D is ordered and this structure compares, if Y_MAX is greater than Y, then the value of Y_MAX remains unchanged, if Y_MAX is less than Y, then with the value among the value renewal Y_MAX of Y; Y_MIN current in the Y value that D is ordered and this structure compares, if the value among the Y_MIN less than Y, then Y_MIN remains unchanged, if the value of Y_MIN greater than Y, is then upgraded value among the Y_MIN with Y.
After second pixel column scanned, row cache space and each connected domain structure were shown in Fig. 4 (B).
The 3rd pixel column of
step33, the pending image of reception scans the bright spot pixel in this row and dim spot pixel.In scanning process, the mode of the connected component labeling that definite bright spot pixel of describing in one in conjunction with the embodiments is corresponding is determined the connected component labeling of each bright spot pixel, simultaneously its connected component labeling is stored in the correspondence position in row cache space.Then utilize the coordinate parameters of described bright spot pixel to upgrade the connected domain structure that connected component labeling corresponding to described bright spot pixel points to.
As follows in conjunction with Fig. 3 detailed process:
At first scan the E point.By analysis, the processing that E is ordered is with identical to A, B in second pixel column, processing that C is ordered, the connected component labeling ' 4 ' that storage E in spatial cache E point corresponding position order so be expert at, the value renewal connected component labeling that utilizes simultaneously X, Y that E order are ' 4 ' connected domain structure.
When scanning the F point, the A point of F point corresponding position is bright spot in its left side E point and the upper pixel column, simultaneously, the A point is different with the connected component labeling that E is ordered, be respectively ' 1 ' and ' 4 ', and connected component labeling for ' 1 ' and the connected domain link parameter A nother of two connected domain structures of ' 4 ' be zero, so according to above-mentioned connected component labeling principle, it is identical that the connected component labeling that F is ordered and E are ordered, be ' 4 ', Another in the connected domain structure that the A point is corresponding is labeled as the connected component labeling ' 4 ' that E is ordered simultaneously, and the renewal connected component labeling is other parameters of connected domain structure of 4.Through above-mentioned processing, this shows that A point place connected domain is linked in the connected domain at E point place.The connected component labeling ' 4 ' that storage E in spatial cache F point corresponding position order so be expert at, utilizing the value renewal connected component labeling of X, Y that F order according to the mode of above-mentioned record simultaneously is parameter in ' 4 ' the connected domain structure.
When scanning the G point, its left side F point is bright spot, and G point corresponding position is dim spot in the upper pixel column, and situation is identical with the D point, so the connected component labeling that G is ordered is set to ' 4 '.Being expert at, G point corresponding position writes ' 4 ' in the spatial cache, and connected component labeling is the parameter in ' 4 ' the structure in the value renewal connected domain structure group of X, the Y of order according to G according to the mode of above-mentioned record simultaneously.
When scanning the H point, its left side G point is bright spot, G point corresponding position is B point bright spot in the upper pixel column, situation is identical with the F point, simultaneously, the G point is different with the connected component labeling that B is ordered, be respectively ' 2 ' and ' 4 ', and connected component labeling for ' 2 ' and the connected domain link parameter A nother of two connected domain structures of ' 4 ' be zero, so according to above-mentioned connected component labeling principle, it is identical that the connected component labeling that H is ordered and G are ordered, and is ' 4 ', Another in the connected domain structure that the B point is corresponding is labeled as the connected component labeling ' 4 ' that H order simultaneously, and is the parameter of 4 connected domain structure according to the method renewal connected component labeling of above-mentioned record.Through above-mentioned processing, this shows that B point place connected domain is linked in the connected domain at H point place.
When scanning the I point, its left side H point is bright spot, and G point corresponding position is dim spot in the upper pixel column, and situation is identical with the D point, so the connected component labeling that I is ordered is set to ' 4 '.Being expert at, I point corresponding position writes ' 4 ' in the spatial cache, and connected component labeling is the parameter in ' 4 ' the structure in the value renewal connected domain structure group of X, the Y of order according to I according to the method for above-mentioned record simultaneously.
When scanning the J point, its left side is dim spot, and J point corresponding position D point is bright spot in the upper pixel column, so the connected component labeling that J is ordered is set to ' 3 '.Being expert at, J point corresponding position writes ' 3 ' in the spatial cache, it is ' 3 ' structure that the value of X, the Y of order according to J is simultaneously upgraded connected component labeling in the connected domain structure group, and is the parameter of ' 3 ' connected domain structure according to the method renewal connected component labeling of above-mentioned record.
After the third line pixel column had scanned, row cache space and each connected domain structure were shown in Fig. 4 (C).
The 4th pixel column of step 34, the pending image of reception scans the bright spot pixel in this row and dim spot pixel.In scanning process, the mode of the connected component labeling that definite bright spot pixel of describing in one in conjunction with the embodiments is corresponding is determined the connected component labeling of each bright spot pixel, simultaneously its connected component labeling is stored in the correspondence position in row cache space.Then utilize the coordinate parameters of described bright spot pixel to upgrade the connected domain structure that connected component labeling corresponding to described bright spot pixel points to.
When scanning during the 4th pixel column, K point and A point, E dotted state are identical, are set to ' 5 ' according to the connected component labeling of before the processing mode K of two of A points, E point being ordered, and upgrade simultaneously connected component labeling and be ' 5 ' connected domain structure.The processing mode that the L point is identical with the F point, the connected component labeling that L is ordered is set to ' 5 ', upgrades simultaneously connected component labeling and is ' 5 ' connected domain structure, and the Another with connected domain structure ' 4 ' is updated to ' 5 ' simultaneously.The Another of the pixel F of the upper pixel column corresponding position that M, N are 2 and the connected domain structure of G is ' 5 ', and is identical with the connected component labeling of its left pixel point, so the connected component labeling of M, N is set to ' 5 '.The pixel I of the upper pixel column corresponding position that O is ordered is bright spot, and left pixel point is dim spot, and the Another of the connected domain structure of pixel I is ' 5 ', so O point connected component labeling is ' 5 '.In the connected component labeling of determining the fourth line pixel, the parameter in the corresponding connected domain structure is carried out before described processing.
After the 4th pixel column scanned, row cache space and each connected domain structure were shown in Fig. 4 (D).
The 5th pixel column of step 34, the pending image of reception scans the bright spot pixel in this row and dim spot pixel.In scanning process, the mode of the connected component labeling that definite bright spot pixel of describing in one in conjunction with the embodiments is corresponding is determined the connected component labeling of each bright spot pixel, simultaneously its connected component labeling is stored in the correspondence position in row cache space.Then utilize the coordinate parameters of described bright spot pixel to upgrade the connected domain structure that connected component labeling corresponding to described bright spot pixel points to.
When the 5th pixel column of scanning, the P point has identical state with A, B, 3 of C, so the connected component labeling that P is ordered is set to ' 6 ', simultaneously, in connected component labeling is ' 6 ' connected domain structure, the parameter that the X of ordering according to P and Y value are upgraded this connected domain structure.The Q point is identical with the L dotted state, and the connected component labeling that Q is ordered is set to connected component labeling for the value of the Another of ' 5 ' connected domain structure, is ' 6 '.In determining the 5th pixel column, in the connected component labeling of pixel, the parameter in the corresponding connected domain structure is carried out before described processing.
After the 5th pixel column scanned, row cache space and each connected domain structure were shown in Fig. 4 (E).
35, after all pixels are disposed, travel through all connected domain structures, obtain two null connected domain structures of Another, namely connected component labeling is the connected domain structure of " 3 " and " 6 ".At this moment, carry out determining of connected domain.
Concrete, as to calculate two connected domains according to connected component labeling for SUM_DOT, SUM_X in the connected domain structure of " 3 " and " 6 " and SUM_Y respectively center of gravity, this center of gravity is the coordinate of connected domain.Computing formula and process are as follows.
Wherein, connected component labeling is that the coordinate Calculation mode of structure of " 3 " is as follows:
X3=(SUM_X÷SUM_DOT)=29÷3=9.67;Y3=(SUM_Y÷SUM_DOT)=7÷3=2.33;
So connected component labeling is the coordinate of " 3 " is (9.67,2.33).
Wherein, connected component labeling is that the coordinate Calculation mode of structure of " 6 " is as follows:
X6=(SUM_X÷SUM_DOT)=69÷14=4.93;Y6=(SUM_Y÷SUM_DOT)=49÷14=3.50;
So connected component labeling is the coordinate of " 6 " is (9.67,2.33), (4.93,3.50).
Simultaneously, be the X_MAX in the connected domain structure of " 3 " and " 6 " and difference X_DIF, Y_DIF(X_DIF=X_MAX-X_MIN, the Y_DIF=Y_MAX-Y_MIN of X_MIN, Y_MAX and Y_MIN according to connected component labeling respectively) judge the shape of connected domain, wherein, respectively with X_DIF, the Y_DIF length of side as rectangle, the connected domain that is arranged in this rectangle can be defined as final connected domain, is illustrated in fig. 5 shown below.
According to above-mentioned principle, connected component labeling is 3 for the connected domain structure area of " 3 ", and its rectangle by 1 * 1 surrounds.Connected component labeling is 14 for the connected domain structure area of " 6 ", and its rectangle by 5 * 3 surrounds.
Concrete, if default connected domain area is 10 to 20, and require connected domain by minimum be 3 * 2, to be 6 * 4(unit to the maximum be pixel) rectangle surround.Therefore can draw, because connected component labeling is 14 for ' 6 ' connected domain area, and is surrounded by 5 * 3 rectangle, so connected domain ' 6 ' meets the demands, and also namely the pixel in this connected domain is noise spot, is given up.
As seen from the above, in embodiments of the present invention, only need the connected domain parameter of buffer memory the first pixel column, can be by the connected domain parameter of the second pixel column and buffer memory be compared when the second pixel column is processed, find out the relation of the second pixel column and the first pixel column, always obtain the connected domain information of pending image.Therefore, utilize the method for the embodiment of the invention, can determine fast the connected domain in the pending image, thereby improved the real-time of definite connected domain.Owing to adopting the FPGA technology to realize the method for the embodiment of the invention, therefore the corresponding external devices of having saved reduces the area of circuit board, thereby has reduced cost simultaneously.
As shown in Figure 6, the image processing apparatus of the embodiment of the invention three comprises:
61, for connected domain parameter corresponding to the first pixel column of obtaining pending image, wherein, described connected domain parameter comprises row cache space and at least one connected domain structure;
62 is used for utilizing the second pixel column of described pending image to upgrade the connected domain parameter that described parameter acquiring unit is obtained, the connected domain parameter after obtaining to upgrade;
Processing
unit63, be used for judging whether described the second pixel column is last pixel column of described pending image, if last pixel column that described the second pixel column is not described pending image, control described parameter acquiring unit and described parameter updating block is carried out above-mentioned action, until last pixel column of the described pending image of described the second pixel behavior;
Connected
domain determining unit64 is used for according to the connected domain of being obtained connected domain parameter after last pixel column finished dealing with by described parameter updating block and determine described pending image.
With reference to the before description of embodiment of the method, if first pixel column of the described pending image of described the first pixel behavior, described
parameter acquiring unit61 comprises: the first pixel determination module, for bright spot pixel and the dim spot pixel of determining described first pixel column; The first processes pixel module, for first pixel column bright spot pixel of determining according to described the first pixel determination module and the distribution of dim spot pixel, determine the connected component labeling of described bright spot pixel, and the connected component labeling of described bright spot pixel is stored in memory location corresponding to bright spot pixel described in the described row memory space; The first structure update module is used for utilizing the coordinate parameters of the definite bright spot pixel of described the first pixel determination module to upgrade the connected domain structure that connected component labeling corresponding to described bright spot pixel points to.
Wherein, the distribution of described the first processes pixel module bright spot pixel and dim spot pixel in according to described the first pixel column specifically is used for when determining the connected component labeling of described bright spot pixel:
If the neighbor pixel on predetermined scanning sequency of the first bright spot pixel also is the bright spot pixel in described first pixel column, then described the first processes pixel module utilizes the connected component labeling of described neighbor pixel as the connected component labeling of described the first bright spot pixel; If the neighbor pixel on the predetermined scanning sequency of the first bright spot pixel is dim spot pixel or the neighbor pixel of nothing on predetermined scanning sequency in described first pixel column, then described the first processes pixel module adds 1 connected component labeling as described the first bright spot pixel with connected component labeling maximum in the described row cache space.
Concrete, in concrete the application, described the first structure update module specifically is used for: utilize the coordinate parameters of described the first bright spot pixel to upgrade the connected domain structure that connected component labeling corresponding to described the first bright spot pixel points to.
With reference to the before description of embodiment of the method, wherein said the first pixel column is not first pixel column of described pending image, and described
parameter acquiring unit61 comprises:
The second pixel determination module is for bright spot pixel and the dim spot pixel of determining described the second pixel column; The second processes pixel module, for the distribution of the second pixel column bright spot pixel of determining according to described the second pixel determination module and dim spot pixel and according to described connected domain parameter, determine the connected component labeling of bright spot pixel in described the second pixel column, and the connected component labeling of described bright spot pixel is stored in memory location corresponding to bright spot pixel described in the described row memory space; The second structure update module is used for utilizing the coordinate parameters of the definite described bright spot pixel of the second pixel determination module to upgrade the connected domain structure that connected component labeling corresponding to bright spot pixel described in the described connected domain parameter points to.
For the second bright spot pixel in described the second pixel column, when the pixel of described the second bright spot pixel in the first pixel column corresponding position is the dim spot pixel, the distribution of described the second processes pixel module bright spot pixel and dim spot pixel in the second pixel column of determining according to described the second pixel determination module and according to described connected domain parameter, when determining the connected component labeling of bright spot pixel in described the second pixel column, specifically be used for:
If the neighbor pixel on predetermined scanning sequency of the second bright spot pixel also is the bright spot pixel in described the second pixel column, then described the second processes pixel utilizes the connected component labeling of described neighbor pixel as the connected component labeling of described the second bright spot pixel; If the neighbor pixel on the predetermined scanning sequency of the second bright spot pixel is dim spot pixel or the neighbor pixel of nothing on predetermined scanning sequency in described the second pixel column, then described the second processes pixel adds 1 connected component labeling as described the second bright spot pixel with connected component labeling maximum in the described row cache space.
In concrete the application, also can comprise the connected domain link identification in each connected domain structure of described connected domain parameter.At this moment, the distribution of described the second processes pixel module bright spot pixel and dim spot pixel in the second pixel column of determining according to described the second pixel determination module and according to described connected domain parameter, when determining the connected component labeling of bright spot pixel in described the second pixel column, specifically be used for: according to the connected domain link identification in each connected domain structure of the distribution of described the second pixel column bright spot pixel and dim spot pixel and described connected domain parameter, determine the connected component labeling of bright spot pixel in described the second pixel column.
In the case, for the second bright spot pixel in described the second pixel column, when the pixel of described the second bright spot pixel in the first pixel column corresponding position was the bright spot pixel, described the second processes pixel module comprised:
Identifier acquisition module is used for obtaining described the second bright spot pixel in the first connected domain link identification of the corresponding connected domain structure of the connected component labeling of the pixel of the first pixel column corresponding position;
Judge module is used for judging that described the first connected domain link identification represents whether described the second bright spot pixel is linked to other connected domains in the corresponding connected domain of the pixel of the first pixel column corresponding position;
The first processing module represents that described the second bright spot pixel is not linked to other connected domains in the corresponding connected domain of the pixel of the first pixel column corresponding position if be used for described the first connected domain link identification:
If the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column also is the bright spot pixel, then utilize the connected component labeling of described neighbor pixel as the connected component labeling of described the second bright spot pixel, and described the first connected domain link identification is expressed as described the second bright spot pixel is linked to described neighbor pixel in the connected domain of the pixel of the first pixel column corresponding position connected domain;
If the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column is the dim spot pixel, then utilize described the second bright spot pixel at the connected component labeling of the pixel of the first pixel column corresponding position connected component labeling as described the second bright spot pixel;
The second processing module represents that described the second bright spot pixel is linked to other connected domains in the connected domain of the pixel of the first pixel column corresponding position if be used for described the first connected domain link identification:
If if the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column also equals the value of described the first connected domain link identification for the connected component labeling of bright spot pixel and described neighbor pixel or the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column is the dim spot pixel, the connected component labeling of described the second bright spot pixel is labeled as the value of described the first connected domain link identification;
If the neighbor pixel on predetermined scanning sequency of the second bright spot pixel in described the second pixel column also is not equal to the value of described the first connected domain link identification for the connected component labeling of bright spot pixel and described neighbor pixel, the connected component labeling of described the second bright spot pixel is labeled as the value of described the first connected domain link identification, and the connected domain link identification in the corresponding connected domain structure of described neighbor pixel is changed to the connected component labeling of described neighbor pixel;
Memory module is used for the connected component labeling of described bright spot pixel is stored in memory location corresponding to bright spot pixel described in the described row memory space.
Concrete, described the second structure parameter update module specifically is used for utilizing the coordinate parameters of described the second bright spot pixel to upgrade the connected domain structure that connected component labeling corresponding to bright spot pixel described in the described connected domain parameter points to.
Wherein, described the first structure parameter update module specifically is used for: utilize the abscissa of described bright spot pixel and abscissa summation parameter and the ordinate summation parameter that ordinate upgrades respectively described connected domain structure; If the abscissa of described bright spot pixel or ordinate respectively greater than the maximum abscissa value in the described connected domain structure or maximum ordinate value, then utilize the abscissa of described bright spot pixel or ordinate to upgrade maximum abscissa value or maximum ordinate value in the described connected domain structure; Utilize the abscissa of described bright spot pixel and ordinate to upgrade connected domain area parameters in the described connected domain structure.
Concrete, described the second structure parameter update module specifically is used for: utilize the abscissa of described bright spot pixel and abscissa summation parameter and the ordinate summation parameter that ordinate upgrades respectively described connected domain structure; If the abscissa of described bright spot pixel or ordinate respectively greater than the maximum abscissa value in the described connected domain structure or maximum ordinate value, then utilize the abscissa of described bright spot pixel or ordinate to upgrade maximum abscissa value or maximum ordinate value in the described connected domain structure; Utilize the abscissa of described bright spot pixel and ordinate to upgrade connected domain area parameters in the described connected domain structure.
In concrete application, described connected domain determining unit comprises:
The first determination module be used for to determine that connected domain link identification in described each connected domain structure of connected domain parameter after last pixel column is finished dealing with is zero connected domain structure; The second determination module, being positioned at preset range if be used for connected domain link identification that described the first determination module determines and be the connected domain area parameters of zero connected domain structure, then is that described connected domain link identification is that the zone that the pixel of zero connected domain structure forms is defined as connected domain with described label.
Wherein, the operation principle of embodiment of the invention device is seen the description with reference to preceding method embodiment.
As seen from the above, in embodiments of the present invention, only need the connected domain parameter of buffer memory the first pixel column, can be by the connected domain parameter of the second pixel column and buffer memory be compared when the second pixel column is processed, find out the relation of the second pixel column and the first pixel column, always obtain the connected domain information of pending image.Therefore, utilize the device of the embodiment of the invention, can determine fast the connected domain in the pending image, thereby improved the real-time of definite connected domain.
The method of the embodiment of the invention and device can be applicable in the digital multimedia technology, in intelligent projector.
One of ordinary skill in the art will appreciate that all or part of flow process that realizes in above-described embodiment method, to come the relevant hardware of instruction to finish by computer program, described program can be stored in the computer read/write memory medium, this program can comprise the flow process such as the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc.
The above; be the specific embodiment of the present invention only, but protection scope of the present invention is not limited to this, anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; can expect easily changing or replacing, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection range of described claim.