Updating an ROI

11 vues (au cours des 30 derniers jours)
Jason
Jason le 17 Août 2011
Hello. This is sort of related to another post so I apologise. I have an image "IM" and want to be able to draw a box, resize and move the box and for the new ROI to be drawn in a second axes component.
J = imadjust(IM,stretchlim(IM),[0 1]);
axes(handles.axes1)
axis off;
imshow(J);
zoom on;
%Get ROI
h = imrect;
p = h.getPosition()
assignin('base','p',round(p))
addNewPositionCallback(h,@(p)assignin('base','p',p));
p1=evalin('base','p')
%Get x & y coordinates
sp(1) = min(floor(p1(1)), floor(p1(2))); %xmin
sp(2) = min(floor(p1(3)), floor(p1(4))); %ymin
sp(3) = max(ceil(p1(1)), ceil(p1(2))); %xmax
sp(4) = max(ceil(p1(3)), ceil(p1(4))); %ymax
Zoom = IM(sp(2):sp(4), sp(1): sp(3),:); % This is the ROI
J = imadjust(Zoom,stretchlim(Zoom),[0 1]);
axes(handles.axes2)
imshow(J);
It works the first time I initialise the box on the raw image but doesn't update as I move and resize the box. Have I missed something? Thanks Jason

Réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by