Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a raster image like thisRaster image

I want to delete the isolated noise point and smooth the edge (say the white single points, and I want the edges of the entity look smooth). How can I do this in ArcGIS or in R?

The cell size is 30*30.

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

The morphological operations Expand and Shrink were created for this kind of processing. Use ArcGIS (or GRASS or Mathematica) because R's "raster" library is too slow.

Often it helps to experiment a little with the parameters: you have to decide how much expanding and shrinking is needed to clean an image; and usually you want to do as little as possible, because each operation tends to smooth out some of the sharp details. Here is a sequence that works well to eliminate much of the apparent "noise" while maintaining most of the detail in the "entities". "Expand" and "shrink" are both with reference to the white cells, so that expanding causes them to grow outwards and shrinking causes the black cells to encroach into white regions.

Table of images

The "difference" column uses color to highlight differences between the start and end image at each step: blue for black that turned to white, and orange for white that turned to black.

If the larger remaining pieces need to be removed, that might best be done with RegionGroup to identify them, after which they can be obliterated through reclassification. This was an option at the outset, but a little initial cleaning with Expand and Shrink reduces the work and provides the desired smoothing.

Incidentally, I chose to make the eight images in this illustration with Mathematica commands because they are so simple, easy, and fast to execute:

i = Import["http://i.stack.imgur.com/umDg7.png"];
l = Dilation[k = Erosion[j = Dilation[i, 2], 3], 1];      (* This does all the work *)
delta = ColorCombine /@ {{i, j}, {j, k}, {k, l}, {i, l}}; (* Compares images *)

The workflow in ArcGIS is the same but the syntax will be lengthier. If you really want to use R, load the "raster" library and exploit focalFilter to create functions to do the expanding and shrinking. Then wait about a minute each to execute the operations... .

share|improve this answer
Thank you @whuber you always give me great answers! –  Seen Nov 15 '12 at 3:54
Hello! If you don't mind, could you send me your contact information? I would like to acknowledge you in my research. Thank! @whuber –  Seen Mar 1 '13 at 2:19
Do you know the equivalent commands in GRASS? –  Richard Mar 14 '13 at 20:39
@Richard I'm sure there are plenty of creative ways to do these operations in GRASS, but r.neighbors looks well suited to the task. –  whuber Mar 14 '13 at 20:57
add comment

Using the Spatial Analyst Extension, you can use some of the Generalization tools. Some of them perform similar tasks, so you might need to play around with a few to get the results to be how you want them. But, I would have a look at the Majority Filter tool and the Boundary Clean tool.

Here is a page on the concepts of these two tools.

I'm not sure how to perform these tasks in R, but here is a post on how to perform a Majority Filter using GRASS GIS.

share|improve this answer
Thanks for pointing me to the right direction! –  Seen Nov 14 '12 at 13:57
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.