From: "Earl F. Glynn"
To: "nipon ph"
Subject: Re: Reguest reslove:
Date: Tuesday, October 31, 2000 8:49 AM
Dear Engineering Student at kmutt:
> i can't apply all it , How i read bmp file which have picture
> to find perimeter?
> Possible ? i can find (x,y) of pixel
> Can i count the pixel border to find perimeter? How to?
I have never had to solve this problem, so I don't have a
complete example for you.
Can you get this book at a library?
Image Processing for Scientific Applications
by Bernd Jahne (CRC Press, 1997)
http://www.amazon.com/exec/obidos/ASIN/0849389062/efgscomputlab
On p. 494, the concept of "chain code" or
"countour code" is described. It is a "data structure
to represent the boundary of a binary image on a discrete
grid in an efficient way. Instead of storing the positions
of all the pixels, we select a starting pixel and store its
coordinates. If we use an algorithm which scans the
image line by line, this will be the uppermost left pixel
of the object. Then we follow the boundary in clockwise
direction. In a 4-neighborhood, there are 4, in an
8-neighborhood there are 8 possible directions to go
which we can code with a 3-bit or 2-bit code."
The 8-neighborhood code is a number from 0 to
7 with 0 = East, 1 = NorthEast, 2 = North,
3=NorthWest, 4=West, 5=SouthWest,
6=South, 7=SouthEast. (This assumes
"up" on a page like on a map is "North")
Draw arrows from a center point to "see" this
diagram.
So you can represent an object by its
initial (x,y) plus a chain code around the
perimeter of the object. The book gives
a good example of this.
Section 16.4.3b tells how to use such a chain code
to compute perimeter: "The perimeter is
another geometrical parameter, which can easily
be obtained from the chain code of the object
boundardy. We just need to count the
length of the code code and take into consideration
that steps in diagonal directions [namely
the codes, 1, 3, 5, 7] are a factor of SQRT(2)
longer [than the even codes, 0, 2, 4, 6]. The
perimeter P is then given by an 8-neighborhood
chain code:
P = NumberEven + SQRT(2)*NumberOdd,
where NumberEven and NumberOdd are the number
of even and odd chain code steps, respectively. In
contrast to the area, the perimeter is a parameter
which is sensitive to the noise level in the image.
The more noise in the image, the more rugged and
thus longer the boundary of an object will become
in the segmentation procedure. This means that
care must be taken in comparing perimeters which
have been extracted from different images."
Seems like another approach might be to use
"dilation" of an object since the derivative
of area would give you perimeter.
[Much like taking the derivative of the
area of a circle gives you the "perimeter"
(i.e., circumference) of a circle:
d/dR (PI*R^2) = 2 * PI * R]
I hope this gets you going.
--
efg
Earl F. Glynn E-mail: efg2@efg2.com
Overland Park, KS USA
efg's Computer Lab: http://www.efg2.com/Lab