Skip to main content

FME questionHello,

 

I have a satellite raster in GeoTIFF format and am trying to generate a grey8 image for selected RGB colours. Similar to what is in the attached image. Above is the RGB satellite image and below is a grey8 image for the selected RGB values with a "falloff" or "threshold value" similar to the photoshop selection filter.

 

I tried RasterExpressionEvaluator and the examples to give me some ideas but I'm not able to make it do what I want.

 

This video shows the exact output I am trying to achieve - https://www.youtube.com/watch?v=Ha3HdYBzU_Q

 

Ideally, I would like to split an RGB image into "n" most common colours using a "falloff" value, and export them as a greyscale "mask". Then I would import them as a blended texture in unreal engine.

 

Appreciate any help!

/Sanjay

 

Hi @snjsomnath​,

I think I have solution that produces the same results as the Select Color device. I used two RasterExpressionEvaluators in order to simplify the expressions, since they were getting very complex.

Screen Shot 2022-04-08 at 10.50.35 AMSource Orthophoto:

Screen Shot 2022-04-08 at 10.51.00 AMResult with target color set to 171, 176, 150 (grey pavement) and falloff set to 0.26:

Screen Shot 2022-04-08 at 10.51.23 AMThe attached workspace uses a color picker parameter to choose the target color, and range bar to choose the falloff.

The first RasterExpressionEvaluator calculates the color distance between each pixel and the target, then scales by the inverse of the falloff. Any values greater than 1 from this calculation are beyond the falloff.

The secondRasterExpressionEvaluator uses an if() function to replace values higher than 1 with 0, and subtract values lower than 1 from 1, in order to invert the color distance.


@daveatsafe​  Thank you so much for that solution, I think this would work perfectly! I will try it out and get back with some updates shortly.

 

Best,

Sanjay


Reply