Montage of several different images

Function montage_images(X, Y) where X is a M-by-D data matrix (of floating-point numbers in double-precision format, which is the default in Matlab), where M is the number of samples, and D is the the number of elements in a sample. Note that each sample is represented as a row vector rather thana column vector. Y is a M-by-1 label vector (of uint8) for X. Y(i)is the class number ofX(i,:) which are just class labels
So, I've loaded in the dataset (not shown) and there's ten sets of this, of which I need to create a montage of the first 10 samples of each set. So, I have two for-loops and I've managed to get the images, but I'm stuck on how to compile each set of 10 images and then making it display with montage. It seems that montage doesn't play nicely with image format or something?
The X = Xtrn2(Y==k, :) gets the associated set # (1,2, .., 10).
Any help/hints would be greatly appreciated.
55618380_326336761413541_5738513565191503872_n.png

답변 (1개)

Geoff Hayes
Geoff Hayes 2019년 3월 31일

0 개 추천

From montage, the input parameter can be list of filenames or a list of images. You are providing (if I understand your code) a (single) graphics object or handle to an image. I think that you want to create the images first and then provide this list of images to the function montage. Your code would then look something like
myImages = cell(1,10);
for k = 1:10
myImages{k} = reshape(X(k,:)*255.0, 28, 28)';
end
montage(myImages);
The above may work (I haven't tested it) but hopefully it will give an idea of why your code may not be working as expected.

댓글 수: 2

John Doe
John Doe 2019년 4월 1일
Is it possible to open all 10 different montages in their own separate windows at once? After implementing this snippit, it opens all of them, but it quickly flashes through all of them in one single window and finishes on the last set of 10 images montage.
Thanks
You can try adding a call to figure before your call to montage:
myImages = cell(1,10);
for k = 1:10
myImages{k} = reshape(X(k,:)*255.0, 28, 28)';
end
figure;
montage(myImages);

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

카테고리

도움말 센터File Exchange에서 Big Data Processing에 대해 자세히 알아보기

제품

릴리스

R2018b

태그

질문:

2019년 3월 31일

댓글:

2019년 4월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by