I want to introduce geotiff images generated in QGIS by clipping ortho imagery to a shapefile into matlab. However, the clipped raster images come with black borders. I managed to remove them in QGIS (by setting a no data value for zero/ black), but they return when I open the same images in matlab. Even when I check the "create an output alpha band" box, the same thing happens in matlab. Any solution?

  • 1
    Welcome to GIS.SE. Your "removal" of the black borders in QGIS is only of cosmetic nature - you only tell QGIS not to display them, you don't remove them. Have you done any research on how to remove the black borders? Also, is the removal necessary or only for aestheticpurposes? – Erik Aug 16 '19 at 9:35
  • I have tried nodata value and alpha band. Removes black borders perfectly in QGIS, but not in matlab. Besides, nodata values also affect the image itself it seems, which makes sense: every black pixel is removed. It turns out the black borders will probably not affect my results (Deep Learning CNN Classification and Detection), so I guess the answer is aesthetic purpose for now. – Serge B Mooyman Aug 16 '19 at 14:40

It seems to me that Matlab GeoTIFF reader can't deal with nodata value or with alpha channel https://se.mathworks.com/help/map/ref/geotiffread.html. Transparency is available only for PNG, CUR and ICO files https://se.mathworks.com/help/matlab/ref/imread.html. Therefore the only way to remove the nodata areas from Matlab on QGIS side is probably to save the image as PNG with alpha.

By this old answer you should be able to remove regions from a raster with Matlab by using a vector mask. The mask can be a shapefile.


  • There are a lot of options to export the image in another format as tiff, but strange enough, no matter what I choose, the output was still a tiff image. Thanx for the links. – Serge B Mooyman Aug 16 '19 at 14:44

Your Answer

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

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