MATLAB: Very Basic Threshold & Edge Detection

edge detectionimage processingthresholding

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

Best Answer

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.