Discussion:
[Matplotlib-users] applying an image's colormap to another image
Matteo Niccoli
2016-01-28 04:23:52 UTC
Permalink
Can something like this (which by the way I can't get to work):
http://stackoverflow.com/questions/3114925/pil-convert-rgb-image-to-a-specific-8-bit-palette

What I would like to do is this:
1) Import an RGB image, which would have its own colormap - say this one
for example:
Loading Image...

2) convert it to intensity, display the intensity color-mapped to the same
colours the original RGB had.

Any tips, or even better code or pseudocode would be greatly appreciated.

Thanks
Matteo
Benjamin Root
2016-01-28 15:39:25 UTC
Permalink
You might have better luck asking the scikit-image people, or the Pillow
people. ImageMagick might also have what you are looking for.

Cheers!
Ben Root
Post by Matteo Niccoli
http://stackoverflow.com/questions/3114925/pil-convert-rgb-image-to-a-specific-8-bit-palette
1) Import an RGB image, which would have its own colormap - say this one
https://upload.wikimedia.org/wikipedia/commons/b/b3/Jupiter_new_hubble_view_above_pole.png
2) convert it to intensity, display the intensity color-mapped to the same
colours the original RGB had.
Any tips, or even better code or pseudocode would be greatly appreciated.
Thanks
Matteo
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Fabrice Silva
2016-01-28 16:43:40 UTC
Permalink
Post by Matteo Niccoli
http://stackoverflow.com/questions/3114925/pil-convert-rgb-image-to-a
-specific-8-bit-palette
1) Import an RGB image, which would have its own colormap - say this
https://upload.wikimedia.org/wikipedia/commons/b/b3/Jupiter_new_hubble_view_above_pole.png
2) convert it to intensity, display the intensity color-mapped to the
same colours the original RGB had.
According to the PNG header, this image does not have a palette (i.e. a
list of colors). The data chunks define the image as an array of NxMx3
values (N rows, M cols, 3 channels=no alpha), each value being defined
using 8 bits. I may however badly understand what you call the "own
colormap"...

You still can convert it to a grayscale img representing the intensity
(NxM values), but you then lose some information and you cannot display
it back with the same colors as originally. Because some different RGB
tuple are converted into the same intensity level, you can then not
discriminate them using the intensity image only.

Maybe there is some trick to convert to a grayscale image where those
RGB values are converted to almost-equal-but-different intensity levels
that would enable the later reconstruction, but I am not aware of...

Fabrice

Loading...