Error in imnoise>ParseInputs

10 visualizzazioni (ultimi 30 giorni)
Tenati Rats
Tenati Rats il 9 Giu 2021
Risposto: DGM il 3 Feb 2023
code
I = imread('Image.png');
subplot(2, 2, 1),
imshow(I)
title("Original image");
% adding salt and pepper noise
s = imnoise(I, "salt & pepper", 0.20);
subplot(2, 2, 2),
imshow(s);
title("Salt and Pepper noise");
I am trying to add the noise to a grayscale image by using imnoise function, but getting the inputparse error. The error is:
Error in imnoise>ParseInputs (line 114)
a = im2double(a);
Error in imnoise (line 86)
[a, code, classIn, classChanged, p3, p4] = ParseInputs(args{:});
Error in noise (line 7)
s = imnoise(I, "salt & pepper", 0.20);
kindly help please.
thanks in advance

Risposte (1)

DGM
DGM il 3 Feb 2023
We know that imread() will only return an array of class 'logical', 'uint8', or 'uint16' when given a PNG image. Since only a single output is specified, the array can only be MxNx1 or MxNx3.
If the array were class 'logical', imnoise() would throw an error during input validation, so it wouldn't even make it to line 114.
If the array were 'uint8' or 'uint16', either one should be able to be handled by im2double() without issue, regardless of whether it's single-channel or RGB.
So that leaves us to conclude that either im2double() is missing, corrupted/modified, or shadowed by some user-defined function. I suspect that in any case, there would have been more error messages that weren't included, but that's moot now.
If you think im2double() is being shadowed, check to see.
which im2double -all
/MATLAB/toolbox/matlab/images/im2double.m /MATLAB/toolbox/matlab/bigdata/@tall/im2double.m % tall method /MATLAB/toolbox/parallel/gpu/@gpuArray/im2double.m % gpuArray method /MATLAB/toolbox/parallel/parallel/@codistributed/im2double.m % codistributed method
If you see user-defined functions there, rename them. If images/im2double.m is missing, then you'll have to find out why. Im2double() used to be part of IPT, but regardless of version, if you have imnoise(), you should have im2double().

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by