Why do I get the error message "Subscripted assignment dimension mismatch"?
조회 수: 3 (최근 30일)
이전 댓글 표시
Subscripted assignment dimension mismatch.
Error in L1SR (line 144)
hIm(1:3, :) = bhIm(1:3, :);
Error in yima (line 60)
ReconIm = L1SR(lowIm, zooming, patch_size, overlap, Dh, Dl, lambda, regres);
Error in Research_Experiment (line 248)
res{2} = {yima(low{1}, upscaling)};
The highlighted Line (144) to Line (148) has these on code
hIm(1:3, :) = bhIm(1:3, :);
hIm(:, 1:3) = bhIm(:, 1:3);
hIm(end-2:end, :) = bhIm(end-2:end, :);
hIm(:, end-2:end) = bhIm(:, end-2:end);
Why do I have these errors ??
Thanks
댓글 수: 0
채택된 답변
Walter Roberson
2018년 11월 22일
You have
[lhg, lwd] = size(lIm);
hhg = lhg*zooming;
hwd = lwd*zooming;
[...]
hIm = zeros([hhg, hwd]);
Assuming that a grayscale image was passed in, the size of lIm will be multiplied by zooming (which is not certain to be an integer by the way) and the result is used to construct hIm . Imagine that lIm is 256 x 256 and that zooming is set to 2, then 256*2 by 256*2 would give a hIm of 512 by 512.
You also have
bhIm = imresize(lIm, 3, 'bicubic');
If the original image lIm were 256 x 256 then the result of bhIm would be 768 x 768.
Now you do
hIm(1:3, :) = bhIm(1:3, :);
Left hand side variable would be 512 x 512, right hand side variable would be 768 x 768. You select three rows and all of the columns of the left hand side as the destination, so that would be 3 x 512 as the destination. The source is three rows and all the columns so that would be 3 x 758 as the source. You cannot store 2304 elements in a space only big enough for 1536.
댓글 수: 5
Walter Roberson
2018년 11월 23일
Within the context of the code, what good does mIm do you? What good does bhIm do you? Why do they exist? How big are they expected to be? How do they fit into the computation? We know that hIm exists because it is the output variable. Why does hIm end up with places that need to be copied onto? What should be the source for that copying?
추가 답변 (1개)
madhan ravi
2018년 11월 22일
편집: madhan ravi
2018년 11월 22일
size(hIm(1:3, :)) and size( bhIm(1:3, :)) have to be the same to get rid of your error.
댓글 수: 14
Walter Roberson
2018년 11월 24일
The L1SR code that you had in https://www.mathworks.com/matlabcentral/answers/425572-how-to-decrypt-a-mat-file#comment_627929 has the line
bhIm = imresize(lIm, zooming, 'bicubic');
whereas in this present code, you replaced zooming with 3. If it is left as zooming then there is no conflict with the rest of the code.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Exploration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!