try
imshow( f1, [] ); title('Laplacian filtered image');
Adding []
in imshow
should scale the grey level image, and you should see the greyish result you are aiming at.
EDIT :
Another thing that may cause issues is the data type of your image. If your image is stored as uint8
type, than it will not have negative values (because of the unsigned
type).
try:
img = im2double( image1 ); % convert image from uint to double
f1 = imfilter( img, m );
figure; imshow( f1 ); title( 'Laplacian filtered image' );
r = img - f1; % perform the image editing with double precision variables and NOT with unsigned ints.
r = im2uint( r ); % if you have to -cast only the final result to unsigned ints.
As a general principle, always perform image manipulation on floating-point images and refrain from doing manipulations on unsigned int images.
If you have no choice (hardware / memory constraints) and you must perform manipulations using unsigned int images - bear in mind that negative values are not represented and large values are cropped. Your manipulation should be able to handle these cases.