开发者

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

开发者 https://www.devze.com 2023-04-13 03:44 出处:网络
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 usi开发者_如何学

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 usi开发者_如何学Gong 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?


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)


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)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号