Skip to main content

Hi,

I have a png raster with RGBA bands, and I need to transform this raster into a single band grayscale (UInt32). By convention, we have set the leftmost bit in the Alpha channel to 1. This bit is to be ignored when computing the result (a "31 bit integer"), which should fit in the UInt32 type (isn't it?).

 

In the rasterexpressionevaluator, I use the following formula:

@if(AA3]<128,0,((AA3] -128)*256*256*256 + AA0]*256*256 + AA1]*256 + AA2]))

 

However, when I try to use bitwise operators, only the value of the blue band (a(2]) is included in the result.

 

((A(3] & 127) << 24) | (A 0] << 16) | (A 1] << 😎 | A|2])

 

I used a simpler form for testing purposes (As1] << 😎, but this always evaluates to 0.

 

I can't figure out how to use the bitwise operators, any help would be appreciated.

 

 

 

Hi,

I have found something that works. I first use a RasterBandInterpretationCoercer to cast all bands to UInt32, then I apply the raster formula in the rasterexpressionevaluator :

 

((AA3] & 127) << 24) | (AA0] << 16) | (AA1] << 😎 | AA2])

 

Confusing that ne needs 2 steps,and FME does not signal that the operation fails...

 

 


Reply