There are two questions here:
1) What is wrong with the GINPUT code as well as 2) How to write roiCircle or roiSquare
In response to (1) nothing happens; this code behaves as it should:
imgData = randn(100); imagesc(imgData ); [X, Y]= ginput(2) xmin=min(X); xmax=max(X); ymin=min(Y); ymax=max(Y); squareX = [xmin xmin xmax xmax xmin]; squareY = [ymin ymax ymax ymin ymin]; hold on; plot(squareX,squareY); %plot the correct square hold off;
You can use IMCROP to get data:
width = xmax - xmin; height = ymax - ymin; imgSelect = imcrop(imgData,[xmin,ymin,width,height]); figure; imagesc(imgSelect);
Regarding (2) (spelling roiCircle or roiSquare), so that they are well updated, as roiPoly does, they will require a significant (though not insurmountable) amount of MATLAB GUI programming. This is tolerable, but not trivial.
source share