Hi,

I think the colormaps are always interpolated. If you run the pyqtgraph 
Color Maps example you'll see even the discrete maps imported from 
matplotlib get interpolated.
It might be possible to define your own colormap with two stops at the same 
location. It might break, but it might also work...
I've hard coded in my own colormaps before using something like:

#...
self.cbar = pg.HistogramLUTItem(self.overview_composite_image)
self.cbar.gradient.restoreState({"mode": "rgb",
    "ticks": [(0.00, (0, 0, 0)),
              (0.25, (0, 0, 128)),
              (0.50, (144, 0 , 0)),
              (0.85, (224, 224, 0)),
              (1.00, (255, 255, 255))]})
#...

So you could try putting two stops for each colour something like:

self.cbar.gradient.restoreState({"mode": "rgb",
    "ticks": [(0.00, (0, 0, 0)),
              (0.25, (0, 0, 0)),
              (0.25, (0, 0, 128)),
              (0.50, (0, 0, 128)),
              (0.50, (144, 0 , 0)),
              (0.85, (144, 0, 0)),
              (0.85, (255, 255, 255)),
              (1.00, (255, 255, 255))]})
#...

It's possible you may need to make the next range start at 0.25000001 etc 
if things break because of divide-by-zero errors.

The "proper" way to do it would be to write a ColorMap subclass 
DiscreteColorMap or similar that handles the functionality.

Patrick
On Monday, 10 April 2023 at 7:36:56 pm UTC+9:30 [email protected] wrote:

> Hello,
>
> Is it possible to apply a colour map to an image without interpolation 
> between the colours? Sort of a discrete colour map?
>
>
> Kind regards
> Edward
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/388488cc-7acf-4351-8721-f936f9f80919n%40googlegroups.com.

Reply via email to