필터 지우기
필터 지우기

Laplacian and sobel for image processing

조회 수: 5 (최근 30일)
John Snow
John Snow 2013년 11월 25일
댓글: Image Analyst 2021년 11월 19일
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

채택된 답변

Image Analyst
Image Analyst 2013년 11월 25일
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
bini kif
bini kif 2021년 11월 19일
@Image Analyst in test.m
Image Analyst
Image Analyst 2021년 11월 19일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bruno Pop-Stefanov
Bruno Pop-Stefanov 2013년 11월 25일
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
Image Analyst
Image Analyst 2013년 11월 25일
John, my code does exactly what you wanted.
John Snow
John Snow 2013년 11월 25일
Sorry I was typing this when you posted I accepted the answer its perfect

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by