how to calculate perimeter on RGB picture??

Asked by BSantos about 13 hours ago
Latest activity Commented on by Image Analyst about 7 hours ago

Hello everyone!

I would like to ask for your help, once again!

In my project, I have to draw a circumference on a RGB picture, and calculate the intensity of that picture within that circumference (circle) and ON the circumference. The circle part, I can do it, but on the circumference not.

The issue is that, if the radius it's not an integer, the function does not count with the decimal part. Here's a picture to illustrate my issue.

Assume, radius=3.5 (for example). https://www.dropbox.com/s/k3ntibshwa2nkiz/example.PNG

Thanks!!!

BR,

BS.

0 Comments

BSantos

Products

No products are associated with this question.

2 Answers

Answer by Image Analyst about 13 hours ago

I don't know what "The circle part, I can do it, but on the circumference not." means. Do you have the coordinates of the outside perimeter (circumference) of the circle? If so, use poly2mask to create a binary image from it, then call regionprops and ask for MeanIntensity. It's like 2 lines of code.

3 Comments

BSantos about 12 hours ago

What I meant with "The circle part, I can do it, but on the circumference not." is that I can calculate the circle area for the integer part of the radius (like on the link I shared).

Regarding coordinates: I have the center's coordinates (Pixel number).

I do not have Image Processing Toolbox, so I have to do it "old fashioned way".

Thanks!

Image Analyst about 8 hours ago

See the FAQ: http://matlab.wikia.com/wiki/FAQ?&cb=5430#How_do_I_create_a_circle.3F

% Create a logical image of a circle with specified
% diameter, center, and image size.
% First create the image.
imageSizeX = 640;
imageSizeY = 480;
[columnsInImage rowsInImage] = meshgrid(1:imageSizeX, 1:imageSizeY);
% Next create the circle in the image.
centerX = 320;
centerY = 240;
radius = 100;
circlePixels = (rowsInImage - centerY).^2 ...
    + (columnsInImage - centerX).^2 <= radius.^2;
% circlePixels is a 2D "logical" array.
% Now, display it.
image(circlePixels) ;
colormap([0 0 0; 1 1 1]);
title('Binary image of a circle');

Then you calculate the mean intensity of the pixels within the circle like this:

meanWithinCircle = mean(grayImage(circlePixels));
Image Analyst about 7 hours ago

Responding to your Answer, if "within that circumference" actually means "on the perimeter" rather than "anywhere within the entire disk" then you can use the faq to get the perimeter pixels only, rather than a solid disc. Then use the same code. Nothing I gave in the code above is in the Image Processing Toolbox.

Image Analyst
Answer by BSantos about 8 hours ago

Image Analyst,

Thank you but this doesn't help much. I can create the circle (or disk), the issue is for those pixels that are on the border (let's call it like that), in case of non integer radius.

Plus, I don't have Image Processing Toolbox, so I can't use most of the functions that could actually solve this in 10secs(??)!

Help anyone???

0 Comments

BSantos

Contact us