Is my code wrong because why am i getting this output? Use the MATLAB command conv2() to convolve image3 with itself. What is this process referred to as? Show the result.
조회 수: 1 (최근 30일)
이전 댓글 표시
Can someone explain why i got this output from this code?Is the code wrong?
img3=imread("image3 (1).png")
C = conv2(img3,img3)
imshow(C,[])
plot(C)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1223417/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1223422/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1223427/image.png)
댓글 수: 0
답변 (1개)
Walter Roberson
2022년 12월 7일
The image you posted is an RGB image, not a grayscale image. You cannot use conv2() with it, not unless you select out a single channel.
If you do select out a single channel then the plot() looks different than what you posted.
Your C is a 511 x 511 array. When you plot() it, you are asking for one line to be drawn for each column of C -- 511 lines in total. You should expect it to be difficult to make sense of such a line plot.
댓글 수: 3
Walter Roberson
2022년 12월 7일
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1223422/image.png';
img3 = imread(filename);
size(img3)
C = conv2(img3,img3);
size(C)
imshow(C, [])
Walter Roberson
2022년 12월 7일
The 480 x 522 x 3 size tells us that the image you posted is an RGB image, not a grayscale image. conv2() has never been supported for RGB images.
If you convert the posted image to grayscale and do the conv2() with itself on that, then C comes out as 959 by 1043 not the 511 x 511 that is shown in your output.
We have to conclude that the image you posted is not image3 (1).png . Perhaps what you posted is the output of the imshow() (but that is doubtful, imshow() would not have produced a 480 x 522 output for a 511 x 511 image.)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!