Changing drawellipse to drawcircle doesn't work like I wished

5 visualizaciones (últimos 30 días)
I had a few lines of code running with the command drawellipse.
f = figure;
set(f,'Name',['cropping image "',imageName,'"'],'NumberTitle','off','units','normalized','position',[0.075,0.0375,0.85,0.85]);
Opt.Interpreter = 'tex';
Opt.WindowStyle = 'normal';
%% define ellipse
% show the image and draw an ellipse to the ROI
subplot(1,1,1);
imshow(image)
title('Please draw ellipse.');
roi = drawellipse;
waitfor(msgbox('Please adjust the ellipse on the original image manually and confirm it here \bfafterwards\rm with ok.','Ellipse correctly positioned','none',Opt));
roi = addlistener(roi,'ROIMoved',@allevents);
Then I tried to change it to a circle, that has a given radius (in pixels) and only needs to be placed at the right position. So that you only have to find the position for the center.
%% nothing changed above
%% define ellipse
% show the image and place a circle to the right ROI
subplot(1,1,1);
imshow(image)
title('Please place circle.');
roi = drawcircle('radius',Radius,'InteractionsAllowed','translate');
waitfor(msgbox('Please adjust the circle on the original image manually and confirm it here \bfafterwards\rm with ok.','Circle correctly positioned','none',Opt));
roi = addlistener(roi,'ROIMoved',@allevents);
It doesn't work as I thought, because when I click anywhere it only creates a dot that can be moved. Although I can create a circle by pulling the clicked mouse across the image. But I want to see the whole circle with the given radius by clicking once and the possiblity to translate it across the image to the right position.

Respuesta aceptada

Jonas Thomalla
Jonas Thomalla el 11 de Nov. de 2020
I don't know why it works right now, but I changed the drawcircle/drawellipse to images.roi.Ellipse with fixed values.
%% nothing changed above
%% define ellipse
% show the image and place a circle to the right ROI
subplot(1,1,1);
imshow(image)
title('Please place circle.');
roi = images.roi.Ellipse(gca,'Center',[200,200],'Semiaxes',[Radius,Radius],'FixedAspectRatio',true,'InteractionsAllowed','translate');
waitfor(msgbox('Please adjust the circle on the original image manually and confirm it here \bfafterwards\rm with ok.','Circle correctly positioned','none',Opt));
roi = addlistener(roi,'ROIMoved',@allevents);
Now it creates a ROI that is fixed in aspect ratio and radius of the circle. You are only allowed to move the circle around your image.

Más respuestas (0)

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by