Hello, I would like to segment some images based on some conditions, Could you help me with that?

asked 2020-02-06 08:13:47 -0600

tsabbir96 gravatar image

Hello I have an image that i got after performing clustering for 5 colors. Now there are only 5 colors present in the image. Suppose the colors are (100, 150, 200), (200, 250, 100), (50, 150, 200), (100, 250, 100), (0, 100, 200).

Now I want to split the image into chunks. Each chunks will have some percentage of the pixels of all the 5 colors. Say 20% pixels are of color A and 30% pixels are of color B and so on.

How do I split the image this way?

Example: This is the input image: input

This should be the output image: output

Each chunk has to have all the clustering colors (i.e. 5 if we use the example above) colors present in the image in it.

edit retag flag offensive close merge delete

Comments

yea, you can do something with some algorithm, and you'll get some result ;(

berak gravatar imageberak ( 2020-02-06 08:33:31 -0600 )edit

haha .. I was filled with joy when I saw your comment. But then realized something XD

tsabbir96 gravatar imagetsabbir96 ( 2020-02-06 08:46:29 -0600 )edit

your output image looks more like you want spacial segmentation, like e.g. SLIC

berak gravatar imageberak ( 2020-02-06 08:56:00 -0600 )edit

I just want to group the pixels in such a way that each group will have all the 5 colours

tsabbir96 gravatar imagetsabbir96 ( 2020-02-06 09:09:09 -0600 )edit

What do you mean 5 colors? It looks like an exercise Image histogram is image description more than 5 colours. Take 5 random pixels and you get regions with 5 colors

use kmean before?

LBerger gravatar imageLBerger ( 2020-02-06 09:29:45 -0600 )edit

Yes, i did a kmeans on the original image where k = 5.. this way i made sure i get an image with 5 colours only.. now i want this new image as input in some kind of algorithm that will help me to come up with chunks of image. Each chunk should contain all the 5 colours

tsabbir96 gravatar imagetsabbir96 ( 2020-02-06 10:36:06 -0600 )edit

Yes, i did a kmeans on the original image where k = 5.. this way i made sure i get an image with 5 colors only

Well if you found 5 centroids you have found 5 dominant colors and also their cluster(area) within the whole image. These cluster dont overlap. "Kmeans algorithm is an iterative algorithm that tries to partition the dataset into Kpre-defined distinct non-overlapping subgroups (clusters)". So you divided the image into distinct areas but at same time you are asking where these area overlap(Each chunk should contain all the 5 colours).

My suggestion. Use contours or similar approach to find areas within the image.I think this is what berak was suggesting with "spacial segmentation". Then run kmeans with k5 on these areas so you get clusters with dominant colors

holger gravatar imageholger ( 2020-02-06 15:20:06 -0600 )edit

And then check if centroids suffice your criteria. If so - measure the cluster area. If each cluster is sufficiant dominant (maybe like 10% of the whole contours area) - you found your area. I hope this make sense. @berak can you comment on this?

holger gravatar imageholger ( 2020-02-06 15:23:33 -0600 )edit

@tsabbir96 -- it would be helpful, if you could explain, why you need this, and what for.

@holger -- the image reminded me of superpixels, but those have no guarantee, that all 5 dominant colors are present

berak gravatar imageberak ( 2020-02-06 16:06:49 -0600 )edit

@holger@berak sorry guys, I would have upvoted you. But I guess I need 5 points to do that.. Thanks a lot for your suggestion. Definitely will test the idea.

tsabbir96 gravatar imagetsabbir96 ( 2020-02-07 04:31:58 -0600 )edit