how to subplot 4 images?

i've captured 4 images of same scene from different angles and i want to subplot all 4 images but problem is that only two images are subplotted when i subplot the third one it says index exceeds number of subplots ,what it means ? i'm stuck in it plz help

10 件のコメント

Jing
Jing 2013 年 3 月 12 日
Can you provide the code you used?
Jan
Jan 2013 年 3 月 12 日
Obviously there is a bug in your code. Without seeing the code, it is impossible to guess where the error is.
This is a general problem in forums: The readers do not have the faintest idea about what you are doing, although it is such obviously for yourself. Therefore a general strategy is to write the question, sit back and remember the holiday at the beach. Then read the question again and imagine, whether a reader could have enough information to reconsider the problem.
Mehreen Hussain
Mehreen Hussain 2013 年 3 月 13 日
a=videoinput('winvideo');
set(a,'Returnedcolorspace','grayscale');
I=getsnapshot(a);
K=imread('firstimage.jpg');
I2=getsnapshot(a);
L=imread('image.jpg');
I3=getsnapshot(a);
M=imread('Thirdimage.jpg');
I4=getsnapshot(a);
N=imread('Image.jpg');
subplot(1,2,1);imshow(I);title('firstimage')
subplot(1,2,2);imshow(I);title('secondimage')
subplot(1,1,2);imshow(I);title('thirdimage')
error index exceed number of subplot
Mehreen Hussain
Mehreen Hussain 2013 年 3 月 13 日
i want all 4 images in one figure window where i'm making mistake do let me know plz thanks in advance
Algorithms Analyst
Algorithms Analyst 2013 年 3 月 13 日
you need to make indexing for plotting them.......
Mehreen Hussain
Mehreen Hussain 2013 年 3 月 14 日
how can i make indexing ,can u give me some hint kindly
Jan
Jan 2013 年 3 月 14 日
@Mehreen: What about Sean's answers? I do not think, that there is a beeter solution. If you need something else, please explain this in detail.
Mehreen Hussain
Mehreen Hussain 2013 年 3 月 20 日
@Jan: Saen's answer is correct but that is only for a single image plotted 4 times,my problem is that i'm capturing the images from real video and all 4 images are different and i want to plot them in one,if i use the one that Saen suggested it only plot the first image again and again,what should i do now? thanks in advance
Walter Roberson
Walter Roberson 2013 年 3 月 20 日
for ii = 1:4
subplot(2,2,ii);
imshow(rand(200,300));
end
Different images for each subplot.
Mehreen Hussain
Mehreen Hussain 2013 年 3 月 20 日
sir its not working,it is giving a dotted gray image in all 4 infact it is not showing the actuall captured images..struct in it plz help

サインインしてコメントする。

回答 (1 件)

Sean de Wolski
Sean de Wolski 2013 年 3 月 12 日

2 投票

figure;
for ii = 1:4
subplot(2,2,ii);
imshow('cameraman.tif');
end

2 件のコメント

Jan
Jan 2013 年 3 月 14 日
+1, I'd prefer image instead of imshow.
Sean de Wolski
Sean de Wolski 2013 年 3 月 14 日
@Jan, why?
Other than for just preallicating an image into existence (i.e. image(1)); I've never really found much other use for image. imshow does all of the meta stuff that I expect with an image for free.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

質問済み:

2013 年 3 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by