Reputation: 16896
I = imread ("lena.jpg");
%imshow(I);
K = I;
C = conv2(I, K);
imshow(C);
I am expecting something like the following as indicated in this link.
But, my octave output is blank:
What could be the possible reason?
And, how can I obtain the expected output?
Upvotes: 0
Views: 1442
Reputation: 10792
imshow()
expect values between [0-255]. After your convolution all your value are way above 255. So of course when you use imshow(C)
, matlab/octave do a type conversion using uint8()
. All your value equal 255 and the result is a white image. (0 = black, 255 = white).
You also should take into account severals things:
add the option 'same' to your convolution to preserve the original size of your image: conv2(I,K,'same')
If you only apply the convolution like that, you will obtain a strong border effect, because the central values of your image will be multiplied more time than the values in the border of your image. You should add a compensation matrix:
border_compensation = conv2(ones(size(K)),ones(size(K)),'same')
C = conv2(I,K,'same')./border_compensation
Normalize the final result (Don't take into account the point 2. if you really want the kind of output that you pointed out in your question)
C = uint8(C/max(C(:))*255)
Upvotes: 3