how to solve "Subscripted assignment dimension mismatch" error ?

2 次查看(过去 30 天)
Hi everyone, any help on this will be highly appreciated!!
i have 3D image. Here is my program:
T=imread('....'); %host image
M=imresize(T,[400 400]);
I=im2double(M);
figure(1),imshow(I);
title('Host Image','color','b');
HSV=rgb2hsv(I);
%separate host image into H S & V components
H_plane=HSV(:,:,1);
S_plane=HSV(:,:,2);
V_plane=HSV(:,:,3);
%combine H S & V component
I1(:,:,1)=H_plane;
I1(:,:,2)=S_plane;
I1(:,:,3)=V_plane1;
figure(3),imshow(I1);
When I run the program, the error "subscripted assignment dimension mismatch" will show up, I really dont know how resolve it. I want I1 dimension should be [400 400 3]

采纳的回答

Guillaume
Guillaume 2014-11-19
编辑:Guillaume 2014-11-19
It would be so much easier to help you if you'd shown the complete error message, particularly the bit that tells you which line the error occurs on.
As a guess, the error occurs on
I1(:, :, 1) = H_plane;
because I1 already exists and is not the same size as HSV. So,
I1 = zeros(size(HSV));
before the previous line should solve it.
------
However, I don't particularly see the point of separating the three components to recombine exactly the same way. In the end, your code is equivalent to
I1 = HSV;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by