how to fix subscripted assignment dimention mismatch in my coding?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
clc;
clear all;
close all;
%%input images
im1 = imread('31-0000.jpg') ;
im2 = imread('32-0000.jpg') ;
im3 = imread('33-0000.jpg') ;
im4 = imread('34-0000.jpg') ;
im5 = imread('35-0000.jpg') ;
im6 = imread('36-0000.jpg') ;
im7 = imread('37-0000.jpg') ;
im8 = imread('38-0000.jpg') ;
M(:,:,1) = im1 ;
M(:,:,2) = im2 ;
M(:,:,3) = im3 ;
M(:,:,4) = im4 ;
M(:,:,5) = im5 ;
M(:,:,6) = im6 ;
M(:,:,7) = im7 ;
M(:,:,8) = im8 ;
hf2 = figure ;
hs = slice(M,[],[],1:8) ;
shading interp
set(hs,'FaceAlpha',0.8);
all images are of dimentions 250x306
2 Comments
Jan
on 28 Mar 2019
I've formatted your code today. Please use the buttons for formatting in the future. Thanks.
If you post a copy of the complete error message, the readers do not have to guess, where the problem occurs.
Pawan Kumar PS
on 28 Mar 2019
Answers (1)
Jan
on 28 Mar 2019
The posted code works as expected. Please confirm, that this causes the same problem:
M = rand(250, 306, 8);
hs = slice(M,[],[],1:8) ;
shading interp
set(hs,'FaceAlpha',0.8)
If this does not create the same problem, the difference must be found inside te assignment of M:
M(:,:,1) = im1 ;
M(:,:,2) = im2 ;
...
Either the assumption is wrong, that "all images are of dimentions 250x306". Or the images are RGB images with the dimension [250 x 306 x 3].
7 Comments
Pawan Kumar PS
on 28 Mar 2019
Jan
on 28 Mar 2019
Please post the full code. Now your M is not a single or double, so I guess, that you have converted the image data to uint8. Without seeing the code, I can only guess, what is going on.
Pawan Kumar PS
on 28 Mar 2019
M = zeros(25, 50, 8);
for k = 1:8
img = imread(sprintf('%d-0000.jpg', k + 30));
img = imresize(img, [25 50]);
img = im2double(rgb2gray(img)); % Convert to double format
M(:, :, k) = img;
end
hf2 = figure ;
hs = slice(M,[],[],1:8) ;
shading interp
set(hs,'FaceAlpha',0.8);
Pawan Kumar PS
on 28 Mar 2019
Pawan Kumar PS
on 28 Mar 2019
Pawan Kumar PS
on 28 Mar 2019
Edited: Pawan Kumar PS
on 28 Mar 2019
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
