how to find perimeter of object without using bwperim?

6 views (last 30 days)
i am using BW2 = bwperim(BW) inbuilt function to find perimeter of an image. now i want to undestand how this exactly works? how this image is passesd to other function and how the function retruns perimeter.so where can i find complete hard code of inbuilt function??
i mean to say is i find perimeter of object without using bwperim function?

Answers (1)

Image Analyst
Image Analyst on 27 Apr 2015
What "other function"?
Anyway, bwperim returns the outer layer of a binary image. If you know what 8-connected and 4-connected means, it should be obvious what you'll get out of it. One way might be to erode the image and then eXclusive OR it, like the Mathworks does, from the original. Why do you need to know? I just treat it as a black box and don't need to know and don't care about the details. I have higher level operations to worry about. Even though I might know how low level routines work in principle, I don't feel I need to know them down to the actual lines of source code. If you really want to know, you can edit the file
>> edit bwperim
and find code such as this:
b_eroded = imerode(b,conn);
p = b & ~b_eroded;
which is the heart of the algorithm.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!