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.

2 ビュー (過去 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)

回答 (1 件)

Walter Roberson
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
Walter Roberson 2022 年 12 月 7 日
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1223422/image.png';
img3 = imread(filename);
size(img3)
ans = 1×3
480 522 3
C = conv2(img3,img3);
Error using conv2
N-D arrays are not supported.
size(C)
imshow(C, [])
Walter Roberson
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 ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by