clean isolated pixel

3188
5
09-10-2013 05:28 AM
New Contributor III
Hi,

I'm looking for a way to remove isolated pixels in order to speed up vectorization. In other words, I would like to set the value of its 8 neighbours to any pixel having a different value. I tried Majority but I don't get what I want. This will be coded aftr with Arcobjects. I would be grateful to any idea.
Thanks,

Olivier
Reply
0 Kudos
5 Replies
Regular Contributor II
I've used the Shift tool to do things I couldn't find a specific tool for.

Here is a similar post I responded to.http://forums.arcgis.com/threads/78067-how-can-I-eliminate-quot-island-quot-raster-cells-from-a-laye....  My post regarding the use of the shift tool is #4.
Reply
0 Kudos
New Contributor III
Hi Mark,

Thanks for this answer. It gives me ideas, but I'm not sure I understand the required shift and if it would work in my case as I have plenty of different values (and not 0/6 as in the post) as what I need is to eliminate the orphan pixels which could have any values.

Olivier
Reply
0 Kudos
Regular Contributor II
Cell statistics compares the value of the cell it is processing with other layers values in the same location. By using and shift function, you can place the surrounding 8 cells "under" the center cell and do some comparisons that you couldn't do otherwise. For example, if you wanted to know if the grid (pixel) were isolated and surrounded by cells that all had the same value, you could use con() to test if the values of the surrounding cells all equaled their average and if the cell had a different value than the average.

I'm sure there are other SA functions that could do this or something like it more eloquently. If not, this might be a way to attack the problems.

Cheers!
Reply
0 Kudos
MVP Esteemed Contributor
Olivier,

I'm looking for a way to remove isolated pixels


I'd try Boundary Clean or Thin (Generalization tools) before you get too fancy.

If you decide you truly need to zap single pixel zones, you can find them the Region Group tool and zap them using Nibble, a tool specifically designed to fill in "holes."


from arcpy.sa import *
# set all single-cell zones to NoData
catmask = SetNull(Lookup(RegionGroup(catraster),"COUNT") == 1, catraster)
# fill them in with the Nibble tool
cleanras = Nibble(catraster, catmask)


Hope this helps...
Reply
0 Kudos
New Contributor III
Mark, Curtis, thanks for your kind help,  I'll try your ideas, hope it'll work.

Olivier
Reply
0 Kudos