Issue with imresize, resizeParseInputs
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
DGM
am 2 Jan. 2024
Bearbeitet: DGM
am 2 Jan. 2024
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 Kommentar
Weitere Antworten (1)
Cris LaPierre
am 2 Jan. 2024
Bearbeitet: Cris LaPierre
am 2 Jan. 2024
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 Kommentare
Siehe auch
Kategorien
Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!