필터 지우기
필터 지우기

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 CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by