Last active
March 31, 2021 18:50
-
-
Save petebankhead/863352f92d17facb15bb5cf35ed03f56 to your computer and use it in GitHub Desktop.
Try to extract the label from an image in QuPath v0.2 and display it in ImageJ with enhanced contrast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Try to extract the label from an image and show this with enhanced contrast using ImageJ as the viewer. | |
* | |
* This is mostly intended for .czi files, where currently the label seems to be 16-bit | |
* and displays as entirely black in QuPath. | |
* | |
* It assumes that the label exists as an 'associated image' within the server. | |
* | |
* This has been tested with QuPath v0.2 - it may not work with other versions. | |
* | |
* @author Pete Bankhead | |
*/ | |
import qupath.imagej.gui.IJExtension | |
import javax.swing.SwingUtilities | |
def server = getCurrentServer() | |
def labelImageName = server.getAssociatedImageList().find {it.toLowerCase().contains('label')} | |
if (labelImageName == null) { | |
println "Unable to find an associated image with 'label' in the name" | |
return | |
} | |
def img = server.getAssociatedImage(labelImageName) | |
// Show using ImageJ, with enhanced contrast | |
SwingUtilities.invokeLater { | |
IJExtension.getImageJInstance() | |
def imp = IJTools.convertToUncalibratedImagePlus(labelImageName, img) | |
ij.IJ.run(imp, "Enhance Contrast...", " ") | |
imp.show() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment