I am getting Subscripted assignment dimension mismatch in the following code

1 回表示 (過去 30 日間)
Boris
Boris 2014 年 3 月 25 日
コメント済み: Boris 2014 年 3 月 25 日
I am getting Subscripted assignment dimension mismatch error in the following code:
Error in (line 18) ntscIm(:,:,1)=sgI(:,:,1);
Can you help me please, how can I fix this?
g_name='example.bmp';
c_name='example_marked.bmp';
out_name='example_out.bmp';
%
%
solver=2;
gI=double(imread(g_name))/255;
cI=double(imread(c_name))/255;
colorIm=(sum(abs(gI-cI),3)>0.01);
colorIm=double(colorIm);
sgI=rgb2ntsc(gI);
scI=rgb2ntsc(cI);
ntscIm(:,:,1)=sgI(:,:,1);
ntscIm(:,:,2)=scI(:,:,2);
ntscIm(:,:,3)=scI(:,:,3);

採用された回答

Boris
Boris 2014 年 3 月 25 日
∫Found out myself:
A = sgI(:,:,1);
B = scI(:,:,2);
C = scI(:,:,3);
[m,n,l] = size(A);
[m1,n1,l1] = size(B);
[m2,n2,l2] = size(C);
ntscIm(1:m,1:n,1) = A;
ntscIm(1:m1,1:n1,2) = B;
ntscIm(1:m2,1:n2,3) = C;
is the correct solution. and it works!!!! :))))

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 3 月 25 日
Are you looping over this sequence? So ntscIm might already have a value from the last time through the loop? And that value might happen to be a different array size?
  1 件のコメント
Boris
Boris 2014 年 3 月 25 日
Found out myself. First hours in studying MATLAB :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by