As I mentioned earlier, we are partway along building a generative model for flatbed-scanner seed images. We have a silhouette component to the model, but we also want to use edge information, since edges are going to provide essential clues to where one kernel ends and another begins (even if they touch). To that end, I've got a Canny edge detector working on seed images. Here's a picture:
The input to the edge detector was a silhouette of seed kernels. The picture here shows randomly colored edge pixels, i.e., the edge detector has identified which pixels are edges of shapes, and (though you cannot see it), it has stored the edge direction, as well as the location, at each colorful point.
One difficulty here is that there is no perfect edge detector; this one includes a number of parameters (thresholds and a scale factor) that help it distinguish true edges from image noise. Those factors depend on image characteristics like seed size. If one tries different seeds, or a seed sample with more dirt, or if one changes the scan resolution, the edge detector might not do as well. We will have to pay attention how to make the system robust enough to be useful.
The next step is to integrate the edge information into the image model, i.e., into the likelihood function. That's more a problem of modeling than programming, but fortunately it's an issue our lab has been working on for quite awhile.
Update (17:58): Here's a visualization of the edge direction of those edge pixels, as a tangent line, in case the above was not clear. Each edge point has not only a location, but also a direction.