Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparent rgb pixel when all 3 values of original pixels are below browse_type min and no-data is set to 0 #493

Closed
lubojr opened this issue Sep 22, 2021 · 2 comments

Comments

@lubojr
Copy link
Contributor

lubojr commented Sep 22, 2021

Problem: When all three original band values are below their respective browse_type minimum stretch values, final pixel is made transparent when no-data is set for the bands to 0.

Reference:
https://gitlab.eox.at/esa/prism/vs/-/issues/107

stretch with dim_range 50 255, 50 255, 50 255
image

stretch with dim_range 45 255, 45 255, 45 255
image

Maybe this piece of code is where it takes place

return gdal.GDT_NUMERIC_LIMITS.get(field.data_type) or (0, 255)

@jankovicgd
Copy link
Member

jankovicgd commented May 3, 2022

found a workaround for some usecases.

With byte data it is possible to define something like:

TRUE_COLOR:
  asset: multispectral
  red:
    nodata: null
    expression: red
    range:
      - -1
      - 255
  green:
    nodata: null
    expression: green
    range:
      - -1
      - 255
  blue:
    nodata: null
    expression: blue
    range:
      - -1 
      - 255
  alpha:
    expression: a
    range:
      - 0
      - 255

If the lower bound is 0 it is excluded as nodata and made transparent even if 0 is not actually a nodata value. Setting -1 as the lower bound includes 0 as data, meaning at some point it is exclusive at the lower bound (maybe also upper)

@lubojr
Copy link
Contributor Author

lubojr commented Dec 21, 2022

Fixed by #550 and #546

  • Needs a database migration to be run to add show_out_of_bounds_data on BrowseType model

For operators:

To circumvent problem in this issue (masking exactly black 0,0,0 pixels to transparent), use the --show-out-of-bounds-data flag when creating a browse type.

This will use the LUT[_n] rendering. https://mapserver.org/id/input/raster.html#special-processing-directives which sets browse_type.band.nodata value to 0 in respective final color representation (rgb) and maps browse_type.band.nodata+1 to 1 and browse_type.band.min to 1.

This rendering mode can be used only on UInt8 and UInt16 (and positive floats up to UInt16 range) because of how LUT is implemented -> The in values must be in increasing order. The range of input values can go from 0 up to 65535.

@lubojr lubojr closed this as completed Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants