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.
7 次查看(过去 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)
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!