How to resize a 3D image into a 4D matrix to use in montage function?

1 Ansicht (letzte 30 Tage)
matlab_user
matlab_user am 4 Jun. 2018
I have some images that I am trying to read in and display as one single image using montage.
At each for loop I read in a new image I and its edge-detected version E. I want to store each 3D array image(one dimension being color) into a cell array. I put the original images in the top row and the edge versions in the bottom row, with the intention that that is how I want them to be displayed in the final image.
In order to do this I have to resize all the images to make sure they are the same size.
However, I am running into errors with imresize. This is what I know so far:
  • imresize only resizes the first two dimensions
  • the montage function takes in a M-by-N-by-1-by-K array
So I believe the issue is that I can't resize it into a 4D array, but I need to in order to use montage. I considered using reshape but I don't think that will work since it doesn't permanently change the size.
Is there any way I can still use resize? Or are there other alternatives?
for i=1:num_imgs I = imread(directory); %read in the image as a 3d matrix E = edgesDetect(I,model);
I = imresize(I,[600 800 1 3]); %resize into 600x800x1x3
E = imresize(E, [600 800 1 3]);
montageImage = cell(2,5); % create a cell with two rows, five columns
for ii=1:num_imgs
montageImage{1}{ii} = I; %store original images in first row
montageImage{2}{ii} =(1-E);
end
end
montage(montageImage)
Note: If I try to simply resize it to be [600 800] without the extra dimensions, I get the following error in montage:
[bigImage, cmap] = images.internal.createMontage(Isrc, thumbnailSize,...

Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by