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!