Aggregation of neighbour pixels with the same value

Discussion created by guillem84 on Jan 11, 2011
Latest reply on Jan 12, 2011 by guillem84
Dear colleagues,

I need to identify clusters of pixels with the same value and an area lower than a specific value. If some of these clusters are surrounded by a group of pixels that have the same value each other, I need to give to this clusters the same value than the pixels around them. The main problem is that I have a lot of clusters and I need to do it automatically.
I attached an example (fig1). In this case, there are four clusters: Two of orange pixels and two of green pixels. In both cases they are surrounded by yellow pixels, hence, pixels of this four clusters should be convert into yellow color.
If someone knew a methodology to do it I would be really grateful.

Best wishes,