Hi everyone. I need some help to add one image into multiple axes.
I want my program to be something like on this picture:
When I select open image menu, it will browse for a picture. Then, I want that one picture to be displayed on those three axes area (Method A, Method B, and Proposed Method).
Here's my current code. PS: Please don't laugh at my code because i'm still a newbie here.
function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
project=guidata(gcbo);
[filename,directory]=uigetfile({'*.bmp';'*.*'},'Open Image');
I=imread(strcat(directory,filename));
I1=imread(strcat(directory,filename));
I2=imread(strcat(directory,filename));
set(project.figure1,'CurrentAxes',project.axes1);
set(imshow(I));
set(project.axes1,'Userdata',I);
set(project.figure1,'Userdata',I);
set(project.figure3,'CurrentAxes',project.axes3);
set(imshow(I1));
set(project.axes3,'Userdata',I1);
set(project.figure3,'Userdata',I1);
set(project.figure4,'CurrentAxes',project.axes4);
set(imshow(I2));
set(project.axes4,'Userdata',I2);
set(project.figure4,'Userdata',I2);
Can i get some help guys? Any advice would be highly appreciated.

 채택된 답변

Geoff Hayes
Geoff Hayes 2016년 3월 6일

2 개 추천

Pearly - perhaps try using the Parent property of imshow to indicate which axes you wish to "show" the image on. For example,
% read the image
myImg = imread(fullfile(directory,filename));
% show the image on each axes
imshow(myImg,'Parent',handles.axes1);
imshow(myImg,'Parent',handles.axes2);
imshow(myImg,'Parent',handles.axes2);
The above eliminates the need to read the image three times from file. Note how fullfile is used to concatenate the filename parts. Also, the handles structure is used to obtain the handle to each of the three axes (as opposed to the project that you are referencing).
Try the above and see what happens!

댓글 수: 2

Thanks a lot Geoff. You're the best!
It works just the way i wanted.
Geoff Hayes
Geoff Hayes 2016년 3월 7일
Glad that it worked out, Pearly!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

질문:

2016년 3월 6일

댓글:

2016년 3월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by