Rotate image will remove any other image effects in MATLAB

5 views (last 30 days)
I made a simple image processing project by using MATLAB with GUI, i have a button for uploading an image, another button for making the image black and white and another button to rotate the image. When i press the black and white effect button it works great, but when i press the rotate button the black and white effect will be removed after rotating. How can i fix that ?

Accepted Answer

Image Analyst
Image Analyst on 5 Apr 2015
Sounds like you are operating on the original image rather than on the gray scale version. How are you getting the image into your callback function for the rotate button? Are you using getimage() to pull it out of the axes? Are you using one of the ways on the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F ????
  4 Comments
Ahmed El sherif
Ahmed El sherif on 6 Apr 2015
I made it like that
% --- Executes on button press in loadimage.
function loadimage_Callback(hObject, eventdata, handles)
global im1 im2
path=imgetfile();
im1=imread(path);
im1=im2double(im1);
imshow(im1);
im2=im1;
% --- Executes on button press in b_n_wbtn.
function b_n_wbtn_Callback(hObject, eventdata, handles)
global im1 a
a=im2bw(im1);
imshow(a);
% --- Executes on button press in rotate90.
function rotate90_Callback(hObject, eventdata, handles)
global im1 a
f=imrotate(a,90);
imshow(f);
But now it will always rotate the image and make it black and white automatically, what if i want to rotate the original image ?
Image Analyst
Image Analyst on 6 Apr 2015
If you want to rotate the binary image, pass a into imrotate(). If you want to rotate the original image, pass im1 into imrotate.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!