Solved

Rasters: palette interpretation

  • 6 February 2019
  • 2 replies
  • 4 views

Userlevel 6
Badge +31

This is my first real experience with rasterdata so my knowledge quite basic.

What I want to do is to convert rasters to vectors using Potrace and the PotraceCaller. The rasters are 8 bit PNG's, see attachments.

In the PotraceCaller, the raster is being written to BMP. The BMP is commandline converted to DXF by Potrace. The DXF is being read, world file applied.

This works great, but not for all rasters. When running the workspace the following warnings show up:

2019-02-06 12:11:52|   0.5|  0.0|WARN  |BMP writer: Unsupported palette value interpretation 'RGBA32'. Converting to interpretation 'RGB24'. If this conversion is undesired, consider changing the interpretation explicitly
2019-02-06 12:11:52|   0.5|  0.0|WARN  |@ReinterpretRaster: Converting some band/palette interpretations from 'RGBA32' to 'RGB24' might result in a loss of data

I think to understand that a palette is an overview of all variations being used in the raster.

The raster which is successfully converted has the following palette:

RGBA32
0 255,255,255,0
1 150,0,0,255
2 150,0,0,255

The raster which is not successfully converted has the following palette:

RGBA32
0 255,255,255,0
1 255,215,80,255
2 255,215,80,255

I think that 0 255,255,255,0 is the transparant background. The other values are not transparant (255 on 4th position) colors.

What I first tried is to use the RasterPaletteInterpretationCoercer to convert from RGBA32 to RGB24.

  • With the parameter "Drop the alpha band" I still didn't got any results.
  • With the parameter "Apply the alpha band" I also got the frame of the picture, which I don't want.

I think that 255,215,80,255 is a not processable color for some reason, where 150,0,0,255 works fine. So my workaround now is to extract the palette, replace each value by 150,0,0,255, remove the original palette, add the new palette and process the raster. This works well enough but I encounter other problems.

So my question is: Why is 255,215,80,255 not processed where 150,0,0,255 is processed fine and how to I change this in the rasters?

Thanks for your time!

icon

Best answer by takashi 6 February 2019, 14:30

View original

2 replies

Userlevel 2
Badge +17

The BMP format only supports storing RGB24 image raster, so the result could be unexpected one if you sent an RGBA32 raster to the BMP raster.

What happens if you resolve the palette with the RasterPaletteResolver and remove the fourth band with the RasterSelector + RasterBandRemover?

Userlevel 6
Badge +31

The BMP format only supports storing RGB24 image raster, so the result could be unexpected one if you sent an RGBA32 raster to the BMP raster.

What happens if you resolve the palette with the RasterPaletteResolver and remove the fourth band with the RasterSelector + RasterBandRemover?

Thanks for the suggestion @takashi. This helped me understand how these tools work. (Expose bands, select a band, then change it.) Now I read the documentation I understand better what it means.

I think the 255 value in the red band was the problem, as the NoData identifier was 255.

My solution:

RasterPaletteResolver to bring the values from palette to bands.

RasterBandNodataRemover to remove the nodata identifier.

RasterExpressionEvaluator (to set and only keep RED8 = 0 where the alpha band was 255, else 255)

RasterBandNodataSetter (restore nodata identifier to 255)

Learned a lot today.

A Beginners Guide to Bitmaps is a great kickstart for learning how rasterdata works.

Reply