I want to eliminate near black pixels around edges of Landsat-8 overview. I'm interested in doing it not for the entire image but some extent, so I clipped it. I tried using GDAL nearblack utility, but faced the problem that it doesn't take into account image border pixels.


nearblack -of GTiff -nb 1 -o mask.tif input.tif

Produces following result:

nearblack -of GTiff -nb 1 -o mask.tif input.tif When I expected that the output would have looked like this: desired output

Is there a way to force GDAL nearblack utility to ignore pixels around image borders? To achieve my goal I also tried applying erosion with different structuring elements, but erosion produces "torn edges".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.