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:
Finding aspect ratios of irregular regions

Subject: Finding aspect ratios of irregular regions

From: Cory

Date: 16 Nov, 2010 19:11:03

Message: 1 of 2

I am trying to find the aspect ratio of some elongated regions as well as some more circular regions and would like to separate the type of regions and perform separate calculations on both sets of regions. I am not sure how to go about separating the two type of regions (i.e those with aspect ratios <2 and those >=2)

If anybody can help it would be greatly appreciated! Thank you.

Subject: Finding aspect ratios of irregular regions

From: Sean de

Date: 16 Nov, 2010 19:33:04

Message: 2 of 2

"Cory " <cory.hayes@gkndriveline.com> wrote in message <ibul07$hj8$1@fred.mathworks.com>...
> I am trying to find the aspect ratio of some elongated regions as well as some more circular regions and would like to separate the type of regions and perform separate calculations on both sets of regions. I am not sure how to go about separating the two type of regions (i.e those with aspect ratios <2 and those >=2)
>
> If anybody can help it would be greatly appreciated! Thank you.

Something like this?
%%%
M = your_binary_image
CC = bwconncomp(M,4);
RP = regionprops(CC,'Image');
C = {RP(:).Image};
AspectRatio = cellfun(@(x)max(size(x))./min(size(x)),C);

Elongated = false(size(M));
Circular = Elongated;

Elongated(cell2mat(CC.PixelIdxList(AspectRatio>2).')) = true;
Circular(cell2mat(CC.PixelIdxList(AspectRatio<=2).')) = true;
%SCd
%%%

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