Laplacian and sobel for image processing

Hello im having trouble finding how to do the laplacian and sobel of an image I tried the following but none of the 2 results are like what is showed in the book The original image i'm working on is image (a)
Code I tried:
img = imread ('imagename'); A=[0 -1 0 ; -1 4 -1 ; 0 -1 0]; result1 = imfilter (img,A); result2 = conv2 (img,A);
********************
Here are the book results

 Accepted Answer

Well you're not doing the Laplacian or Sobel. Try using the correct kernel and the correct function imgradient). Try the code I wrote for you below in blue.

8 Comments

Thank you very much and sorry I was posting when you typed this so I didnt see This works exactly like I wanted
Sir, your answer is really good and superb. I really admire your help.
great job, thx.
@Image Analystwhy the low frequency part of image after DWT is blank and when i tried to encrypt that image with hyperchaotic encryption it came that the size not symmetric so i rotated the same image and concad four images as a single image and when i done encryption the histogram came like this.What can be alternative to DWT ?
@shyam kumarmanickam I don't think this question of yours on wavelets, chaos, and encryption has anything to do with the original question from @John Snow on x-rays, Sobel filtering, and Laplacian filtering. So you should start your own question and tag it with wavelets, chaos, and encryption. I do not have the Wavelet Toolbox though so I won't be able to help you.
Read this link first though:
@Image Analyst Hello i have a question on the Laplcian why did u divided it by 8
laplacianKernel = [-1,-1,-1;-1,8,-1;-1,-1,-1]/8;
To make sure that the output values of hte convolution were in the same range as the input image. Otherwise, worst case where the center value is 255 and the outer values are zero then the output would be 8*255. That is more than the range of the input values. So just to make sure that case would get you a value of 255 instead of 8*255, I divided by 8.

Sign in to comment.

More Answers (1)

Make sure img is in right format. imfilter will work on a grayscale uint8 image. However, conv2 will only work on a double image. Use im2double to convert it.

5 Comments

I converted but no matter what I do the image (b) [second image] doesnt come up like in the book
Can you post a link to the image so that I can try?
ofcourse here is a link because this site doesnt accept .tif http://www.mediafire.com/view/myfiles/#csmrno3bv6wi2s3
John, my code does exactly what you wanted.
Sorry I was typing this when you posted I accepted the answer its perfect

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!