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

1 回表示 (過去 30 日間)
matlab_user
matlab_user 2018 年 6 月 4 日
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,...

回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by