how to fix subscripted assignment dimention mismatch in my coding?
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
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 个评论
Jan
2019-3-28
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
2019-3-28
回答(1 个)
Jan
2019-3-28
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 个评论
Pawan Kumar PS
2019-3-28
Jan
2019-3-28
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
2019-3-28
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
2019-3-28
Pawan Kumar PS
2019-3-28
Pawan Kumar PS
2019-3-28
编辑:Pawan Kumar PS
2019-3-28
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

