1

How would I segment this image of a tomato from its background? I tried the watershed method done by mathworks; unfortunately, some of the background is of the same intensity of the tomato and an edge is created between that background spot and a surrounding darker spot, so the tomato as well as some background is segmented together.

I tried to just find the gradient to reveal the outer edge of the tomato but not all of it is very defined, so it seems at some parts that it does not connect all the way around the tomato. My thought is that if I could connect that and fill in that entire boundary, I could effectively segment this tomato by pulling out just the filled in pixels from the original image. If anyone could help I would much appreciate it.

I included the picture of the original image and the gradient image, done with the commands below.

I = imread('Insert Image');
figure, imshow(I);

hy = fspecial('sobel');

hx = hy';
Iy = imfilter(double(I), hy, 'replicate');
Ix = imfilter(double(I), hx, 'replicate');
gradmag = sqrt(Ix.^2 + Iy.^2);
figure, imshow(gradmag,[]), title('Gradient magnitude (gradmag)')

tomato image

gradient image

rayryeng
  • 102,964
  • 22
  • 184
  • 193
Mike S
  • 13
  • 4
  • You might find [this thread](http://stackoverflow.com/a/19510366/1714410) on image segmentation based on edge cues relevant to your problem. – Shai Dec 06 '16 at 14:16

1 Answers1

1

You might try Graphcut segmentation approach. I just tried various segmentation methods and found Graphcut segmentation is working fine for the given image:

Interactive Graph Cut Segmentation Mask

Links:

https://www.youtube.com/watch?v=efUh0zcpsXc

Shai
  • 111,146
  • 38
  • 238
  • 371
  • a very nice result, but this requires **interactive supervision**. This solution cannot work automatically. – Shai Dec 28 '16 at 07:24
  • 1
    Prior automatic seed point detection for foreground region and background region needs to be researched so that we could modify above result to automatic graphcut segmentation. – Chanukya Krishna Chama Dec 29 '16 at 03:59