I am new to matlab and I was trying to analyze an image to calculate certain dimensions (specifically ds and de, see images) from an experimental image. Can that be done using matlab?

2 views (last 30 days)
and the experimental image is

Accepted Answer

Walter Roberson
Walter Roberson on 25 May 2015
I don't know if I am interpreting that diagram correctly. It looks to me as if De is the width of the bulb, which you could obtain using regionprops MinorAxisLength . And then you would go up that far from the bottom of the image (regionprops bounding box would tell you the bottom) and measure the width of the object there to get Ds ? If you know which row you are looking at, there are any of several ways to find the width, such as find() of the first and last locations.
Note: you will need to invert the image to use with regionprops.
  3 Comments
Walter Roberson
Walter Roberson on 25 May 2015
rimg = ~black_img;
rinfo = regionprops(rimg, 'Image');
De = size(rinfo.Image,2); %width
imgslice = rinfo.Image(end-De+1,:); %taken at De above bottom
firston = find(imgslice, 1, 'first');
laston = find(imgslice, 1, 'last');
Ds = laston - firston + 1;
Image Analyst
Image Analyst on 25 May 2015
Edited: Image Analyst on 25 May 2015
You'd think the MinorAxisLength would be the max width of the bulb, but it's not. It's the width of an ellipse fitted to that shape, so it won't be an exact match since the shape is not a perfect ellipse. But it looks like the second bit of code should do it.
Your "experimental" image looks more like a perfect computer graphics image rather than an actual snapshot taken from a real digital camera. Such a real world image might have more issues, like noise, nonuniform background, reflections, and other image clutter. If you have an image like that you're going to need to be more robust. If so, post your actual photo and we'll try to see how to make the measurement.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!