Return a graph and an image from a function

조회 수: 9 (최근 30일)
Jose Silva
Jose Silva 2018년 6월 17일
댓글: Jose Silva 2018년 6월 17일
Hi "mathelabers" :p I'm stuck and I hope that someone can help me. So, I'm using matlab to process two images. I did a function to do it and it is working fine, since I´m using the "figure" to show both image and graph as shown below.
if true
figure;
hold on;
plot(dicomImage(centerRow, :), 'r');
plot(tiffImageAligned(centerRow, :), 'b');
plot(difference, 'Color', 'cyan', 'LineWidth', 1);
xlim([1 dcmColumns]);
ylim([-10 101]);
line([1 dcmColumns], [0 0], 'Color', 'black', 'LineStyle', '--');
%line([centerColumn centerColumn], [0 100], 'Color', 'black', 'LineStyle', '--');
legend('DICOM', 'TIFF', 'Difference');
hold off;
figure,
imshowpair (dicomImage,tiffImageAligned,'Scaling','joint');
end
The big problem is that I want to show the same images but using a GUI in different axes. I was thinking declare the variable as global and then create a function that returns the graph, but It's not working. If I chose the axes before calling my function and only return the "imshowpair" it's perfect, but I don't know how to return the graphic.
Can someone help me?
Thank youuuu
  댓글 수: 3
Jose Silva
Jose Silva 2018년 6월 17일
Yes,the function output is the handle of two images. In the pictures below is a sample of the output ( the graphic(figure 1) and the match of both images (figure 2)).
So in GUI, I will load both figures (It's working fine) and then I will call my function when the button match is pressed. After that I want the graphic and the match to be shown in the "free" boxes of the GUI.
Jose Silva
Jose Silva 2018년 6월 17일
"If you have a function and you need parts of the output to be placed into different axes, then why not just pass the handles of the axes into the function and have the function draw directly into the appropriate axes?"
Nice idea! How exactly can I do it? Just adding an argument in function and pass the handle? I'm not used to program in matlab :D

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by