Issue with imresize, resizeParseInputs
6 次查看(过去 30 天)
显示 更早的评论
https://www.mathworks.com/matlabcentral/answers/2065691-brace-indexing-into-the-result-of-a-function-call-is-not-supported
Error using resizeParseInputs
Expected input number 2, [MROWS NCOLS], to be positive.
Error in matlab.images.internal.resize.resizeParseInputs>scaleOrSize (line 215)
validateattributes(arg, {'numeric'}, {'vector', 'real', 'positive'}, ...
Error in matlab.images.internal.resize.resizeParseInputs>parsePreMethodArgs (line 163)
[scale, output_size] = scaleOrSize(next, next_arg);
Error in matlab.images.internal.resize.resizeParseInputs (line 28)
parsePreMethodArgs(varargin, method_arg_idx, first_param_string_idx);
Error in imresize (line 153)
params = matlab.images.internal.resize.resizeParseInputs(args{:});
Error in focusStack>recontructFromPyramid (line 59)
expanded = imresize(resultImage, size(pyramid{level}), 'bilinear');
Error in focusStack (line 21)
resultImage = recontructFromPyramid(blendedPyramid);
Hello, I had another issue with the code from the link. I understand that the issue may stem form the argument for the for loop being negative when the input for resize needs to be positive. Is there a way to make this work?
2 个评论
采纳的回答
DGM
2024-1-2
编辑:DGM
2024-1-2
See the comments. It ran without errors, but I don't know if the output is right or if I'm using it correctly.
%blend the laplacian pyramid to create the final result
function blendedPyramid = blendLaplacianPyramids(pyramid)
numLevels = numel(pyramid{1});
blendedPyramid = cell(1, numLevels);
for level = 1:numLevels % this loop variable is already called 'level'
blendedLevel = zeros(size(pyramid{1}{level}));
for plevel = 1:numel(pyramid) % so name this something different
blendedLevel = blendedLevel + pyramid{1}{plevel};
end
blendedPyramid{level} = blendedLevel;
end
end
%Reconstruct image from blended Laplacian
function resultImage = recontructFromPyramid(pyramid)
numLevels = numel(pyramid);
resultImage = pyramid{numLevels};
for level = numLevels-1:-1:1
% geometry passed to imresize() can't be longer than 2
expanded = imresize(resultImage, size(pyramid{level},1:2), 'bilinear');
resultImage = expanded + pyramid{level};
end
end
更多回答(1 个)
Cris LaPierre
2024-1-2
编辑:Cris LaPierre
2024-1-2
At least one of your resize dimensions is 0. It appears, then, that your code is producing a result you did not anticipate. Check your code and if necesesary add a check so that your resize dimensions can never be 0.
img = imread("peppers.png");
% This works
img1 = imresize(img,[5,5],"bilinear");
% This reproduces your error
img2 = imresize(img,[0,5],"bilinear");
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!