This example draw rectangle on the image in matlab using imrect function .
Code:
NumberArrays=[20 20 120 120] % Show the Image figure(1), imshow('000067.jpg'); h = imrect(gca, NumberArrays); addNewPositionCallback(h,@(p) title(mat2str(p,3))); % recall function to draw the rectangle. fcn = makeConstrainToRectFcn('imrect',get(gca,'XLim'),get(gca,'YLim')); setPositionConstraintFcn(h,fcn);
_________________ M. S. Rakha, Ph.D. Queen's University Canada