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:
Problem in calculating area!

Subject: Problem in calculating area!

From: Beho nashed

Date: 16 Jun, 2010 21:59:05

Message: 1 of 10

Hello,
I have some samples that has different degrees of damage.
http://drop.io/rlv072i

you can see that there are two boundaries. I am trying to calculate the area of the small one.

I tried to adjust the contrast, and then use some of the previously posted scripts such as creaseg and ImROI, it couldn't detect the small area.

#[code]

I=imread('sample.jpg');

J = IMADJUST(I,[0.1; 0.8],[0.2; 0.9],20); % I made gamma large, as it showed the area more visible.

%imshow(I)
%figure;
%imshow(J)
imwrite(J,'test_gamma.jpg');
h=rgb2gray(J);

A = adapthisteq(h,'clipLimit',0.02,'Distribution','rayleigh');
figure, imshow(h);
figure, imshow(A);

gray_level = graythresh(A);

% Trying to convert it to Black&White, but it doesn't really work
BWImage = im2bw(A,gray_level);
imwrite(BWImage,sample_mod.jpg');
figure, imshow(BWImage)

image_size = size(BWImage);
all_pixels = image_size(1,1) * image_size(1,2);
count_w_pxl = (BWImage == 1);
white_pixels = sum(sum(count_w_pxl));

pxl_in_sq = 70^2;
Damage_Area = white_pixels / pxl_in_sq;

[Code]

Is there a simpler method to detect the small area and calculate its area

Subject: Problem in calculating area!

From: ImageAnalyst

Date: 16 Jun, 2010 22:26:36

Message: 2 of 10

Heck, I can't even detect the small area. What exactly is it that
separates one area from the other? If I had to draw it, I'd have a
tough time. Maybe you can draw it and post it and say what criteria
you're using to decide where to draw it.

Subject: Problem in calculating area!

From: Beho nashed

Date: 16 Jun, 2010 22:39:07

Message: 3 of 10

"Beho nashed" <beho86@yahoo.com> wrote in message <hvbhf9$ep3$1@fred.mathworks.com>...
> Hello,
> I have some samples that has different degrees of damage.
> http://drop.io/rlv072i
>
> you can see that there are two boundaries. I am trying to calculate the area of the small one.
>
> I tried to adjust the contrast, and then use some of the previously posted scripts such as creaseg and ImROI, it couldn't detect the small area.
>
> #[code]
>
> I=imread('sample.jpg');
>
> J = IMADJUST(I,[0.1; 0.8],[0.2; 0.9],20); % I made gamma large, as it showed the area more visible.

Hello ImageAnalyst,

I uploaded what I meant ( http://drop.io/rlv072i ), something like that!

The imadjust I am using is actually showing the area I am looking for! give it a try:
I=imread('sample.jpg');
J = IMADJUST(I,[0.1; 0.8],[0.2; 0.9],20);
%imshow(I)
%figure;
imshow(J)

but I am not sure what to do after this.

Subject: Problem in calculating area!

From: ImageAnalyst

Date: 16 Jun, 2010 22:52:48

Message: 4 of 10

Beho:
imadjust does nothing at all to help you. It just scales the image,
that's all. You can find the objects equally well without scaling
them beforehand. So now you need to define where the edges are
because to me it looks like the are areas where blob 1 and blob 2
blend together pretty well. In that case you might have to get
partial boundaries somehow and then use something like snakes to
"complete" the boundary. Not easy. If you can segment based on
intensity (perhaps by using just one of the color channels), or by
color, then that's easier. Maybe you can use bilateral filtering to
make the regions more uniform and the edges sharper and more
distinct. See the examples on this page:
http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html
-ImageAnalyst

Subject: Problem in calculating area!

From: Beho nashed

Date: 16 Jun, 2010 23:04:22

Message: 5 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <53ed35ef-fc17-4674-a600-35de503b364c@a40g2000vbl.googlegroups.com>...
> Beho:
> imadjust does nothing at all to help you. It just scales the image,
> that's all. You can find the objects equally well without scaling
> them beforehand. So now you need to define where the edges are
> because to me it looks like the are areas where blob 1 and blob 2
> blend together pretty well. In that case you might have to get
> partial boundaries somehow and then use something like snakes to
> "complete" the boundary. Not easy. If you can segment based on
> intensity (perhaps by using just one of the color channels), or by
> color, then that's easier. Maybe you can use bilateral filtering to
> make the regions more uniform and the edges sharper and more
> distinct. See the examples on this page:
> http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html
> -ImageAnalyst

Hello ImageAnalyst,
What I need is an approximate for the area. I know that they tend to overlap each other.
I read about the imadjust, changing the gamma value changes the image intensity. The image generated by the imadjust doesn't show much from region one ( the larger region).
I thought all what I needed is just to identify the area of the region in white.
if I can eliminate the white noise around the image, and switch the color of the yellow to something darker, then I think I can convert the pic to B&W image.
I would like to know your opinion? ( I am new to ML btw)
thanks,

Subject: Problem in calculating area!

From: ImageAnalyst

Date: 16 Jun, 2010 23:12:07

Message: 6 of 10

Look at the blue channel. Your inner blob is fairly distinct there
with a threshold of 228. However your outer blob has a very poorly
defined outer border that connects it to the bright stuff at the edge
of the image.

You really need to work on getting a better image to start with.
Better illumination, better contrast, no letters written on your
sample, etc.

Subject: Problem in calculating area!

From: Beho nashed

Date: 16 Jun, 2010 23:29:20

Message: 7 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <3a1a72c4-5c73-4949-b1f9-077741af3dc3@z31g2000vbk.googlegroups.com>...
> Look at the blue channel. Your inner blob is fairly distinct there
> with a threshold of 228. However your outer blob has a very poorly
> defined outer border that connects it to the bright stuff at the edge
> of the image.
>
> You really need to work on getting a better image to start with.
> Better illumination, better contrast, no letters written on your
> sample, etc.

I will give it another try. I have the picture at 5 MP, but I had to adjust it to 1 MP , as matlab kept freezing and crashing.

I have another question, Is there away to change the yellow color in the image generated by imadjust to black?
Thanks for your help.

Subject: Problem in calculating area!

From: ImageAnalyst

Date: 17 Jun, 2010 01:57:09

Message: 8 of 10

On Jun 16, 7:29 pm, "Beho nashed" <beh...@yahoo.com> wrote:
> I have another question, Is there away to change the yellow color in the image generated by imadjust to black?
> Thanks for your help.
-------------------------------------------------------------------------
Sure, but you shouldn't even be using imadjust.

Subject: Problem in calculating area!

From: Beho nashed

Date: 18 Jun, 2010 15:28:04

Message: 9 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <5b824ca7-29cd-4811-b9ef-013857810b01@g19g2000yqc.googlegroups.com>...
> On Jun 16, 7:29 pm, "Beho nashed" <beh...@yahoo.com> wrote:
> > I have another question, Is there away to change the yellow color in the image generated by imadjust to black?
> > Thanks for your help.
> -------------------------------------------------------------------------
> Sure, but you shouldn't even be using imadjust.

Hello ImageAnalyst,
I took more pics of the sample. for the text, It's already there!!! I tried to remove it using GIMP software, it's not that bad.

I uploaded the new pic here --> http://drop.io/rlv072i (3rd pic)

I am trying to calculate the large area. how would you approach it?

Subject: Problem in calculating area!

From: ImageAnalyst

Date: 18 Jun, 2010 20:23:46

Message: 10 of 10

I know the text (letters) are already there. Can you get rid of
them? Snap a photo without them? Also, even with your latest photo,
it's very unclear where you consider the boundaries of the object to
be.

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