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.

답변 (1개)
Geoff Hayes
2019년 3월 31일
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
2019년 4월 1일
Geoff Hayes
2019년 4월 1일
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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!