Consider an image (img
) as
Now I have partitioned the image using the following command
parts = ImagePartition[img, 32];
Then I compute the ImageDistance
among all the image parts using DistanceFunction
as MeanEuclideanDistance
.
partsFlatten=Flatten@parts;
meanEuclideanDistance =
Table[{ImageDistance[partsFlatten[[i]], partsFlatten[[j]],
DistanceFunction -> "MeanEuclideanDistance"]}, {i, 1, 49, 1}, {j,
1, 49, 1}]
Now I wish to group the original parts based on meanEuclideanDistance
and reconstruct the original image displaying different groups (using different colors preferably).
How can this be achieved?
[Note: In my opinion, a filter can be designed for this specific purpose which will accept the image and the kernel size (32 here), finds a dynamic threshold for the meanEuclideanDistance
to group the parts and display the segments.
]
Edit 1: This is what I have come out so far.
Manipulate[im = img;
{w, h} = ImageDimensions[img];
imgparts = ImagePartition[im, {Round[w/np], Round[h/np]}];
{nr, nc} = Dimensions@imgparts;
imgpartsflattened = Flatten@imgparts;
med = Table[{ImageDistance[imgpartsflattened[[i]],
imgpartsflattened[[j]],
DistanceFunction -> "MeanEuclideanDistance"]}, {i, 1, nr, 1}, {j,
1, nc, 1}];
ListPlot[Flatten@med], {np, 1, 100, 1}]
And the corresponding plot for np=8
is as follows