Effacer les filtres
Effacer les filtres

why this code gives error?

3 vues (au cours des 30 derniers jours)
waruna
waruna le 29 Jan 2023
Commenté : waruna le 1 Fév 2023
color=imread('C:\Users\User\Desktop\matlab\photo.png');
gray=rgb2gray(color);
gray=double(gray);
pfs=fspecial('gaussian',[5 5],2);
motion_filter=fspecial('motion',10,45);
convolution_with_gaussian_filter=conv2(gray,pfs);
convolution_with_motion_filter=imfilter(gray,motion_filter);
self_convolution=conv2(gray,gray);
subplot(2,2,1),imshow(color);
subplot(2,2,2),imshow(convolution_with_gaussian_filter,'auto');title('1')
subplot(2,2,3),imshow(convolution_with_motion_filter,'auto');
subplot(2,2,4),imshow(self_convolution,'auto');
This is the error message:
Error using images.internal.imageDisplayParsePVPairs (line 72)
The parameter, auto, is not recognized by imageDisplayParsePVPairs
Error in images.internal.imageDisplayParseInputs (line 70)
[common_args,specific_args] = images.internal.imageDisplayParsePVPairs(varargin{:});
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in Untitled3 (line 10)
subplot(2,2,2),imshow(convolution_with_gaussian_filter,'auto');title('1')
  3 commentaires
waruna
waruna le 30 Jan 2023
Sir this is the error message;
Error using images.internal.imageDisplayParsePVPairs (line 72)
The parameter, auto, is not recognized by imageDisplayParsePVPairs
Error in images.internal.imageDisplayParseInputs (line 70)
[common_args,specific_args] = images.internal.imageDisplayParsePVPairs(varargin{:});
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in Untitled3 (line 10)
subplot(2,2,2),imshow(convolution_with_gaussian_filter,'auto');title('1')
Walter Roberson
Walter Roberson le 30 Jan 2023
'auto' is not a valid option value for any parameter or any option value for imshow.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 30 Jan 2023
Try using [] instead of 'auto':
color=imread('peppers.png');
grayImage=rgb2gray(color);
grayImage=double(grayImage);
pfs=fspecial('gaussian',[5 5],2);
motion_filter=fspecial('motion',10,45);
convolution_with_gaussian_filter=conv2(grayImage,pfs);
convolution_with_motion_filter=imfilter(grayImage,motion_filter);
self_convolution=conv2(grayImage,grayImage, 'full'); % Will be twice as big in each dimension.
subplot(2,2,1),imshow(color); axis('on', 'image');
subplot(2,2,2),imshow(convolution_with_gaussian_filter,[]); title('1'); axis('on', 'image');
subplot(2,2,3),imshow(convolution_with_motion_filter,[]); axis('on', 'image');
subplot(2,2,4),imshow(self_convolution,[]); axis('on', 'image');
  1 commentaire
waruna
waruna le 1 Fév 2023
thankyou

Connectez-vous pour commenter.

Plus de réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 29 Jan 2023
Here is the corrected code:
[color, I_map]=imread('C:\Users\User\Desktop\matlab\photo.png');
gray=rgb2gray(color);
gray=double(gray);
pfs=fspecial('gaussian',[5 5],2);
motion_filter=fspecial('motion',10,45);
convolution_with_gaussian_filter=conv2(gray,pfs);
convolution_with_motion_filter=imfilter(gray,motion_filter);
self_convolution=conv2(gray,gray);
subplot(2,2,1),imshow(color,I_map);
subplot(2,2,2),imshow(convolution_with_gaussian_filter,I_map);title('1')
subplot(2,2,3),imshow(convolution_with_motion_filter,I_map);
subplot(2,2,4),imshow(self_convolution, I_map);
  2 commentaires
Walter Roberson
Walter Roberson le 29 Jan 2023
The second output of imread is the colormap for the case that the image is an indexed image (which includes the case of GIF). In the case of non-indexed images the second output is empty.
If the image was indexed then the first output of imread would be 2d and in that case rgb2gray would be invalid.
If the image was grayscale without a map then the first output of imread would be 2d and rgb2gray would be invalid.
If the image was rgb truecolor then the first output of imread would be 3d and rgb2gray would succeed, but the second output would be empty.
That empty second output is tgen carried down to the imshow calls in the code, and becomes an empty second input to imshow. An empty second input to imshow is not interpreted as an empty colormap: it is interpreted as an empty scaling range, so the imshow would act similar to imagesc in rescaling the data so that the colormap covered the data range instead of the range implied by the data type.
waruna
waruna le 1 Fév 2023
thankyou

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by