Matlab: How can I display several outputs in the same image?

Deadly 提交于 2019-12-11 06:24:39

问题


Let's say my image is img=zeros(100,100,3), my outputs are several ellipse which i get using a created function [ret]=draw_ellipse(x,y,a,b,angle,color,img), I can display one ellipse using imshow(ret).For the moment, I'm trying to show serval ellipse in the image. But i don't know how to code it. will ‘for loop’ work or I need to hold them?


回答1:


If this is related to what you were doing in your previous question, then what you need to do is to pass the result of one iteration as input to the next.

So assuming that the function [ret]=draw_ellipse(x,y,a,b,angle,color,img) you mentioned takes as input an image img and returns the same image with an ellipse drawn on it, you could do this:

%# ellipses parameters
%#x = {..}; y = {..};
%#a = {..}; b = {..};
%#angle = {..}; color = {..};

img = zeros(200,100,'uint8');     %# image to start with
for i=1:10
    img = draw_ellipse(x{i},y{i}, a{i},b{i}, angle{i}, color{i}, img);
end
imshow(img)



回答2:


I'm a bit unsure of what you want. You want to show several ellipse in one image, like plotting several graphs with hold on?

There is no equivalent command for images, but a simple solution is to add the ellipses into one image and show that one:

several_ellipse = ellipse1 + ellipse2 + ellipse3;
imshow(several_ellipse)



回答3:


Presumably you want to pass ret as the final input to the next call to draw_ellipse.



来源:https://stackoverflow.com/questions/7765219/matlab-how-can-i-display-several-outputs-in-the-same-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!