how can i reclassify pixels of one value that are completely surrounded by pixels of another value?

3309
4
Jump to solution
10-07-2015 03:16 PM
Jon_PaulPierre
New Contributor

I would like to reclassify only the pixels of one value that are completely enclosed by pixels of another value.

Can someone help me do this?

I've used 10 iterations of majority filter (using four as kernel filter and half as majority definition) to help fill in some of the missing pixels.

What i need to do is to reclassify the value of any pixel completely enclosed by pixels of another value to the same value as the surrounding pixels. On the attached image, I would like to reclassify the enclosed blue pixels to the same value as the green pixels.

I appreciate any help.

0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor

See this help page, which describes how to generalize a messy raster imagery classification. In particular, try starting from the second last step, which describes how to remove areas smaller than a threshold (your blue pixels) and fill in the resulting voids using the Nibble tool.

Alternatively, if you really want to consider only the 8 surrounding pixels and reclassify those that are surrounded by all green, you can do so with Focal Statistics to calculate the min and max within the default 3x3 square, then use Con to test if the min = green value, and max = green value, and the green/blue raster = blue value, change it to green.

View solution in original post

0 Kudos
4 Replies
DarrenWiens2
MVP Honored Contributor

See this help page, which describes how to generalize a messy raster imagery classification. In particular, try starting from the second last step, which describes how to remove areas smaller than a threshold (your blue pixels) and fill in the resulting voids using the Nibble tool.

Alternatively, if you really want to consider only the 8 surrounding pixels and reclassify those that are surrounded by all green, you can do so with Focal Statistics to calculate the min and max within the default 3x3 square, then use Con to test if the min = green value, and max = green value, and the green/blue raster = blue value, change it to green.

0 Kudos
Jon_PaulPierre
New Contributor

Thank you very much.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Majority filter would work

But if you want to be selective:

   For example, in your image, there are several dual zones where 2 blue pixels adjoin.  If you want to replace both of those as well then you can do a combination of

Regiongroup to identify the small areas​ it will create individual zones from the input data like a sequential list

SetNull to mask the small areas​  You can also use Con with SetNull but doing the query on the count field

Nibble to remove the small zones

In that way you can remove zones of 1, 2, 3,... x cells even if your maps consists of 2  classes but dozens+ of discrete zones.  Remember, raster data are like multipart data in vector world, you need to convert the multipart representation to singlepart in order to process 'fiddly bits'

0 Kudos
Jon_PaulPierre
New Contributor

Thank you very much.

0 Kudos