We receive raster mosaics of aerial imagery from a supplier and the border contains large black areas which commonly have a range of black or near black values. We've been asked to clean these border areas up so that anything that isn't part of the main image has a null value, not 255 or 254 or 0 or whatever.

Does anyone know of a good tool to do this? We can crop the images but being able to quickly convert this range of extraneous pixels to null would be good. This is complicated by the fact that there will be a few null values inside the image, for example in areas of deep shadow, which ideally should display as black.

Any thoughts?

1 Answer 1


GDAL nearblack

convert nearly black/white borders to black

Note: it operates on image borders, not the entire image.

There is an example of its use and outputs here and in this answer.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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