Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Boundry between image regions

Subject: Boundry between image regions

From: Michael

Date: 12 Jan, 2011 15:31:04

Message: 1 of 2

I have two regions in an image (labeled with 1 and 2 respectively), and I want to find out the length of the boundary between them. I thought of applying dilation to one of them and then looking for the intersection with the second. Something like:

region1 = image == 1;
region2 = image == 2;
se = strel('disk',1,0);
extended = imdilate( region1, se );
boundry = length( find( extended && region2 )

The problem is that I need to do this for a large set of images and this procedure is slow (I guess because of the imdilate).

Does anyone has an idea on how to do this faster?

Thanks in advance!

Subject: Boundry between image regions

From: Sean de

Date: 12 Jan, 2011 16:00:18

Message: 2 of 2

"Michael" wrote in message <igkhfo$p76$1@fred.mathworks.com>...
> I have two regions in an image (labeled with 1 and 2 respectively), and I want to find out the length of the boundary between them. I thought of applying dilation to one of them and then looking for the intersection with the second. Something like:
>
> region1 = image == 1;
> region2 = image == 2;
> se = strel('disk',1,0);
> extended = imdilate( region1, se );
> boundry = length( find( extended && region2 )
>
> The problem is that I need to do this for a large set of images and this procedure is slow (I guess because of the imdilate).
>
> Does anyone has an idea on how to do this faster?
>
> Thanks in advance!

What about:
bwboundaries, bwperim, bwtraceboundary

Also, I would guess that your method with imdilate isn't producing the results you expect, since it would fill small concave areas.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us