Matlab imfilter uint8 overflow

Hello,
I created a gaussian filter. Then I divide every element by the smallest element so my gaussian filter is in integer. When i convolve an image with it, I get 255 for everything. How do I fix this ? I want to convolve using integer values not decimals. Thanks.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 4월 9일

0 개 추천

double() the data before convolving.

댓글 수: 5

RuiQi
RuiQi 2016년 4월 9일
I am trying to prove the linearity of the gaussian ie G(Ia + Ib) = G(Ia) + G(Ib). I tried subtracting the result before getting the max element in the result G(Ia+Ib) - G(Ia) - G(Ib) but I cant seem to get a zero.
Walter Roberson
Walter Roberson 2016년 4월 9일
That is a different matter. You asked how to avoid saturating at 255, and that question has been answered.
RuiQi
RuiQi 2016년 4월 9일
ok but imshow gives me white what do i do
Guillaume
Guillaume 2016년 4월 9일
편집: Guillaume 2016년 4월 9일
With doubles, by default imshow assumes the range [0 1] for intensities. Convert the data back to uint8, or specify the DisplayRange in imshow to be [0 255]:
imshow(uint8(yourimage));
%or
imshow(yourimage, [0 255]);
imagesc(yourimage)
to display it automatically scaled according to the data it contains. This will not be the same as either of Guillaume's suggestions (which would normally be valid) because your filters are producing values larger than 255.

댓글을 달려면 로그인하십시오.

태그

질문:

2016년 4월 9일

댓글:

2016년 4월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by