drawing a regular polygon over an image and calculate the area - matlab

I want to draw a regular polygon over an image in matlab and then calculate the area of that polygon.

have you try area or polyarea?

Related

Calculating area on N points

Im trying to calculate numerically an area of different shapes where the only thing I know about them is the (x,y) of each corner.
For example the shapes are:
P.s. The points inside the shape are for other calculation, I only need the area of the most outer shape.
Thank you.
Create polygon, and use polyarea function.
Given x,y location of corners than:
Area=polyarea(x,y)

Draw draggable/adjustable rectangle on image based on PREDEFINED COORDINATES in Matlab?

I calculate the rectangular bounding box coordinates for objects in my matlab code ([xmin ymin width height]). But the coordinates might not be precise. Then, I want to draw the box on the image and modify that by dragging the box and/or adjusting the borders. I tried to use imrect and imcrop, but those functions do not draw the draggable/adjustable rectangle on image, based on predefined coordinates. Is there any way to do that?
Thanks in advance for your time.
Take a look at imrect. It works much like the imcrop rectangle but you can set an initial position and get the current position by calling getPosition.

how to crop the binary image from the point of the centroid of an image to some extent

After finding out the centroid of the image , i want to crop some object in an image from the centroid point to some extent. I can use regionprops function to identify the centroid.. the thing is how to crop the image based on the centroid point to some region and how to make my object position in an image to fix at the centre of the whole image.

MATLAB: how do I crop out a circle from an image

I need to crop a circle in MATLAB.
I need to perform iris segmentation, and I´ve identified the center point and the radius of the iris, and I need to cut it off from the image.
I have a vector ci that ci(1) is X-coordinate ci(2) is Y-coordinate and ci(3) is the radius of the circle.
One way to do this is to create a binary mask with ones inside the circle and zeros outside. You can then use this array to either mask everything outside the circle with NaNs, or to read the pixel values of the image inside the mask.
To create a circle mask, an easy way is to create coordinate arrays centered on the iris, and threshold the distance, like this:
[xx,yy] = ndgrid((1:imageSize(1))-ci(1),(1:imageSize(2))-ci(2));
mask = (xx.^2 + yy.^2)<ci(3)^2;

Markers and the imagesc() function in matlab

How do you create a marker on a 2D image that is plotted using imagesc()? Is it even possible?
You simply want to draw something over your image? Then you can just use hold on.
For example, this will draw a circle at the 10,10 pixel of the image.
imagesc(magic(24));
hold on
scatter(10,10);