I'd like to apply FindClusters
or ClusteringComponents
to image data of an indistinct edge, with the goal of segmenting the image into three categories (background, foreground, and border region).
This is an example of input image data:
This approach works fine for simple configurations, but I would like to take advantage of the form of my image data to get a clustering that reflects the distinctness of the edge. My code so far looks like this:
Module[{data = ClusteringComponents[image, 3, Method -> "KMeans"],
widths, label},
widths = Table[Count[data[[i]], 2], {i, Length[data]}];
label = "Avg. width = " <> ToString@N@Mean[widths];
GraphicsGrid[{{Colorize@data,
ListPlot[widths, Joined -> True, PlotMarkers -> {Red, 4},
PlotLabel -> label]}}]]
How can I specify a distance function that relates pixels by intensity and horizontal distance, but not vertical position?