use of qupath.lib.color.ColorDeconvolutionStains in project qupath by qupath.
the class ImageDetailsPane method getValue.
private Object getValue(ImageDetailRow rowType) {
if (imageData == null)
return null;
ImageServer<BufferedImage> server = imageData.getServer();
PixelCalibration cal = server.getPixelCalibration();
switch(rowType) {
case NAME:
var project = QuPathGUI.getInstance().getProject();
var entry = project == null ? null : project.getEntry(imageData);
if (entry == null)
return ServerTools.getDisplayableImageName(server);
else
return entry.getImageName();
case URI:
Collection<URI> uris = server.getURIs();
if (uris.isEmpty())
return "Not available";
if (uris.size() == 1)
return decodeURI(uris.iterator().next());
return "[" + String.join(", ", uris.stream().map(ImageDetailsPane::decodeURI).collect(Collectors.toList())) + "]";
case IMAGE_TYPE:
return imageData.getImageType();
case METADATA_CHANGED:
return hasOriginalMetadata(imageData.getServer()) ? "No" : "Yes";
case PIXEL_TYPE:
String type = server.getPixelType().toString().toLowerCase();
if (server.isRGB())
type += " (rgb)";
return type;
case MAGNIFICATION:
double mag = server.getMetadata().getMagnification();
if (Double.isNaN(mag))
return "Unknown";
return mag;
case WIDTH:
if (cal.hasPixelSizeMicrons())
return String.format("%s px (%.2f %s)", server.getWidth(), server.getWidth() * cal.getPixelWidthMicrons(), GeneralTools.micrometerSymbol());
else
return String.format("%s px", server.getWidth());
case HEIGHT:
if (cal.hasPixelSizeMicrons())
return String.format("%s px (%.2f %s)", server.getHeight(), server.getHeight() * cal.getPixelHeightMicrons(), GeneralTools.micrometerSymbol());
else
return String.format("%s px", server.getHeight());
case DIMENSIONS:
return String.format("%d x %d x %d", server.nChannels(), server.nZSlices(), server.nTimepoints());
case PIXEL_WIDTH:
if (cal.hasPixelSizeMicrons())
return String.format("%.4f %s", cal.getPixelWidthMicrons(), GeneralTools.micrometerSymbol());
else
return "Unknown";
case PIXEL_HEIGHT:
if (cal.hasPixelSizeMicrons())
return String.format("%.4f %s", cal.getPixelHeightMicrons(), GeneralTools.micrometerSymbol());
else
return "Unknown";
case Z_SPACING:
if (cal.hasZSpacingMicrons())
return String.format("%.4f %s", cal.getZSpacingMicrons(), GeneralTools.micrometerSymbol());
else
return "Unknown";
case UNCOMPRESSED_SIZE:
double size = server.getWidth() / 1024.0 * server.getHeight() / 1024.0 * server.getPixelType().getBytesPerPixel() * server.nChannels() * server.nZSlices() * server.nTimepoints();
String units = " MB";
if (size > 1000) {
size /= 1024.0;
units = " GB";
}
return GeneralTools.formatNumber(size, 1) + units;
case SERVER_TYPE:
return server.getServerType();
case PYRAMID:
if (server.nResolutions() == 1)
return "No";
return GeneralTools.arrayToString(Locale.getDefault(Locale.Category.FORMAT), server.getPreferredDownsamples(), 1);
case STAIN_1:
return imageData.getColorDeconvolutionStains().getStain(1);
case STAIN_2:
return imageData.getColorDeconvolutionStains().getStain(2);
case STAIN_3:
return imageData.getColorDeconvolutionStains().getStain(3);
case BACKGROUND:
ColorDeconvolutionStains stains = imageData.getColorDeconvolutionStains();
double[] whitespace = new double[] { stains.getMaxRed(), stains.getMaxGreen(), stains.getMaxBlue() };
return whitespace;
default:
return null;
}
}
use of qupath.lib.color.ColorDeconvolutionStains in project qupath by qupath.
the class QP method setColorDeconvolutionStains.
/**
* Set the color deconvolution stains for hte current image data using a (JSON) String representation
*
* @param arg
* @return
*/
public static boolean setColorDeconvolutionStains(final String arg) {
ImageData<?> imageData = getCurrentImageData();
if (imageData == null)
return false;
ColorDeconvolutionStains stains = ColorDeconvolutionStains.parseColorDeconvolutionStainsArg(arg);
imageData.setColorDeconvolutionStains(stains);
return true;
}
Aggregations