Combine Images to display on single page
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have multiple sets of 21 images that I would like to display either as a single image or as on one page, which ever is easier. For simplicity I only uploaded 4 here.
I have tried the code below, but I received error messages.
fileFolder = fullfile(matlabroot,'toolbox','images','imdata');
dirOutput = dir(fullfile(fileFolder,'trajplot_*.png'));
fileNames = string({dirOutput.name});
montage(fileNames, 'Size', [2 2]);
Error using montage>getImagesFromFiles (line 366)
FILENAMES must be a cell array of strings or character vectors.
Error in montage>parse_inputs (line 243)
[I,cmap] = getImagesFromFiles(varargin{1});
Error in montage (line 114)
[I,cmap,mSize,indices,displayRange,parent] = parse_inputs(varargin{:});
img1 = imread('trajplot_C1_0012_10m.png');
img2 = imread('trajplot_C2_0012_10m.png');
img3 = imread('trajplot_C3_0012_10m.png');
img4 = imread('trajplot_C5_0012_10m.png');
>> multi = cat(3,img1,img2,img3);
>> montage(multi);
Error using images.internal.imageDisplayValidateParams>validateCData (line
115)
Multi-plane image inputs must be RGB images of size MxNx3.
Error in images.internal.imageDisplayValidateParams (line 27)
common_args.CData = validateCData(common_args.CData,image_type);
Error in images.internal.imageDisplayParseInputs (line 78)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 241)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in montage (line 156)
hh = imshow(bigImage, displayRange,parentArgs{:});
>> multi = cat(4,img1,img2,img3,img4);
>> montage(multi);
%%The image shows up, but is one giant black square.%%
img1 = imread('trajplot_C1_0012_10m.jpeg');
img2 = imread('trajplot_C2_0012_10m.jpeg');
img3 = imread('trajplot_C3_0012_10m.jpeg');
>> multi = cat(3,img1,img2,img3);
montage(multi);
Error using images.internal.imageDisplayValidateParams>validateCData
(line 115)
Multi-plane image inputs must be RGB images of size MxNx3.
Error in images.internal.imageDisplayValidateParams (line 27)
common_args.CData = validateCData(common_args.CData,image_type);
Error in images.internal.imageDisplayParseInputs (line 78)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 241)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in montage (line 156)
hh = imshow(bigImage, displayRange,parentArgs{:});
Does anyone know what is going on? Are my images in the wrong format or possibly too big?
The original files are in .ps format and were converted to .png using an online converter. If they need to be converted into something else, please let me know.
0 Kommentare
Antworten (2)
Image Analyst
am 2 Jan. 2019
They appear, from the error message, to not be RGB images. Do they have an alpha plane or something?
What does this say?
whos img1
size(img1)
If it's not 3 planes, then you might take the first 3, if those represent R, G, and B.
img1 = img1(:,:,1:3);
or somehow otherwise process it until you get 3 planes. Attach two of your PNG files if you need more help.
Image Analyst
am 2 Jan. 2019
Don't cat() them together into a 4-D array, just use montage():
multi = montage(img1,img2,img3,img4);
9 Kommentare
Image Analyst
am 9 Jan. 2019
I think the alpha channel can only be gray scale, not RGB, so you're better off trying to get them saved in a normal way in the first place, rather than how they are now.
To get rid of the border, try thresholding and cropping after the montage has been made.
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!