-{ a hewer of maps }-

Decollaring with nearblack

to-be-decollared.jpgThe attached geotiff image has two collars to be removed. The outermost consists of pure black (0,0,0) while the innermost is off-white (ranges from 240 thru 255). I used gdalsetnull to change 0,0,0 to nodata, then ran `nearblack -white` on the result. I detect no difference in the output image even with a very large fuzz factor (-near 50) .

What am I doing wrong?

Answers

From Even Rouault I learned that nearblack doesn't grok nodata, it just looks at the pixel values. Consequently it never sees the white collar, except a small portion at the very top of the image.

Thankfully Luke Pinner, who's come to my aid before, has an elegant solution using a VRT intermediate file (ref):

#Change black to white
gdalbuildvrt -srcnodata 0 -vrtnodata 255 to-be-decollared.vrt
to-be-decollared.tif
#Run nearblack -white
nearblack -white -o decollared.tif to-be-decollared.vrt
ipy and arcgisscripting » « Time Traveller Drop Points