Matlab imfilter uint8 overflow
Show older comments
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.
Answers (1)
Walter Roberson
on 9 Apr 2016
0 votes
double() the data before convolving.
5 Comments
RuiQi
on 9 Apr 2016
Walter Roberson
on 9 Apr 2016
That is a different matter. You asked how to avoid saturating at 255, and that question has been answered.
RuiQi
on 9 Apr 2016
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]);
Walter Roberson
on 10 Apr 2016
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.
Categories
Find more on Image Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!