Subscribe to this thread
Home - General / All posts - Making some pixels transparent in a raster/Image
julmou17 post(s)
#25-Feb-23 08:43


Please the image below first.

What I'm trying to achieve is to get all the black pixels transparent. These are basically the areas where there are no satellite data. But because every raster is basically a rectangle, the "void" have been filled with pixels with a value of 0, which get represented in black.

Note: the raster has 3 channels, RGB, as uint16, with values from 0 to 65535 (LANDSAT 8). But in effect, to be rendered properly as "true" colors close from reality, I only use values from 5000 to 10000 for the RGB (see the right pane on the screenshot). Still though, it seems all the 0 values get shown in black. I'm pretty sure these are zeros, because, when doing the Style with equal intervals, there are 29.7% pixels with 0!

There could be several ways around it, but I haven't found a method successful so far.

  1. Style it in a way that all the pixels with 0 are shown with a transparent color (while still keeping the 5000-10000 interval for the RGB)
  2. Make all the zero values as NULL, or as "NoData" -> similar to ArcGIS, the pixels with NoData just aren't shown
  3. Cut the Image with a vector layer that fits only the part of the raster that I want (I tried, based on this tutorial, but it still retains the black portions)

Any help is welcome, I haven't been successful so far.


7,313 post(s)
#25-Feb-23 09:21

You probably want to use TileMaskRange expressions. Here's how to find info on them:

1. Visit the User manual

2. Note the Search box in the upper right corner of the page. Enter "transparent pixels" or "invisible pixels" in that box (no quotes).

3. The second topic that pops up is what you want, but the other topics returned by the search may also be useful.

For multichannel images you'll want to generalize the single channel advice given in that topic. There are other useful topics for how to do multichannel things using expressions and SQL, like the Images examples of SQL and filters.

Also, not sure why your option 3 didn't work. I often use that method when I want to clip the black parts off an image. You might want to report your workflow in detail in this thread so you can discover what's the error, as that's a very useful technique to have in your toolbox.

10,071 post(s)
#26-Feb-23 03:32

Just to be a PIA Dimitri: predicting Google’s ranking for another user is a fool’s game, as it depends on what Google knows or thinks about the user “asset” and where it would most like to make its next money. Even for search.

julmou17 post(s)
#26-Feb-23 04:19

Thank you Dimitri!

I just reached no. 33 of the "Learn Manifold" YouTube playlist and realised that there was an entire tutorial dedicated to my question! :D

So, yes, indeed, the TileMaskRang function was what I was after. Also, I did find the documentation regarding that function:

The nice thing too about this, is that, once I cleared the 0 pixels as missing pixels, Manifold nicely styles my Landsat images automatically using the range of values available.

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.