Question

I am new at Image Processing.

Now, I am studying on Laplacian Sharpening Methods. But there is a thing that I could not understand. I hope you can help me.

As you all know, sharpened images occur when we add laplacian filtered image to original image.

But after getting laplacian filtered image my reference book scales this laplacian filtered image for display purposes and get a greyish image. And add this greyish one to the original image and in conclusion get a sharpened image.

My problem is how can I get this greyish image.

Here is my code:

image1=imread('hw1image1.tif');
m=[1 1 1; 1 -8 1; 1 1 1];
f1=imfilter(image1,m);
r=image1-f1;
subplot(1,3,1);
imshow(image1);
subplot(1,3,2);
imshow(f1);
subplot(1,3,3);
imshow(r);

f1 is laplacian filtered image. But it is not greyish as you all know. How can I get this greyish one?

Edit:

http://i.imgur.com/9qqXX.jpg (1st one original picture, 2nd greyish one, 3rd sharpened image)

Thank you for your help.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top