CN102737360B - Method for fast transforming full distance of binary image - Google Patents

Method for fast transforming full distance of binary image Download PDF

Info

Publication number
CN102737360B
CN102737360B CN201210205727.4A CN201210205727A CN102737360B CN 102737360 B CN102737360 B CN 102737360B CN 201210205727 A CN201210205727 A CN 201210205727A CN 102737360 B CN102737360 B CN 102737360B
Authority
CN
China
Prior art keywords
pixel
distance
nearest
background pixel
function
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201210205727.4A
Other languages
Chinese (zh)
Other versions
CN102737360A (en
Inventor
李均利
魏平
孙宇红
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CHENGDU RUIMING MEDICAL INFORMATION TECHNOLOGY Co Ltd
Sichuan Normal University
Original Assignee
CHENGDU RUIMING MEDICAL INFORMATION TECHNOLOGY Co Ltd
Sichuan Normal University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CHENGDU RUIMING MEDICAL INFORMATION TECHNOLOGY Co Ltd, Sichuan Normal University filed Critical CHENGDU RUIMING MEDICAL INFORMATION TECHNOLOGY Co Ltd
Priority to CN201210205727.4A priority Critical patent/CN102737360B/en
Publication of CN102737360A publication Critical patent/CN102737360A/en
Application granted granted Critical
Publication of CN102737360B publication Critical patent/CN102737360B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Processing (AREA)
  • Image Analysis (AREA)
  • Measurement Of Optical Distance (AREA)

Abstract

The embodiment of the invention provides a method for fast transforming a full distance of a binary image. The method comprises the following steps of: determining a first function and a second function; determining the nearest background pixel range of a first pixel; searching a background pixel nearest to the first pixel from each row of the nearest background pixel range by using the first function, or searching the background pixel nearest to the first pixel from each column of the nearest background pixel range by using the second function; and determining a first background pixel nearest to the first pixel from the searched background pixel nearest to the first pixel, and calculating a first full distance between the first background pixel and the first pixel, wherein the first full distance is used as the full distance transforming value of the first pixel. By the method provided by the embodiment of the invention, a distance of an image can be quickly and accurately transformed.

Description

The method of the quick complete range conversion of bianry image
Technical field
The present invention relates to image processing field, in particular, relate to the method for the complete range conversion of quick bianry image.
Background technology
Range conversion is that the digital picture after range conversion has good rotation, translation and constant rate, thereby it all plays an important role in image processing techniques every field to digital picture important pretreatment operation.
Bianry image is carried out to range conversion just to be referred to the pixel value of each pixel in bianry image is transformed into from the process of the distance of its nearest background pixel and this pixel.Pixel in bianry image can be divided into background pixel (pixel value is 0) and object pixel (pixel value is 1) two classes, bianry image is carried out to range conversion and exactly background pixel and object pixel are carried out to range conversion.
Can utilize Quasi Euclidean Distance Transform method and complete Euclidean Distance Transform method to carry out range conversion to bianry image, the basic thought of Quasi Euclidean Distance Transform method is: utilize an approximate template computing of commonly using in image processing, calculating moves to the bee-line of certain point in figure from figure, in template the distance value of sign normally Euclidean distance round approximate value, simultaneously template also can not be all the time moves along the normal orientation of boundary profile, therefore these class methods must be to have error, as city block distance, chessboard distance, chamfering distance etc.
The basic thought of Euclidean Distance Transform method is completely: need to calculate respectively the distance of each background pixel and object pixel, cause working time longer.
To sum up, the method for prior art range conversion has following shortcoming: the first, and there is error and be not suitable for the strict image of accuracy requirement is processed, as medical image; The second, working time is longer.
Summary of the invention
In view of this, the invention provides the method for the complete range conversion of quick bianry image, there is error and is not suitable for the problem to the strict image of accuracy requirement is processed and operation time is long in the method for calculating range conversion to overcome in prior art.
For achieving the above object, the invention provides following technical scheme:
The method of the complete range conversion of a kind of quick bianry image, described bianry image is of a size of m * n, comprise: determine the first function or the second function, described the first function is for determining the position of the background pixel that capable middle distance the first pixel of i is nearest, and described the second function is for the position of the nearest background pixel of the first pixel described in definite j row middle distance, wherein, 1≤i≤m, 1≤j≤n, i and j are integer, and described method also comprises:
According to the complete distance of the second object pixel and described the first pixel, and described the second object pixel with from the complete distance of its nearest background pixel, determine the nearest background pixel scope of described the first pixel;
Utilize described the first function nearest background pixel of the first pixel described in detection range in every row of described nearest background pixel scope respectively, or utilize described the second function nearest background pixel of the first pixel described in detection range in every row of described nearest background pixel scope respectively;
From the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate the first complete distance of described the first background pixel and described the first pixel, and the complete range conversion value using the described first complete distance as described the first pixel.
Preferably, described according to the complete distance of the second object pixel and described the first pixel, and described the second object pixel with from the complete distance of its nearest background pixel, determine that the nearest background pixel scope of described the first pixel specifically comprises:
Calculate described the second object pixel and complete in r apart between its nearest background pixel 1;
Determine the complete in r of described the first pixel and described the second object pixel 2;
Described nearest background pixel scope is the center of circle for take described the first pixel, with r 1+ r 2round O for radius 1the region that surrounds of circumscribed square;
Or described nearest background pixel scope is the center of circle for take described the second object pixel, with r 1round O for radius 2in connect square with described round O 1the annular region that surrounds of circumscribed square;
Or described nearest background pixel scope is the center of circle for take described the first pixel, with | r 1-r 2| be the round O of radius 3in connect square with described round O 1the annular region that surrounds of circumscribed square.
Preferably, the x that described the first pixel is positioned at described bianry image is capable, y row, with (x, y) represent the position of described the first pixel in described bianry image, take (x, y) as separation, by capable left side and the right side of being divided into of x, y row are divided into above and below, wherein, 1≤x≤m, 1≤y≤n, determines that the method for the first function specifically comprises:
Be identified for calculating the first pixel (x described in the distance of the capable left side of described bianry image x, y) the first subfunction of nearest background pixel place columns, and for calculating the second subfunction of the nearest background pixel place columns of described the first pixel (x, y) of described bianry image x capable right side distance;
According to described the first subfunction and described the second subfunction, determine described the first function;
Described definite the second function specifically comprises:
Be identified for calculating described the first pixel (x of the described bianry image y side of listing distance, y) the 3rd subfunction of nearest background pixel place line number, and for calculating the 4th subfunction of the nearest background pixel place line number of the first pixel (x, y) described in the distance of described bianry image y row below;
According to described the 3rd subfunction and described the 4th subfunction, determine described the second function.
Preferably, described the first subfunction is specially L:
L : L [ x , y ] = y I ( x , y ) = 0 L [ x , y - 1 ] I ( x , y ) = 1 ;
If I (x, y)=1 and y=1, so L (x, y)=-Maxlable;
Described the second subfunction is specially R:
R : R [ x , y ] = y I ( x , y ) = 0 R [ x , y + 1 ] I ( x , y ) = 1 ;
If I (x, y)=1 and y=n, R[x so, y]=Maxlable;
According to described the first subfunction and definite described the first function of described the second subfunction, be specially SZ:
SZ : SZ [ x , y ] = L [ x , y ] y - L [ x , y ] < R [ x , y ] - y R [ x , y ] y - L [ x , y ] &GreaterEqual; R [ x , y ] - y ;
Described the 3rd subfunction is specially T:
T : T [ x , y ] = x I ( x , y ) = 0 T [ x - 1 , y ] I ( x , y ) = 1 ;
If I (x, y)=1 and x=1, T[x so, y]=-Maxlable;
Described the 4th subfunction is specially D:
D : D [ x , y ] = x I ( x , y ) = 0 D [ x + 1 , y ] I ( x , y ) = 1 ;
If I (x, y)=1 and x=m, D[x so, y]=Maxlable;
According to described the 3rd subfunction and definite described the second function of described the 4th subfunction, be specially ZS:
ZS : ZS [ x , y ] = T [ x , y ] x - D [ x , y ] < T [ x , y ] - x D [ x , y ] x - D [ x , y ] &GreaterEqual; T [ x , y ] - x ;
Wherein, I (x, y)=1 is expressed as object pixel, and I (x, y)=0 is expressed as background pixel, and described Maxlable is default maximum mark value.
Preferably, describedly from the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate described the first background pixel and described the first pixel first completely distance specifically comprise:
Utilize formula min{ ((y-SZ[i, y]) 2+ (i-x) 2), the nearest background pixel scope of i ∈, determines first background pixel nearest with described the first pixel distance; Utilize formula
Figure BDA00001791402600042
calculate the described first complete distance;
Or, utilize formula min{ (x-ZS[x, j]) 2+ (j-y) 2, wherein the nearest background pixel scope of j ∈, determines first background pixel nearest with described the first pixel distance, recycling formula
Figure BDA00001791402600043
calculate the described first complete distance.
Preferably, before the nearest background pixel scope of described definite described the first pixel, also comprise:
Calculate (y-SZ[x, y]) 2;
(y-SZ[x, y]) 2be not more than in 1 situation, described first completely distance be (y-SZ[x, y]) 2, (y-SZ[x, y]) 2be greater than in 1 situation, carry out the described operation of determining the nearest background pixel scope of described the first pixel.
Or,
Calculate (x-ZS[x, y]) 2;
(x-ZS[x, y]) 2be not more than in 1 situation described first completely distance be (x-ZS[x, y]) 2, (x-ZS[x, y]) 2be greater than in 1 situation, carry out the described operation of determining the nearest background pixel scope of described the first pixel.
The method of the complete range conversion of a kind of quick bianry image, described bianry image is of a size of m * n, comprise: determine the first function and the second function, described the first function is for determining the position of the background pixel that capable middle distance the first pixel of i is nearest, and described the second function is for the position of the nearest background pixel of the first pixel described in definite j row middle distance, wherein, 1≤i≤m, 1≤j≤n, i and j are integer, and described method also comprises:
According to the complete distance of the second object pixel and described the first pixel, and described the second object pixel with from the distance of its nearest background pixel, determine the nearest background pixel scope of described the first pixel, and described nearest background pixel scope is divided into the first son background pixel range set and the nearest background pixel range set of the second son recently according to preset rules, described the first son recently background pixel range set comprises at least one first son background pixel scope recently, line number in the nearest background pixel scope of described at least one height is not more than columns, described the second son recently background pixel range set comprises at least one second son background pixel scope recently, line number in the nearest background pixel scope of described at least one the second son is greater than columns,
Utilize described the first function at the nearest nearest background pixel of the first pixel described in detection range in every row of background pixel range set of described the first son, utilize the second function at described the second son nearest background pixel of the first pixel described in detection range in every row of background pixel range set recently;
From the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate the first complete distance of described the first background pixel and described the first pixel, and the complete range conversion value using the described first complete distance as described the first pixel.
The method of the complete range conversion of a kind of quick bianry image, described bianry image is of a size of m * n, comprise: determine the first function and the second function, described the first function is for determining the position of the background pixel that capable middle distance the first pixel of i is nearest, and described the second function is for the position of the nearest background pixel of the first pixel described in definite j row middle distance, wherein, 1≤i≤m, 1≤j≤n, i and j are integer, and described method also comprises:
According to the complete distance of the second object pixel and described the first pixel, and described the second object pixel with from the distance of its nearest background pixel, determine the nearest background pixel scope of described the first pixel;
Utilize described the first function and described the second function nearest background pixel of the first pixel described in detection range in every layer of described nearest background pixel scope respectively, every layer of foursquare border referring to centered by described the first pixel or described the second object pixel of described nearest background pixel scope;
From the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate the first complete distance of described the first background pixel and described the first pixel, and the complete range conversion value using the described first complete distance as described the first pixel.
Preferably, every layer of foursquare border referring to centered by described the first pixel of described nearest background pixel scope, described utilize described the first function and described the second function respectively in every layer of described nearest background pixel scope described in detection range the nearest background pixel of the first pixel specifically comprise:
Utilize described the first function and described the second function from r xlayer starts search until at r x+ k layer searches the nearest background pixel of described the first pixel of distance, described r xlayer is nearest one deck of the first pixel described in distance within the scope of described nearest background pixel, k=0,1,2 ... q-1, a total q layer within the scope of described nearest background pixel;
From at described r xdescribed in the distance that+k layer searches out, in the nearest background pixel of the first pixel, determine described r xthe nearest background pixel of the first pixel described in+k layer middle distance, and record described r xthe nearest background pixel of the first pixel and the complete square distance value of described the first pixel described in+k layer middle distance
Relatively
Figure BDA00001791402600062
with (r x+ k+1) 2+ (r x+ k) 2, when
Figure BDA00001791402600063
time, stop search, when time, continue the lower one deck of search, until search for complete r x+ q-1 layer finishes.
Preferably, describedly from the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate described the first background pixel and described the first pixel first completely distance specifically comprise:
According to the nearest background pixel of the first pixel described in the distance of record and the complete square distance value of described the first pixel, determine the first complete square distance value of first background pixel nearest with described the first pixel distance and described the first pixel;
The described first complete square distance value evolution is obtained to the described first complete distance.
Known via above-mentioned technical scheme, the method of the complete range conversion of quick bianry image that the employing embodiment of the present invention provides, by the first function or the second function, search for the nearest background pixel of the first pixel described in the nearest background pixel of every row middle distance the first pixel or every row middle distance, after searching the first nearest background pixel of distance the first pixel, calculate again the first complete distance of the first background pixel and the first pixel, rather than search out the complete distance of just calculating this background pixel and the first pixel after a background pixel, thereby improved computing velocity, further, when search background pixel, not to search in whole bianry image, but after the nearest background pixel scope of the first pixel of determining, within the scope of nearest background pixel, search for the nearest background pixel of the first pixel, improved search speed, further improved computing velocity, and in whole search procedure and computation process, all do not carry out approximate processing, so the distance accuracy calculating is high.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, to the accompanying drawing of required use in embodiment or description of the Prior Art be briefly described below, apparently, accompanying drawing in the following describes is only embodiments of the invention, for those of ordinary skills, do not paying under the prerequisite of creative work, other accompanying drawing can also be provided according to the accompanying drawing providing.
Fig. 1 is the process flow diagram of the method for the complete range conversion of the quick bianry image of the disclosed the first of the embodiment of the present invention;
Fig. 2 is the nearest background pixel scope of the first schematic diagram;
Fig. 3 is the nearest background pixel scope of the second schematic diagram;
Fig. 4 is the third nearest background pixel scope schematic diagram;
The schematic flow sheet of the method for the complete range conversion of the quick bianry image of the second that Fig. 5 provides for the embodiment of the present invention;
Fig. 6 is the division schematic diagram of nearest background pixel;
The schematic flow sheet of the method for the complete range conversion of the third quick bianry image that Fig. 7 provides for the embodiment of the present invention;
Fig. 8 is for using function LR[x, y] and TD[x, y] search for the schematic diagram of nearest background pixel;
Fig. 9 is for adopting contour searching method to search for the schematic diagram of nearest background pixel;
Figure 10 is proof procedure figure.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Embodiment based in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
X in (x, y) in all embodiment of the present invention and [x, y] represents the row in bianry image, does not represent horizontal ordinate, and the y in (x, y) and [x, y] represents the row in bianry image, does not represent ordinate.Pixel (x for example 0, y 0) represent the x of this pixel in bianry image 0oK, y 0row.
Embodiment mono-
Referring to accompanying drawing 1, is the process flow diagram of the method for the complete range conversion of the quick bianry image of the disclosed the first of the embodiment of the present invention, and the method can comprise:
Step S100: determine the first function or the second function;
The first function is for determining the position of the background pixel that capable middle distance the first pixel of i is nearest, and the second function is used for the position of the nearest background pixel of definite j row middle distance the first pixel, wherein, 1≤i≤m, 1≤j≤n, i and j are integer.
The first pixel can be to be arranged in the arbitrary pixel of bianry image, just just claim that in order to narrate conveniently arbitrary pixel is the first pixel.
When the first pixel is background pixel, the nearest background pixel of distance the first pixel is exactly itself.
Suppose that the first pixel is positioned at the x of bianry image capable, y row, represent the position of the first pixel in bianry image with (x, y), take (x, y) as separation, by capable left side and the right side of being divided into of x, y are listed as and are divided into above and below.
The method of determining the first function specifically comprises:
Be identified for calculating the capable left side of bianry image x distance the first pixel (x, y) the first subfunction of nearest background pixel place columns, and for calculating the second subfunction of the nearest background pixel place columns of the capable right side of bianry image x distance the first pixel (x, y).Wherein, 1≤x≤m, 1≤y≤n.
According to the first subfunction and the second subfunction, determine the first function.
Determine that the second function specifically comprises: be identified for calculating the bianry image y side of listing distance the first pixel (x, y) the 3rd subfunction of nearest background pixel place line number, and for calculating the 4th subfunction of the nearest background pixel place line number of bianry image y row below distance the first pixel (x, y).
According to the 3rd subfunction and the 4th subfunction, determine the second function.
Concrete, determine that the first method of the first function and the second function is specially:
Described the first subfunction is specially L[x, y]:
L [ x , y ] = y I ( x , y ) = 0 L [ x , y - 1 ] I ( x , y ) = 1 ;
If I (x, y)=1 and y=1, so L (x, y)=-Maxlable;
Described the second subfunction is specially R[x, y]:
R [ x , y ] = y I ( x , y ) = 0 R [ x , y + 1 ] I ( x , y ) = 1 ;
If I (x, y)=1 and y=n, R[x so, y]=Maxlable;
According to described the first subfunction and definite described the first function of described the second subfunction, be specially SZ[x, y]:
SZ [ x , y ] = L [ x , y ] y - L [ x , y ] < R [ x , y ] - y R [ x , y ] y - L [ x , y ] &GreaterEqual; R [ x , y ] - y ;
Described the 3rd subfunction is specially T[x, y]:
T [ x , y ] = x I ( x , y ) = 0 T [ x - 1 , y ] I ( x , y ) = 1 ;
If I (x, y)=1 and x=1, T[x so, y]=-Maxlable;
Described the 4th subfunction is specially D[x, y]:
D [ x , y ] = x I ( x , y ) = 0 D [ x + 1 , y ] I ( x , y ) = 1 ;
If I (x, y)=1 and x=m, D[x so, y]=Maxlable;
According to described the 3rd subfunction and definite described the second function of described the 4th subfunction, be specially ZS[x, y]:
ZS [ x , y ] = T [ x , y ] x - D [ x , y ] < T [ x , y ] - x D [ x , y ] x - D [ x , y ] &GreaterEqual; T [ x , y ] - x ;
The second method of determining the first function and the second function is specially:
Described the first subfunction is specially L[x, y]:
L [ x , y ] = y I ( x , y ) = 0 L [ x , y - 1 ] I ( x , y ) = 1 ;
If I (x, y)=1 and y=1, so L (x, y)=-Maxlable;
Described the second subfunction is specially R[x, y]:
R [ x , y ] = y I ( x , y ) = 0 R [ x , y + 1 ] I ( x , y ) = 1 ;
If I (x, y)=1 and y=n, R[x so, y]=Maxlable;
According to described the first subfunction and definite described the first function of described the second subfunction, be specially LR[x, y]:
LR [ x , y ] = ( y - L [ x , y ] ) 2 y - L [ x , y ] < R [ x , y ] - y ( R [ x , y ] - y ) 2 y - L [ x , y ] &GreaterEqual; R [ x , y ] - y ;
Described the 3rd subfunction is specially T[x, y]:
T [ x , y ] = x I ( x , y ) = 0 T [ x - 1 , y ] I ( x , y ) = 1 ;
If I (x, y)=1 and x=1, T[x so, y]=-Maxlable;
Described the 4th subfunction is specially D[x, y]:
D [ x , y ] = x I ( x , y ) = 0 D [ x + 1 , y ] I ( x , y ) = 1 ;
If I (x, y)=1 and x=m, D[x so, y]=Maxlable;
According to described the 3rd subfunction and definite described the second function of described the 4th subfunction, be specially TD[x, y]:
TD [ x , y ] = ( x - T [ x , y ] ) 2 x - T [ x , y ] < D [ x , y ] - x ( D [ x , y ] - x ) 2 x - T [ x , y ] &GreaterEqual; D [ x , y ] - x .
Wherein, I (x, y)=1 is expressed as object pixel, and I (x, y)=0 is expressed as background pixel, and Maxlable is default maximum mark value, wherein, Maxlable = ( 1 + 2 ) max ( m , n ) .
Step S100 is a pre-treatment step, needn't all carry out at every turn.
In order to improve computing velocity, after step S100, before step S101, can also comprise:
Calculate LR[x, y];
At LR[x, y] be not more than in 1 situation, described first completely distance be LR[x, y], at LR[x, y] be greater than in 1 situation, enter step S101.
Or,
Calculate TD[x, y];
At TD[x, y] be not more than in 1 situation described first completely distance be TD[x, y], at TD[x, y] be greater than in 1 situation, enter step S101.
If LR (x, y)=0 or TD[x, y]=0 explanation the first pixel (x, y) is background pixel.If there is background pixel in level 2 neighborhoods of LR (x, y)=1 explanation the first pixel (x, y), the first complete distance is 1, if TD[x, y]=1 explanation the first pixel (x, y) in vertical 2 neighborhoods, have background pixel, the first complete distance is 1.
After step S100, before step S101, can also comprise:
Calculate (y-ZS[x, y]) 2;
(y-SZ[x, y]) 2be not more than in 1 situation, described first completely distance be (y-SZ[x, y]) 2, (y-SZ[x, y]) 2be greater than in 1 situation, carry out the described operation of determining the nearest background pixel scope of described the first pixel.
Or,
Calculate (x-ZS[x, y]) 2;
(x-ZS[x, y]) 2be not more than in 1 situation described first completely distance be (x-ZS[x, y]) 2, (x-ZS[x, y]) 2be greater than in 1 situation, carry out the described operation of determining the nearest background pixel scope of described the first pixel.
Step S101: according to the complete distance of the second object pixel and the first pixel, and the second object pixel with from the complete distance of its nearest background pixel, determine the nearest background pixel scope of the first pixel;
A known object pixel and a background pixel, if the complete distance of point-to-point transmission is r, nearest apart from this object pixel so background pixel point one fixes on take this object pixel as the center of circle, r is in the circular scope of radius, if each object pixel is arranged to a rational search radius, so just hunting zone can be narrowed down in the scope of a circle by picture in its entirety.
The second object pixel is arbitrary object pixel in bianry image, and wherein, this arbitrary object pixel is known to its nearest background pixel and the complete distance between it.
Determine the process flow diagram of hunting zone, concrete steps can comprise:
Calculate the second object pixel O 2with apart from its nearest background pixel B 0between complete in r 1;
Calculate completely apart from r 1can calculate by method of the prior art.Distance the second object pixel O 2nearest background pixel may have a plurality of, according to actual conditions, only gets one of them background pixel B 0.
Determine the first pixel O 1with the second object pixel O 2complete in r 2;
Preferably, the first pixel O 1be positioned at the second object pixel O 2vertical neighbours territory in, such the first pixel and the second object pixel complete in r 2=1.Certainly, the position of the first pixel is not restricted in vertical four fields of the second object pixel, and the particular location of the first pixel does not affect the realization of the embodiment of the present invention, so the particular location of the first pixel is not specifically limited.If the first pixel, not in the vertical neighbours territory of the second object pixel, because the coordinate of the second object pixel and the first pixel is known, can utilize Pythagorean theorem to calculate complete distance between the two so.
According to known the first pixel of triangle length of side relation theorem and background pixel B 0between distance one fix on | r 1-r 2| between with r 1+ r 2between.
According to complete apart from r 2and completely apart from r 1determine the nearest background pixel scope of the first pixel.
Referring to Fig. 2, be the nearest background pixel scope of the first schematic diagram, the round O in figure 1for take the first pixel as the center of circle, with r 1+ r 2for the circle of radius, because digital picture has discreteness, determine that to take accurately the border circular areas that circular arc is border be very consuming time, so background pixel scope is circle O recently 1the region that surrounds of circumscribed square.
When search radius is little, it is feasible utilizing above-mentioned search strategy to dwindle hunting zone, but for object pixel in more and concentrated situation, search radius is just larger, and now this dominance of strategies is just not obvious.
Due to background pixel B 0with the second object pixel O 2distance be r 1, background pixel B so 0obviously with the second object pixel O 2for the center of circle, r 1in circular scope for radius, simultaneously due to background pixel B 0for first object is as O 1background pixel, means with the second object pixel O recently 2for the center of circle, r 1for there is not background pixel in the circular scope inside of radius.
Referring to Fig. 3, be the nearest background pixel scope of the second schematic diagram, background pixel scope is with described the second object pixel O recently 2for the center of circle, with r 1round O for radius 2in connect square with circle O 1the region that surrounds of circumscribed square;
Referring to Fig. 4, be the third nearest background pixel scope schematic diagram, background pixel scope is circle O recently 1circumscribed square with circle O 3in connect the annular region that surrounds of square.
Background pixel one fixes on described the first pixel O recently 1for the center of circle, with | r 1-r 2| be the round O of radius 3with described round O 1in the annular region forming, in order to reduce the time of determining annular region, background pixel scope is circle O recently 1circumscribed square with circle O 3the region that surrounds of inscribe square.
If the first pixel is positioned at the marginal position of bianry image, the initial nearest background pixel scope of determining may some exceed bianry image, now can get the common factor of definite initial background pixel scope recently and bianry image as nearest background pixel scope.
Step S102: utilize the first function nearest background pixel of detection range the first pixel in every row of nearest background pixel scope respectively, or utilize the second function nearest background pixel of detection range the first pixel in every row of nearest background pixel scope respectively;
The position of supposing the first pixel is O (x, y), in background pixel scope, a total M is capable recently, N row, can utilize the first function nearest background pixel of detection range the first pixel in every row of nearest background pixel scope respectively, be searching for of a line a line, if all have powerful connections pixel in every row, will search so at least M distance the first pixel O (x, y) nearest background pixel, because may have two background pixels and the first pixel O (x in a line, y) distance is identical, if only have a distance the first pixel O (x in every row, y) nearest background pixel, at this moment by the first function, will search M distance the first pixel O (x, y) nearest background pixel, while there is the nearest background pixel of two distance the first pixels in a line, can select one of them background pixel as background pixel nearest in this line.
Utilize the second function nearest background pixel of detection range the first pixel in every row of nearest background pixel scope respectively, one be listed as search for, if all have powerful connections pixel in every row, will search so at least N distance the first pixel O (x, y) nearest background pixel, because may have two background pixels and the first pixel O (x in row, y) distance is identical, if only have a distance the first pixel O (x in every row, y) nearest background pixel, at this moment by the second function, will search N distance the first pixel O (x, y) nearest background pixel, while there is the nearest background pixel of two distance the first pixels in row, can select one of them background pixel as background pixel nearest in these row.
Utilize the first function nearest background pixel of detection range the first pixel in every row of nearest background pixel scope respectively, and utilize the second function nearest background pixel of detection range the first pixel in every row of nearest background pixel scope respectively, the effect that these two steps reach is identical, so only need a function to search element in nearest background pixel scope.
Step S103: determine first background pixel nearest with the first pixel distance from the nearest background pixel of distance the first pixel of searching out, calculate the first complete distance of the first background pixel and the first pixel, and the complete range conversion value using this first complete distance as the first pixel.
Suppose that the position of the first pixel in bianry image, for (x, y), at the first function is:
SZ [ x , y ] = L [ x , y ] y - L [ x , y ] < R [ x , y ] - y R [ x , y ] y - L [ x , y ] &GreaterEqual; R [ x , y ] - y Situation under, step S103 specifically comprises:
Utilize formula min{ ((y-SZ[i, y]) 2+ (i-x) 2), the nearest background pixel scope of i ∈, determines first background pixel nearest with the first pixel distance, recycling formula:
Figure BDA00001791402600132
calculate the first complete distance.
At the first function, be LR [ x , y ] = ( y - L [ x , y ] ) 2 y - L [ x , y ] < R [ x , y ] - y ( R [ x , y ] - y ) 2 y - L [ x , y ] &GreaterEqual; R [ x , y ] - y Situation under, step S103 specifically comprises: utilize formula min{ (LR[i, y]+(i-x) 2), wherein the nearest background pixel scope of i ∈, finds out the first background pixel nearest with the first pixel O (x, y) in nearest background pixel scope, recycling formula
Figure BDA00001791402600134
calculate the first complete distance.
Suppose that the position of above-mentioned arbitrary pixel in bianry image, for (x, y), at the second function is ZS [ x , y ] = T [ x , y ] x - D [ x , y ] < T [ x , y ] - x D [ x , y ] x - D [ x , y ] &GreaterEqual; T [ x , y ] - x Situation under, step S103 specifically comprises:
Utilize formula min{ (x-ZS[x, j]) 2+ (j-y) 2, the nearest background pixel scope of j ∈, determines first background pixel nearest with the first pixel distance, recycling formula
Figure BDA00001791402600142
calculate the first complete distance.
At the second function, be TD [ x , y ] = ( x - T [ x , y ] ) 2 x - T [ x , y ] < D [ x , y ] - x ( D [ x , y ] - x ) 2 x - T [ x , y ] &GreaterEqual; D [ x , y ] - x Situation under, step S103 specifically comprises: utilize formula min{ (TD[x, j]+(j-y) 2, wherein the nearest background pixel scope of j ∈, finds out the first background pixel nearest with the first pixel O (x, y) in bianry image, recycling formula
Figure BDA00001791402600144
calculate the first complete distance.
Preferably, calculate the range conversion of a width bianry image and (suppose that bianry image is of a size of m * n, and m >=1, n >=1), first calculate in the first row (1,1) complete range conversion, then calculate the complete range conversion of (1,2), according to order from left to right, be calculated to successively (1, n), the complete range conversion of calculating again (2,1) in the second row, is calculated to (2 from left to right successively, n), namely according to the complete range conversion of each pixel in order computation bianry image from top to bottom from left to right.
The method of the complete range conversion of quick bianry image that the employing embodiment of the present invention provides, by the first function or the second function, search for the nearest background pixel of the first pixel described in the nearest background pixel of every row middle distance the first pixel or every row middle distance, after searching the first nearest background pixel of distance the first pixel, calculate again the first complete distance of the first background pixel and the first pixel, rather than search out the complete distance of just calculating this background pixel and the first pixel after a background pixel, thereby improved computing velocity, further, when search background pixel, not to search in whole bianry image, but after the nearest background pixel scope of the first pixel of determining, within the scope of nearest background pixel, search for the nearest background pixel of the first pixel, improved search speed, further improved computing velocity, and in whole search procedure and computation process, all do not carry out approximate processing, so the distance accuracy calculating is high.
Embodiment bis-
Refer to Fig. 5, the schematic flow sheet of the method for the complete range conversion of the quick bianry image of the second providing for the embodiment of the present invention, the method can comprise:
Step S501: determine the first function and the second function;
Step S501 is identical with the deterministic process of step S 100.Step S501 is a pre-treatment step, needn't all carry out at every turn.
In order to improve computing velocity, after step S501, before step S502, can also comprise:
Calculate LR[x, y] and TD[x, y];
At LR[x, y] or TD[x, y] be not more than in 1 situation, described first completely distance be min{LR[x, y], TD[x, y], at LR[x, y] and TD[x, y] be all greater than in 1 situation, enter step S602.
If LR (x, y)=0 or TD[x, y]=0 explanation the first pixel (x, y) is background pixel.If there is background pixel in level 2 neighborhoods of LR (x, y)=1 explanation the first pixel (x, y), the first complete distance is 1, if TD[x, y]=1 explanation the first pixel (x, y) in vertical 2 neighborhoods, have background pixel, the first complete distance is 1.
Step S502: according to the complete distance of the second object pixel and the first pixel, and second object pixel with from the distance of its nearest background pixel, determine the nearest background pixel scope of the first pixel, and nearest background pixel scope is divided into the first son background pixel range set and the nearest background pixel range set of the second son recently according to preset rules, the first son recently background pixel range set comprises at least one first son background pixel scope recently, line number in the nearest background pixel scope of described at least one height is not more than columns, the second son recently background pixel range set comprises at least one second son background pixel scope recently, line number in the nearest background pixel scope of described at least one the second son is greater than columns,
The nearest background pixel scope of nearest background pixel scope as shown in Fig. 3 or Fig. 4, the interior line segment that connects a foursquare opposite side is extended to the border of circumscribed square and intersected, here the nearest background pixel scope of the second of take is divided as example, as shown in Figure 6, for the division schematic diagram of nearest background pixel, dot-and-dash line is circle O 2inside connect the extended line of a square opposite side, this opposite side is divided into four nearest background pixel scopes of son up and down by nearest background pixel scope, be referred to as upper area, lower zone, left region and right-hand region, obviously line number is less than columns in region and lower zone up, in left region and right-hand region midrange, is less than line number.Certainly, also can use circle O 2the extended line that inside connects another opposite side of square, is divided into four regions up and down by nearest background pixel scope.
Preset rules refers to the interior line segment that connects a foursquare opposite side extended to the border of circumscribed square and intersected, and this opposite side is divided into four nearest background pixel scopes of son up and down by nearest background pixel scope.
The first son recently background pixel range set comprises: upper area and lower zone; The second son recently background pixel range set comprises: left region and right-hand region.
Step S503: utilize the first function nearest background pixel of detection range the first pixel in every row of the nearest background pixel range set of the first son, utilize the second function nearest background pixel of detection range the first pixel in every row of the nearest background pixel range set of the second son;
When the line number of the nearest background pixel scope of son is not more than columns, utilize the first function to search for, search time used is few, when the line number of the nearest background pixel scope of son is greater than columns, utilizes the second function to search for, and search time used is few.
Step S504: determine first background pixel nearest with the first pixel distance from the nearest background pixel of distance the first pixel of searching out, calculate the first complete distance of the first background pixel and the first pixel, and the complete range conversion value using this first complete distance as the first pixel.
Adopt the embodiment of the present invention, due to nearest background pixel scope is divided according to pre-defined rule, because the first sub line number of background pixel range set is recently not more than columns, utilize the first function nearest background pixel of detection range the first pixel in every row of the nearest background pixel range set of the first son, because the second sub line number of background pixel range set is recently greater than columns, utilize the second function nearest background pixel of detection range the first pixel in every row of the nearest background pixel range set of the second son, more accelerate search speed, thereby improved computing velocity.
Embodiment tri-
Refer to Fig. 7, the schematic flow sheet of the method for the complete range conversion of the third quick bianry image providing for the embodiment of the present invention, the method can comprise:
Step S701: determine the first function and the second function;
The method of determining described the first function specifically comprises:
The first function is for determining the position of the background pixel that capable middle distance the first pixel of i is nearest, and the second function is used for the position of the nearest background pixel of definite j row middle distance the first pixel, wherein, 1≤i≤m, 1≤j≤n, i and j are integer.
Step S701 is identical with the deterministic process of step S100.
Step S701 is a pre-treatment step, needn't all carry out at every turn.
In order to improve computing velocity, after step S701, before step S702, can also comprise:
Calculate LR[x, y] and TD[x, y];
At LR[x, y] or TD[x, y] be not more than in 1 situation, described first completely distance be min{LR[x, y], TD[x, y], at LR[x, y] and TD[x, y] be all greater than in 1 situation, enter step S802.
If LR (x, y)=0 or TD[x, y]=0 explanation the first pixel (x, y) is background pixel.If there is background pixel in level 2 neighborhoods of LR (x, y)=1 explanation the first pixel (x, y), the first complete distance is 1, if TD[x, y]=1 explanation the first pixel (x, y) in vertical 2 neighborhoods, have background pixel, the first complete distance is 1.
Take the position of the second object pixel describes for example as (1,1):
Calculate LR[1,1] and TD[1,1];
At LR[1,1] or TD[1,1] be not more than in 1 situation r 1=min{LR[1,1], TD[1,1];
At LR[1,1] and TD[1,1] be all greater than in 1 situation, enter step S802.
Step S702: according to the complete distance of the second object pixel and the first pixel, and the second object pixel with from the distance of its nearest background pixel, determine the nearest background pixel scope of the first pixel;
Step S703: utilize the first function and the second function nearest background pixel of detection range the first pixel in every layer of nearest background pixel scope respectively;
Every layer of foursquare border referring to centered by described the first pixel or described the second object pixel of described nearest background pixel scope.
Concrete, utilize the first function and the second function from r xlayer starts search until at r x+ k layer searches the nearest background pixel of distance the first pixel, r xlayer is nearest one deck of distance the first pixel within the scope of nearest background pixel, k=0,1,2 ... q-1, a total q layer within the scope of nearest background pixel, from r xlayer starts search until at r x+ k layer refers to first searches for r xlayer, next searches for r x+ 1 layer, again search for r x+ 2 layers, until search r x+ k layer;
From at r xin the nearest background pixel of distance the first pixel that+k layer searches out, determine r xthe background pixel that+k layer middle distance the first pixel is nearest, and record r xthe complete square distance value of the background pixel that the first pixel of distance described in+k layer is nearest and the first pixel
Figure BDA00001791402600171
Relatively
Figure BDA00001791402600172
with (r x+ k+1) 2+ (r x+ k) 2, when
Figure BDA00001791402600173
time, stop search, when
Figure BDA00001791402600174
time, continue the lower one deck of search, until search for complete r x+ q-1 layer finishes.
The nearest background pixel scope of take is as shown in Figure 4 example, and to step, S703 describes, and every one deck of background pixel is all with O recently 1centered by foursquare border, half of this square length of side is exactly the number of plies of this layer, the method that the thought that adopts contour search is searched within the scope of background pixel recently for from
Figure BDA00001791402600175
layer (half of the inscribed square length of side) starts, and successively scanning is until r 1+ r 2layer (half of the circle circumscribed square length of side) finishes, and supposes scanning r xlayer, wherein referring to Fig. 8, be to use function LR[x, y] and TD[x, y] search for the schematic diagram of nearest background pixel, for r xpixel on layer is divided into R along x, y direction respectively 1(using in the drawings the region of dotted line), R 2(region surrounding with dot-and-dash line in the drawings), R 3(region surrounding is realized in left side in the drawings) and R 4(region surrounding is realized on right side in the drawings) four groups, easily knows that the element in these four groups is respectively (x-r x) OK, (x+r x) OK, (y-r x) row, (y+r x) list the part of pixel.At (x-r x) the nearest background pixel of row mid-range objectives pixel O (is designated as B x1) coordinate be ( x - r x , y - LR [ x - r x , y ] ) Or ( x - r x , y + LR [ x - r x , y ] ) , If
Figure BDA00001791402600183
show B x1∈ R 1, i.e. R 1in there is background pixel, if LR[x+r in like manner x, y] and <r x 2, TD[x, y-r x] <r x 2tD[x x, y+r] and <r x 2, show respectively R 2, R 3, R 4in there is background pixel, establish tD=min{LR[x-r x, y], LR[x+r x, y], TD[x, y-r x], TD[x x, y+r] }, note r xon layer, the distance of the nearest background pixel of distance the first pixel and the first pixel square is DT x 2=tD+r x 2, due at r xin+1 layer, the minimum value of tD is (r x+ 1) 2so, as tD≤(r x+ 1) 2time, stop search, or judgement
Figure BDA00001791402600184
with (r x+ 1) 2+ r x 2, when
Figure BDA00001791402600185
in time, stops search.
Referring to Fig. 9, for adopting contour searching method, search for the schematic diagram of nearest background pixel, the pixel of supposing to calculate range conversion is object pixel A, in figure, numeral 1 represents that ground floor, numeral 2 represent the 2nd layer, digital 3 and represent that the 3rd layer and digital 4 represents the 4th layer, in figure, only draw four layers, but might not be four layers in actual applications, suppose at r x, search a background pixel B at=2 o'clock 4, obvious background pixel B 4with the distance of object pixel A be
Figure BDA00001791402600186
but square value 18 be greater than (3+1) 2so, need to continue the 3rd layer of search, at r x, search two background pixel B at=3 o'clock 1with B 3, due to background pixel B 1with the distance of object pixel A be
Figure BDA00001791402600188
obvious 13 are less than (4+1) 2so, stopping the search to lower one deck, the nearest background pixel of distance the first pixel that now utilizes the first function and the second function to search in nearest background pixel scope has B 1, B 3and B 4.
Above-mentioned is that to take the nearest background pixel scope shown in Fig. 4 be example, the explanation that step S703 is carried out, if background pixel is with shown in Fig. 2 recently, every layer of background pixel scope refers to O recently 1centered by foursquare border, the method that the thought that adopts so contour search is searched within the scope of background pixel is recently: from the 1st layer of D s (from 8 fields in the center of circle), successively scan until r 1+ r 2layer (half of the circle circumscribed square length of side) finishes; If background pixel is with shown in Fig. 3 recently, every layer of background pixel scope refers to O recently 2centered by square form, the method that the thought that adopts so contour search is searched within the scope of background pixel is recently: since the 1st layer 8 fields of the center of circle (from), when being scanned up to r 1(r during layer 1layer is circle O 2half of the circumscribed square length of side), the left side of background pixel scope has been searched for completely recently, every layer of this nearest background pixel scope is by with O 2centered by the border of dot-dash wire frame as shown in Figure 3, from r 1search for until r for+1 layer 1+ r 2layer.
Suppose that the position of the first pixel in bianry image is for (x, y), because the first subfunction is for calculating the capable left side of bianry image x distance the first pixel (x, y) columns at nearest background pixel place, the second subfunction is used for calculating the capable right side of bianry image x distance the first pixel (x, y) columns at nearest background pixel place, so SZ[x obtaining according to the first subfunction and the second subfunction, y] be also for determine x capable on distance the first pixel (x, y) columns at nearest background pixel place, ZS[x in like manner, y] be also for determine y capable on distance the first pixel (x, y) line number at nearest background pixel place.
With O (x, y) represent above-mentioned the first pixel, utilize every layer of middle distance O (x of the first function and the second Selecting Function System, y) nearest background pixel, be exactly to utilize the capable middle distance of the first Selecting Function System i (i in fact, y) nearest background pixel, and utilize the second Selecting Function System j row middle distance (x, j) nearest background pixel, so when execution step S703, be actually the first function SZ[x, y] in x replace to the function SZ[i of i, y] search for, function SZ[i, y] be actually search at the capable middle distance of i (i, y) nearest background pixel, due at the capable middle distance of i (i, y) nearest background pixel is exactly apart from O (x, y) nearest background pixel, so function SZ[i, y] in essence still for searching for each row middle distance O (x, y) nearest background pixel, and by the second function ZS[x, y] in y replace to the function ZS[x of j, j] search for, j row middle distance O (x, y) position of nearest background pixel is (ZS[x, j], j).Wherein, 1≤i≤m, 1≤j≤n, i and j are positive integer.
As shown in figure 10, proof procedure is as follows: suppose L 1, L 2, R 1, R 2be four background pixels of i on capable, the distance of they and O (x, y) is respectively | OL 1|, | OL 2|, | OR 1|, | OR 2|, known by geometric knowledge is exactly obviously distance (i, y) nearest background pixel apart from the nearest background pixel of O (x, y), and the position of the background pixel that the capable middle distance O of i (x, y) is nearest is (i, SZ[i, y]).
Step S704: determine first background pixel nearest with the first pixel distance from the nearest background pixel of distance the first pixel of searching out, calculate the first complete distance of the first background pixel and the first pixel, and the complete range conversion value using this first complete distance as the first pixel.
Completely distance refers to the bee-line of this first background pixel and the first pixel, i.e. air line distance, and range conversion value refers to the background pixel nearest with object pixel and the distance value of this object pixel.
Concrete, step S704 comprises: according to the nearest background pixel of the first pixel described in the distance of record and the complete square distance value of described the first pixel, determine the first complete square distance value of first background pixel nearest with described the first pixel distance and described the first pixel; The described first complete square distance value evolution is obtained to the described first complete distance.
Note r xon+k layer, the distance of the nearest background pixel of distance the first pixel and the first pixel square is
Figure BDA00001791402600201
only suppose to have found the background pixel nearest apart from the first pixel at the 3rd layer, the 4th layer and layer 5, the position of the first pixel in bianry image is (x, y), and step S704 specifically comprises:
Utilize formula
Figure BDA00001791402600202
determine first background pixel nearest with the first pixel distance, recycling formula:
Figure BDA00001791402600203
calculate the first complete distance.
The method that the embodiment of the present invention provides, not only has the beneficial effect of embodiment mono-, and owing to being to utilize the first function and the second function to search in every layer of background pixel recently, so more accelerated search speed.
For those skilled in the art further understand the advantage of the embodiment of the present invention, inventor uses said method to calculate the range conversion of each pixel in bianry image, and use prior art to carry out range conversion to same secondary bianry image, and the operation result of the two is compared.
Prior art refers to Fast Euclidean distance transformation in two scans using a 3 * 3neighborhood method.
As shown in table 1, for prior art is calculated the (unit: second) calculate the time contrast form of range conversion with utilizing this method working time of range conversion.
Table 1
As can be seen from Table 1, the image of different size is carried out to range conversion, it is long that prior art is carried out time of the method operation that time of range conversion all provides than the embodiment of the present invention, for high this theory of the method efficiency of carrying out range conversion that the expression embodiment of the present invention provides more intuitively, in table 1, give the ratio of the time of " method that prior art/embodiment of the present invention provides " operation.
As shown in table 2, for prior art, calculate the average error of range conversion and calculate the average error contrast form of range conversion with utilizing this method.
Average error refers to total error/object pixel number.
Table 2
Picture size Prior art The method that the embodiment of the present invention provides
800×534 0.2060 0
960×720 0.7311 0
1000×1000 1.5176 0
1100×734 0.1598 0
1300×1200 1.3605 0
As can be seen from Table 2, the image of different size is carried out to range conversion, prior art provides range conversion method average error large than the embodiment of the present invention.
In this instructions, each embodiment adopts the mode of going forward one by one to describe, and each embodiment stresses is the difference with other embodiment, between each embodiment identical similar part mutually referring to.For the disclosed device of embodiment, because it corresponds to the method disclosed in Example, so description is fairly simple, relevant part partly illustrates referring to method.
The software module that the method for describing in conjunction with embodiment disclosed herein or the step of algorithm can directly use hardware, processor to carry out, or the combination of the two is implemented.Software module can be placed in the storage medium of any other form known in random access memory (RAM), internal memory, ROM (read-only memory) (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technical field.
Above-mentioned explanation to the disclosed embodiments, makes professional and technical personnel in the field can realize or use the present invention.To the multiple modification of these embodiment, will be apparent for those skilled in the art, General Principle as defined herein can, in the situation that not departing from the spirit or scope of the present invention, realize in other embodiments.Therefore, the present invention will can not be restricted to these embodiment shown in this article, but will meet the widest scope consistent with principle disclosed herein and features of novelty.

Claims (9)

1. the method for the complete range conversion of a quick bianry image, described bianry image is of a size of m * n, it is characterized in that, comprising: determine the first function or the second function, described the first function is for determining the position of the background pixel that capable middle distance the first pixel of i is nearest, described the second function is for the position of the nearest background pixel of the first pixel described in definite j row middle distance, wherein, 1≤i≤m, 1≤j≤n, i and j are integer, and described method also comprises:
According to the complete distance of the second object pixel and described the first pixel, and described the second object pixel with from the complete distance of its nearest background pixel, determine the nearest background pixel scope of described the first pixel;
Utilize described the first function nearest background pixel of the first pixel described in detection range in every row of described nearest background pixel scope respectively, or utilize described the second function nearest background pixel of the first pixel described in detection range in every row of described nearest background pixel scope respectively;
From the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate the first complete distance of described the first background pixel and described the first pixel, and the complete range conversion value using the described first complete distance as described the first pixel;
Wherein, the x that described the first pixel is positioned at described bianry image is capable, y row, with (x, y) represent the position of described the first pixel in described bianry image, take (x, y) as separation, by capable left side and the right side of being divided into of x, y row are divided into above and below, wherein, 1≤x≤m, 1≤y≤n, determines that the method for the first function specifically comprises:
Be identified for calculating the first pixel (x described in the distance of the capable left side of described bianry image x, y) the first subfunction of nearest background pixel place columns, and for calculating the second subfunction of the nearest background pixel place columns of described the first pixel (x, y) of described bianry image x capable right side distance;
According to described the first subfunction and described the second subfunction, determine described the first function;
Described definite the second function specifically comprises:
Be identified for calculating described the first pixel (x of the described bianry image y side of listing distance, y) the 3rd subfunction of nearest background pixel place line number, and for calculating the 4th subfunction of the nearest background pixel place line number of the first pixel (x, y) described in the distance of described bianry image y row below;
According to described the 3rd subfunction and described the 4th subfunction, determine described the second function.
2. method according to claim 1, it is characterized in that, described according to the complete distance of the second object pixel and described the first pixel, and described the second object pixel with from the complete distance of its nearest background pixel, determine that the nearest background pixel scope of described the first pixel specifically comprises:
Calculate described the second object pixel and complete in r apart between its nearest background pixel 1;
Determine the complete in r of described the first pixel and described the second object pixel 2;
Described nearest background pixel scope is the center of circle for take described the first pixel, with r 1+ r 2round O for radius 1the region that surrounds of circumscribed square;
Or described nearest background pixel scope is the center of circle for take described the second object pixel, with r 1round O for radius 2in connect square with described round O 1the annular region that surrounds of circumscribed square;
Or described nearest background pixel scope is the center of circle for take described the first pixel, with | r 1-r 2| be the round O of radius 3in connect square with described round O 1the annular region that surrounds of circumscribed square.
3. method according to claim 1, is characterized in that, described the first subfunction is specially L:
L : L [ x , y ] = y I ( x , y ) = 0 L [ x , y - 1 ] I ( x , y ) = 1 ;
If I (x, y)=1 and y=1, L[x so, y]=-Maxlable;
Described the second subfunction is specially R:
R : R [ x , y ] = y I ( x , y ) = 0 R [ x , y + 1 ] I ( x , y ) = 1 ;
If I (x, y)=1 and y=n, R[x so, y]=Maxlable;
According to described the first subfunction and definite described the first function of described the second subfunction, be specially SZ:
SZ : SZ [ x , y ] = L [ x , y ] y - L [ x , y ] < R [ x , y ] - y R [ x , y ] y - L [ x , y ] &GreaterEqual; R [ x , y ] - y ;
Described the 3rd subfunction is specially T:
x I ( x , y ) = 0 T [ x - 1 , y ] I ( x , y ) = 1 ;
If I (x, y)=1 and x=1, T[x so, y]=-Maxlable;
Described the 4th subfunction is specially D:
D : D [ x , y ] = x I ( x , y ) = 0 D [ x + 1 , y ] I ( x , y ) = 1 ;
If I (x, y)=1 and x=m, D[x so, y]=Maxlable;
According to described the 3rd subfunction and definite described the second function of described the 4th subfunction, be specially ZS:
ZS : ZS [ x , y ] = T [ x , y ] x - D [ x , y ] < T [ x , y ] - x D [ x , y ] x - D [ x , y ] &GreaterEqual; T [ x , y ] - x ;
Wherein, I (x, y)=1 is expressed as object pixel, and I (x, y)=0 is expressed as background pixel, and described Maxlable is default maximum mark value.
4. method according to claim 3, it is characterized in that, describedly from the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate described the first background pixel and described the first pixel first completely distance specifically comprise:
Utilize formula min{ ((y-SZ[i, y]) 2+ (i-x) 2), the nearest background pixel scope of i ∈, determines first background pixel nearest with described the first pixel distance; Utilize formula
calculate the described first complete distance;
Or, utilize formula
Figure FDA0000429318960000033
wherein the nearest background pixel scope of j ∈, determines first background pixel nearest with described the first pixel distance, recycling formula
Figure FDA0000429318960000034
calculate the described first complete distance.
5. method according to claim 3, is characterized in that, before the described nearest background pixel scope of determining described the first pixel, also comprises:
Calculate (y-SZ[x, y]) 2;
(y-SZ[x, y]) 2be not more than in 1 situation, described first completely distance be (y-SZ[x, y]) 2, (y-SZ[x, y]) 2be greater than in 1 situation, carry out the described operation of determining the nearest background pixel scope of described the first pixel;
Or,
Calculate (x-ZS[x, y]) 2;
(x-ZS[x, y]) 2be not more than in 1 situation described first completely distance be (x-ZS[x, y]) 2, (x-ZS[x, y]) 2be greater than in 1 situation, carry out the described operation of determining the nearest background pixel scope of described the first pixel.
6. the method for the complete range conversion of a quick bianry image, described bianry image is of a size of m * n, it is characterized in that, comprising: determine the first function and the second function, described the first function is for determining the position of the background pixel that capable middle distance the first pixel of i is nearest, described the second function is for the position of the nearest background pixel of the first pixel described in definite j row middle distance, wherein, 1≤i≤m, 1≤j≤n, i and j are integer, and described method also comprises:
According to the complete distance of the second object pixel and described the first pixel, and described the second object pixel with from the distance of its nearest background pixel, determine the nearest background pixel scope of described the first pixel, and described nearest background pixel scope is divided into the first son background pixel range set and the nearest background pixel range set of the second son recently according to preset rules, described the first son recently background pixel range set comprises at least one first son background pixel scope recently, line number in the nearest background pixel scope of described at least one height is not more than columns, described the second son recently background pixel range set comprises at least one second son background pixel scope recently, line number in the nearest background pixel scope of described at least one the second son is greater than columns,
Utilize described the first function at the nearest nearest background pixel of the first pixel described in detection range in every row of background pixel range set of described the first son, utilize the second function at described the second son nearest background pixel of the first pixel described in detection range in every row of background pixel range set recently;
From the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate the first complete distance of described the first background pixel and described the first pixel, and the complete range conversion value using the described first complete distance as described the first pixel;
Wherein, the x that described the first pixel is positioned at described bianry image is capable, y row, with (x, y) represent the position of described the first pixel in described bianry image, take (x, y) as separation, by capable left side and the right side of being divided into of x, y row are divided into above and below, wherein, 1≤x≤m, 1≤y≤n, determines that the method for the first function specifically comprises:
Be identified for calculating the first pixel (x described in the distance of the capable left side of described bianry image x, y) the first subfunction of nearest background pixel place columns, and for calculating the second subfunction of the nearest background pixel place columns of described the first pixel (x, y) of described bianry image x capable right side distance;
According to described the first subfunction and described the second subfunction, determine described the first function;
Described definite the second function specifically comprises:
Be identified for calculating described the first pixel (x of the described bianry image y side of listing distance, y) the 3rd subfunction of nearest background pixel place line number, and for calculating the 4th subfunction of the nearest background pixel place line number of the first pixel (x, y) described in the distance of described bianry image y row below;
According to described the 3rd subfunction and described the 4th subfunction, determine described the second function.
7. the method for the complete range conversion of a quick bianry image, described bianry image is of a size of m * n, it is characterized in that, comprising: determine the first function and the second function, described the first function is for determining the position of the background pixel that capable middle distance the first pixel of i is nearest, described the second function is for the position of the nearest background pixel of the first pixel described in definite j row middle distance, wherein, 1≤i≤m, 1≤j≤n, i and j are integer, and described method also comprises:
According to the complete distance of the second object pixel and described the first pixel, and described the second object pixel with from the distance of its nearest background pixel, determine the nearest background pixel scope of described the first pixel;
Utilize described the first function and described the second function nearest background pixel of the first pixel described in detection range in every layer of described nearest background pixel scope respectively, every layer of foursquare border referring to centered by described the first pixel or described the second object pixel of described nearest background pixel scope;
From the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate the first complete distance of described the first background pixel and described the first pixel, and the complete range conversion value using the described first complete distance as described the first pixel;
Wherein, the x that described the first pixel is positioned at described bianry image is capable, y row, with (x, y) represent the position of described the first pixel in described bianry image, take (x, y) as separation, by capable left side and the right side of being divided into of x, y row are divided into above and below, wherein, 1≤x≤m, 1≤y≤n, determines that the method for the first function specifically comprises:
Be identified for calculating the first pixel (x described in the distance of the capable left side of described bianry image x, y) the first subfunction of nearest background pixel place columns, and for calculating the second subfunction of the nearest background pixel place columns of described the first pixel (x, y) of described bianry image x capable right side distance;
According to described the first subfunction and described the second subfunction, determine described the first function;
Described definite the second function specifically comprises:
Be identified for calculating described the first pixel (x of the described bianry image y side of listing distance, y) the 3rd subfunction of nearest background pixel place line number, and for calculating the 4th subfunction of the nearest background pixel place line number of the first pixel (x, y) described in the distance of described bianry image y row below;
According to described the 3rd subfunction and described the 4th subfunction, determine described the second function.
8. method according to claim 7, it is characterized in that, every layer of foursquare border referring to centered by described the first pixel of described nearest background pixel scope, described utilize described the first function and described the second function respectively in every layer of described nearest background pixel scope described in detection range the nearest background pixel of the first pixel specifically comprise:
Utilize described the first function and described the second function from r xlayer starts search until at r x+ k layer searches the nearest background pixel of described the first pixel of distance, described r xlayer is nearest one deck of the first pixel described in distance within the scope of described nearest background pixel, k=0,1,2 ... q-1, a total q layer within the scope of described nearest background pixel;
From at described r xdescribed in the distance that+k layer searches out, in the nearest background pixel of the first pixel, determine described r xthe nearest background pixel of the first pixel described in+k layer middle distance, and record described r xthe nearest background pixel of the first pixel and the complete square distance value of described the first pixel described in+k layer middle distance DT ( r x + k ) 2 ;
Relatively
Figure FDA0000429318960000062
with (r x+ k+1) 2+ (r x+ k) 2, when DT ( r x + k ) 2 &le; ( r x + k + 1 ) 2 + ( r x + k ) 2 Time, stop search, when DT ( r x + k ) 2 > ( r x + k + 1 ) 2 ( r x + k ) 2 Time, continue the lower one deck of search, until search for complete r x+ q-1 layer finishes.
9. method according to claim 8, it is characterized in that, describedly from the nearest background pixel of the first pixel described in the distance searching out, determine first background pixel nearest with described the first pixel distance, calculate described the first background pixel and described the first pixel first completely distance specifically comprise:
According to the nearest background pixel of the first pixel described in the distance of record and the complete square distance value of described the first pixel, determine the first complete square distance value of first background pixel nearest with described the first pixel distance and described the first pixel;
The described first complete square distance value evolution is obtained to the described first complete distance.
CN201210205727.4A 2012-06-20 2012-06-20 Method for fast transforming full distance of binary image Expired - Fee Related CN102737360B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210205727.4A CN102737360B (en) 2012-06-20 2012-06-20 Method for fast transforming full distance of binary image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210205727.4A CN102737360B (en) 2012-06-20 2012-06-20 Method for fast transforming full distance of binary image

Publications (2)

Publication Number Publication Date
CN102737360A CN102737360A (en) 2012-10-17
CN102737360B true CN102737360B (en) 2014-04-02

Family

ID=46992796

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210205727.4A Expired - Fee Related CN102737360B (en) 2012-06-20 2012-06-20 Method for fast transforming full distance of binary image

Country Status (1)

Country Link
CN (1) CN102737360B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108257202B (en) * 2017-12-29 2021-09-10 四川师范大学 Medical image volume reconstruction optimization method based on use scene
CN112766338B (en) * 2021-01-11 2023-06-16 明峰医疗系统股份有限公司 Method, system and computer readable storage medium for calculating distance image

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081789A (en) * 2009-12-01 2011-06-01 富士施乐株式会社 Image processing apparatus and image processing method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7496242B2 (en) * 2004-12-16 2009-02-24 Agfa Inc. System and method for image transformation

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081789A (en) * 2009-12-01 2011-06-01 富士施乐株式会社 Image processing apparatus and image processing method

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
Active contours base on maximum gravity optimization algorithm;Jin Linpeng,et al.;《2009 3rd International Conference on Bioinformatics and Biomedical Engineering》;20090616;第1-4页 *
Jin Linpeng,et al..Active contours base on maximum gravity optimization algorithm.《2009 3rd International Conference on Bioinformatics and Biomedical Engineering》.2009,
一种新的完全欧氏距离变换算法;刘相滨等;《计算机工程与应用》;20050623;第41卷(第13期);第44-45、153页 *
刘相滨等.一种新的完全欧氏距离变换算法.《计算机工程与应用》.2005,第41卷(第13期),

Also Published As

Publication number Publication date
CN102737360A (en) 2012-10-17

Similar Documents

Publication Publication Date Title
JP6347827B2 (en) Method, apparatus and device for detecting lane boundaries
CN111104838B (en) Method and device for detecting ROI (region of interest) based on lower end line of obstacle
CN103942824B (en) Linear feature extracting method for three-dimensional point cloud
CN103679702A (en) Matching method based on image edge vectors
CN104899883A (en) Indoor object cube detection method for depth image scene
CN105957113B (en) Manhattan network-based horizontal inscribed rectangle algorithm and device for any connected domain
CN104766037A (en) Two-dimension code recognition method and device
CN107192716A (en) A kind of workpiece, defect quick determination method based on contour feature
CN104517090A (en) Method and system for detecting QR code detection figures
US20170161587A1 (en) Image description and image recognizable method
CN102737360B (en) Method for fast transforming full distance of binary image
JP2020038663A (en) Learning method and learning device for detecting obstacle, and test method and test device using the same
CN113378789B (en) Cell position detection method and device and electronic equipment
CN106547014A (en) The generation method of crystal localization method and look-up table
CN106297536B (en) Method and device for determining labeling position of planar graphic element name in electronic map
CN105551048A (en) Space surface patch-based three-dimensional corner detection method
CN111104840B (en) Regression loss-based learning and testing method and device
CN102737361B (en) Method for transforming full distance of three-dimensional binary image
CN101546432B (en) Method and device for acquiring image deviation position
CN112488429B (en) Two-dimensional irregular layout blanking method based on scanning line method
CN103955929B (en) Image local edge pattern and non-edge mode judging method and judgment means
CN107480710B (en) Feature point matching result processing method and device
CN104156956A (en) Multi-angle edge detection method based on Gauss wavelet one-dimensional peak value identification
WO2010057376A1 (en) Method and device for segmenting candidate obstacle area
CN104680523A (en) Multi-modal region-consistent significance object detection method based on foreground and background priori

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20140402

Termination date: 20180620