radius of my image?

3 次查看(过去 30 天)
Hever castellanos
Hever castellanos 2015-7-27
% r= sqrt((X-x1).^2+(Y-y1).^2);
% t= atan2(y1,x1);

回答(1 个)

Jon
Jon 2015-7-28
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 个评论
Jon
Jon 2015-8-12
编辑:Jon 2015-8-12
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 2015-8-13
编辑:Jon 2015-8-13
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.

请先登录,再进行评论。

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by