Very Basic Threshold & Edge Detection

조회 수: 10 (최근 30일)
Paul Johnson
Paul Johnson 2011년 9월 6일
Hi all, I have a colour image I need to threshold and edge detect. I know this will be quite a simple piece of code however I'm unable to get it working. I was wondering if you could help. Here's what I have so far.
I = imread('p0071.jpeg');
BW = edge(I,'sobel', thresh)
imshow(BW);
This snippet of code doesn't work, and I assume it's because it's in colour and I need to add some thresholding parameters? How do I add these parameters to get this code to work? Sorry for such a simple question but I've been messing around for over an hour with no success.
Paul
  댓글 수: 2
Andreas Goser
Andreas Goser 2011년 9월 6일
Maybe it is very basic. Maybe not. Without an error message, it remains guess work. Can you provide code that e.g. works with images from the MATLAB instalation like 'pillsetc.png' that give the same behaviour? and please also clarify if you just like the code to run and then play with the threshold or if you look for methods to auto-calculate a good threshold.
Paul Johnson
Paul Johnson 2011년 9월 7일
Yes, I want to be able to alter the threshold value as I don't think it will work too well automatically. Here's the working code I have so far:
.
I = imread('p0071.jpg');
J = rgb2gray(I);
BW1 = edge(J,'sobel');
imshow(BW1);

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

채택된 답변

Paul Johnson
Paul Johnson 2011년 9월 12일
I = imread('p0071.jpg');
J = rgb2gray(I);
BW1 = edge(J,'sobel', 0.5);
imshow(BW1);
  • Reads a colour image in.
  • Converts the image to greyscale
  • Applies Sobel edge detection and thresholding (modify 0.5 to change threshold level 0.1-0.99)
  • Display the processed image.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 9월 6일
"thresh" is not a keyword or a function: it is a numeric value that you have to supply if you want to use a different threshold than would be automatically chosen.
  댓글 수: 2
Paul Johnson
Paul Johnson 2011년 9월 7일
This is what I currently have:
.
I = imread('p0071.jpg');
J = rgb2gray(I);
BW1 = edge(J,'sobel');
imshow(BW1);
.
It reads the image in, converts it to greyscale and applies a sobel edge detection filter... before displaying it onscreen. How do I add a thresholding value to this please?
Walter Roberson
Walter Roberson 2011년 9월 7일
BW1 = edge(J,'sobel',0.3); %for example

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

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by