Recoloring objects
Sometimes, presentation matters. Though clearly not on my website!
Color adjustments
Most aspects of QuPath are very configurable, and the colors of objects are no exception. The most obvious way to control object color is through its class - often by double clicking on the class in the Annotations tab. The direct way is not the only way, and being able to apply colors directly can have some benefits when presenting information.
Default object colors can be changed in the Edit->Preferences menu under Objects.
Scripting colors
Alternatively, you can script a color using RGB values, which you can guess, manipulate with math, or snag them from a handy website like this one. Turn those RGB values into a color like
Gray (125,125,125)
Black (0,0,0)
White (255,255,255)
Red (255,0,0)
Cyan (0,100,100)
using the following code.
color = getColorRGB(0, 100, 100) aClass = getPathClass("Anyclass") aClass.setColor(color) fireHierarchyUpdate()
That's it, you have recolored a class (to Cyan if you followed the script) - same as double clicking on it in the Annotation tab. However, this could be included in a script that is run for a new Project (in a case where you have many Project folders) to set up the colors the way you want them.
Additionally, when you first create a class, you can use:
aClass = getPathClass("Anyclass", getColorRGB(0,100,100))
However, to change the color, you cannot call getPathClass a second time, you need to use aClass.setColor. This includes across multiple runs of a script, until you restart QuPath.
Classes and derived classes (with colons to split the parts of complex classes) can be targeted and adjusted with code like the following.
getDerivedPathClass(getPathClass('Subcellular cluster'), 'Eosin object').setColor(qupath.lib.common.ColorTools.makeRGB(50, 20, 160))
This is far more useful if you are still using 0.1.2, prior to the Context Menu option in the Annotation tab to "Populate from existing objects".
Measurement Maps
Measurement maps, (Measure->Show measurement maps) can be tailored to your needs using two tricks. First, you can swap the direction of the color map by swapping the positions of the min and max sliders. Second, you can create your own colormaps using a TSV file as described here on Twitter by Pete.