why this code gives error?
조회 수: 1 (최근 30일)
표시 이전 댓글
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
Walter Roberson
2023년 1월 30일
'auto' is not a valid option value for any parameter or any option value for imshow.
채택된 답변
Image Analyst
2023년 1월 30일
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개)
Sulaymon Eshkabilov
2023년 1월 29일
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);
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!