How to do image rotation in matlab?

조회 수: 2 (최근 30일)
Nimra Azmat
Nimra Azmat 2019년 6월 23일
댓글: Rik 2020년 10월 30일
How to make gui for image rotation.i need the code to get image rotated at every time i press pushbutton when i upload an image.
a=getappdata(0,'a');
aclock=a;
aclock=imrotate(aclock,270);
axes(handles.axes1);
imshow(aclock);
  댓글 수: 2
Rik
Rik 2019년 6월 23일
This code looks like it should work. What is your question? What isn't this code doing that you want it to do?
Rik
Rik 2019년 6월 23일
Comment mistakenly posted as answer by Nimra Azmat:
it only rotate the image once and when i move it on the other angle (anticlock) it process the orignal image i want my code to change the orginal image and change it according to button press on any command

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2019년 6월 23일
It is a bit strange to store your image with getappdata on the graphics root, instead of with guidata. You will also notice that you aren't actually saving the result anywhere, so the function you've written only rotates the original image.
If you want to rotate the image in every callback, you need to store your image back somewhere, so in your case something like this should work:
a=getappdata(0,'a');
aclock=a;
aclock=imrotate(aclock,270);
axes(handles.axes1);
imshow(aclock);
setappdata(0,'a',aclock)

추가 답변 (1개)

NAJMA FAYAZ
NAJMA FAYAZ 2020년 10월 30일
Try This
global a
a=imrotate(a,270);
axes(handles.axes1);
imshow(a);
  댓글 수: 1
Rik
Rik 2020년 10월 30일
I admit that I should have been more vocal about storing data in the appdata of the groot (instead of the GUI figure), but a global is definitely worse.
For future edits: you can find a sandbox and instructions for the editor here.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by