필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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))

채택된 답변

Image Analyst
Image Analyst 2022년 10월 7일
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
SHUBHAM AGARWAL
SHUBHAM AGARWAL 2022년 10월 9일
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 2022년 10월 9일
@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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by