Clipping Color Range via CLUT
Posted: 2013-02-28T07:01:22-07:00
Hi everyone,
This is what I'm trying to do:
For each color channel in an 24bit RGB image, replace all values below 16 with 16 and all values above 235 with 235.
What I tried:
I made a color lookup table ("clut.pgm", one row, 256 values). No values under 16 or above 235 are included in the table, all other values are sequential (example 8->16, 21->21, 45->45, 240->235).
I ran it through convert:
Now, when I'm checking the histogram of output.png, I still see a lot of color values < 16. If I run -clut twice, though, these stray pixel values are gone.
Now, I do need a 100% surefire way to eliminate all values below 16 and above 235, so that second option is not good either (what if, for some images, I need to run it three times?).
Is this a bug? It has nothing to do with input/output formats (I tried). Any other ways to do with I'm trying to do?
EDIT: Sample data is available here.
EDIT2: ... and I found the solution myself. My CLUT was wrong (0x0D 0x0A in PGM instead of 0x0D) :-/. Duh... Can any moderator delete this thread?
..
This is what I'm trying to do:
For each color channel in an 24bit RGB image, replace all values below 16 with 16 and all values above 235 with 235.
What I tried:
I made a color lookup table ("clut.pgm", one row, 256 values). No values under 16 or above 235 are included in the table, all other values are sequential (example 8->16, 21->21, 45->45, 240->235).
I ran it through convert:
Code: Select all
convert 01429_sunsetinedinburgh_1280x800.jpg clut.pgm -clut output.png
Code: Select all
convert 01429_sunsetinedinburgh_1280x800.jpg clut.pgm -clut clut.pgm -clut output.png
Is this a bug? It has nothing to do with input/output formats (I tried). Any other ways to do with I'm trying to do?
EDIT: Sample data is available here.
EDIT2: ... and I found the solution myself. My CLUT was wrong (0x0D 0x0A in PGM instead of 0x0D) :-/. Duh... Can any moderator delete this thread?
..