radius of my image?

9 views (last 30 days)
Hever castellanos
Hever castellanos on 27 Jul 2015
Edited: Hever castellanos on 15 Sep 2015
% r= sqrt((X-x1).^2+(Y-y1).^2);
% t= atan2(y1,x1);

Answers (1)

Jon
Jon on 28 Jul 2015
For the image you provided, you could simply compute the diameter by taking the difference between the max and min y-values of the membrane:
[x y] = find([your_image]); % returns coordinates of white pixels
r = (max(y)-min(y))/2; % computes radius
Of course, this only works if there are no aberrations at the top or bottom of the membrane. It might also be sensitive to a noisy edge. Not robust, but quick and easy.
If you want to compute the area (in pixels) of the entire membrane, including the aberration on the left side, you could simply write
area = sum(sum(imfill(your_image,'holes')));
If you want a more robust method, I think the functions bwboundaries and regionprops might be helpful. Check out the tutorial here to get started.
  2 Comments
Jon
Jon on 12 Aug 2015
Edited: Jon on 12 Aug 2015
I guess I don't understand what you're trying to quantify. The area of the green pixels? The area of the red pixels? Are you just trying to fit a circle to the extent of the green portion? It's not clear what you'd like for a final result.
Jon
Jon on 13 Aug 2015
Edited: Jon on 13 Aug 2015
If you have multiple cells to process, and the bump on the left could be anywhere along the circumference in each cell (or may not be there at all, or there may be multiple bumps, etc), your method will not handle these cases without manual intervention. If that is OK with you, then proceed the way you are. However, I would think that you would want to make the code generalizable to many cases, and I think a better way to do that would be to fit a circle to all the edge cells. You could use this function, for example: http://www.mathworks.com/matlabcentral/fileexchange/5557-circle-fit
If you still prefer to manually remove portions of the image, you can find the intersecting points using intersections.m from the File Exchange. You'll need to make sure your x,y are in the same reference frame (in images, y is positive as you move downward).
Once you have the intersections, you can use poly2mask to remove those portions of the image.

Sign in to comment.

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!