how to make multiple ellipses in image (one inside another) and find the sum of pixels between two ellipses.

4 Ansichten (letzte 30 Tage)
Dear Expert,
I have an tif file and i want to cut the elliptical part of from that image (which i am doing by the following code) . Although I can get sum of elliptical by the following method. But I want to make multiple elliptise(first ellipse and then second smaller ellipse inside the first one and so on) and i also want to know the sum of pixels between two ellipses. I am attaching an image showing how I want to draw the ellipses.
Thank you
[FileName,PathName] = uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files'},'Please Select an Image');
image = imread([PathName FileName]);
imshow(image) %needed to use imellipse
user_defined_ellipse = imellipse(gca, []); % creates user defined ellipse object.
wait(user_defined_ellipse);% You need to click twice to continue.
MASK = double(user_defined_ellipse.createMask());
new_image_name = [PathName 'Cropped_Image_' FileName];
new_image_name = new_image_name(1:strfind(new_image_name,'.')-1); %removing the .jpg, .tiff, etc
new_image_name = [new_image_name '.tif']; % making the image .png so it can be transparent
imwrite(image, new_image_name,'png','Alpha',MASK);
msg = msgbox(['The image was written to ' new_image_name],'New Image Path');
waitfor(msg);
cropped_img_sum = imread(new_image_name);
winopen(new_image_name);
cropped_img = sum(sum(cropped_img))

Akzeptierte Antwort

Image Analyst
Image Analyst am 7 Okt. 2022
That's exactly what my demo does. See attached demos.
meanInsideEllipse =
100.464150943396
areaOfEllipse =
9805
You could of course sum all the gray levels inside if you wanted by adding this:
sumInsideEllipse = sum(monochromeImage(maskImage))
  4 Kommentare
SHUBHAM AGARWAL
SHUBHAM AGARWAL am 9 Okt. 2022
Dear Expert,
I want to zoom into the image before making ellipse. I am trying the zoom option in imshow but then after zoom in i can not fraw the ellipse.How can it be done?
Thank you
Image Analyst
Image Analyst am 9 Okt. 2022
@SHUBHAM AGARWAL I don't know. Not all of the Image Processing functions work well if you have changed the zoom. It might not be possible. Call tech support for a definitive answer.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by