After converting an image x
to a black and white image by using im2bw(x)
, imfilter
returns black and white images only. How can I convert this black and white image into a normal matrix such that imfilter
can return a matrix of reals? Demo:
>> k = [0.3 0.3; 0 0.3];
>> x = [0.9 0.3; 0.4 0.2];
>> y = im2bw(x)
y =
1 0
0 0
>> imfilter(y, k)
ans =
1 0
0 0
>> imfilter([1 0; 0 0], k)
ans =
0.30000 0.00000
0.00000 0.00000
>>
As you can see, imfilter
rounds the results when applying to a binary image. I would like to prevent this. How can I convert the binary image to a regular matrix while keeping its values?