Return a graph and an image from a function

7 次查看(过去 30 天)
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