Filter löschen
Filter löschen

How can I prevent moving ROI out of the image edges?

2 Ansichten (letzte 30 Tage)
azim
azim am 16 Dez. 2015
Beantwortet: azim am 17 Dez. 2015
I have a Region Of Interest (ROI) on an image. Please see the following code:
a=imread('rice.png'); I=imshow (a); e = imellipse(gca,[]);
The ROI can be moved on the image by mouse dragging. I want that the ROI cannot be able to move out of the image, and be stopped when its bounds reach to the image edges. I would be much appreciated it if you could help me for resolving this problem. Thank you very much

Akzeptierte Antwort

Image Analyst
Image Analyst am 16 Dez. 2015
Did you happen to look at the help for imellipse and see the very first example:
figure, imshow('cameraman.tif');
h = imellipse(gca, [10 10 100 100]);
addNewPositionCallback(h,@(p) title(mat2str(p,3)));
fcn = makeConstrainToRectFcn('imellipse',get(gca,'XLim'),get(gca,'YLim'));
setPositionConstraintFcn(h,fcn);

Weitere Antworten (1)

azim
azim am 17 Dez. 2015
Thank you

Community Treasure Hunt

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

Start Hunting!

Translated by