0

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:

https://i.stack.imgur.com/RMz1b.jpg (1st one original picture, 2nd greyish one, 3rd sharpened image)

Thank you for your help.

Shai
  • 111,146
  • 38
  • 238
  • 371
user1907578
  • 33
  • 1
  • 3

1 Answers1

5

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.

Shai
  • 111,146
  • 38
  • 238
  • 371
  • @user1907578 - is your result image `r` is what you expect? Is your only problem is the "greyishness: of `f1`? It is possible that the only issue is the scaling of the displayed image `f1`. Since this image has both positive and negative values its scaling is non trivial and may vary from software to software. This might be the reason why your displayed `f1` **looks** different than the one in your reference book, but the values are the same. – Shai Dec 16 '12 at 10:39
  • 1
    My f1's background previously near black just like: http://i.imgur.com/tEuKz.jpg But after getting this reference book also did this: http://i.imgur.com/JBRAi.jpg – user1907578 Dec 16 '12 at 10:51
  • To sum up, I added first one to the original but reference book added second one to the original. Because of that I am confused. And not sure for my result "r" – user1907578 Dec 16 '12 at 11:02
  • Unfortunately, it didn't solve my problem but just like before I said, these infos are useful (especially for me because I'm beginner and don't know most of you said) and thank you again. :) – user1907578 Dec 16 '12 at 16:52