crop the image and after cropping display the cropped image on axes

3 views (last 30 days)
i have an image and i want to crop it i applied this code but its only cropping the image but not showing the cropped image on the axes :
I=imcrop(Iedge2);
pause(2)
imshow(I,'Parent',handles.axes2);
title('cropped image')
i want to show the message on the top of the axes area that "crop the image" when the crop process occurs and after selection of the area the cropped area will be shown to the `axes2 .some body please tell me is there is any function or method to do so?
thanks and regards`

Answers (1)

Image Analyst
Image Analyst on 22 May 2016
imshow() does not change the current axes if you specify a Parent axes, therefore title will display over the current axes, which might not be axes2. To avoid confusion, I always call axes() before doing anything with an axes. This will change the current axes and everything you do from then on (without specifically referring to an axes) will happen at the axes you just passed in to axes():
axes(handles.axes2); % Change current axes, gca, to handles.axes2
imshow(I, []); % No need to specify 'Parent' now.
title('Cropped Image', 'FontSize', 20);
  8 Comments
Image Analyst
Image Analyst on 12 Jun 2016
I think you're right. Now I seem to remember running across this before and I called the Mathworks about it. I think they might have given me some work around but I don't remember what it might have been. Try calling them. Alternatively you could just use text() to put some text into the overlay - see if that will remain after imcrop is called. Or (this I'm pretty sure will definitely work), just use GUIDE or uicontrol() to place a static text label somewhere on the figure window.

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!