public enum PixelType extends Enum<PixelType>
Pixels/@Type and
TIFF SampleFormat / SamplesPerPixel / PhotometricInterpretation.
Supports single-component grayscale in 8-, 16- and 32-bit forms, plus 8-bit interleaved
3-sample RGB. bytesPerPixel() is bytes per sample (a component);
a pixel occupies bytesPerPixel() * samplesPerPixel() bytes on disk.
| Enum Constant and Description |
|---|
GRAY16 |
GRAY32 |
GRAY8 |
RGB8
8-bit interleaved RGB: a
byte[] of width*height*3, samples ordered R,G,B. |
| Modifier and Type | Field and Description |
|---|---|
static int |
PHOTOMETRIC_MIN_IS_BLACK
TIFF PhotometricInterpretation tag value for grayscale (0 = black).
|
static int |
PHOTOMETRIC_RGB
TIFF PhotometricInterpretation tag value for RGB colour.
|
static int |
SAMPLE_FORMAT_FLOAT
TIFF SampleFormat tag value for IEEE floating-point samples.
|
static int |
SAMPLE_FORMAT_UINT
TIFF SampleFormat tag value for unsigned integer samples.
|
| Modifier and Type | Method and Description |
|---|---|
int |
bitDepth() |
int |
bytesPerPixel()
Bytes per sample (one colour component), e.g.
|
int |
bytesPerPixelPacked()
Total bytes one pixel occupies on disk (
bytesPerPixel() * samplesPerPixel()). |
static PixelType |
fromOme(String type,
int samplesPerPixel)
Resolve a pixel type from an OME-XML
Pixels/@Type string and its
SamplesPerPixel. |
static PixelType |
fromOmeType(String type)
Resolve a pixel type from an OME-XML
Pixels/@Type string (e.g. |
boolean |
isRgb()
Whether this is a multi-component (RGB) format.
|
static PixelType |
of(boolean rgb,
int bitDepth)
Resolve a pixel type from the
(rgb, bitDepth) pair used by the putImage
API (which mirrors NDTiffStorage's signature). |
String |
omeType()
OME-XML
Pixels/@Type string, e.g. |
int |
photometric()
TIFF
PhotometricInterpretation tag value (1 = grayscale, 2 = RGB). |
int |
pixelCount(Object pixels)
Number of pixels represented by a primitive pixel array of this type.
|
int |
sampleFormat() |
int |
samplesPerPixel()
Samples (colour components) per pixel: 1 for grayscale, 3 for RGB.
|
static PixelType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static PixelType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final PixelType GRAY8
public static final PixelType GRAY16
public static final PixelType GRAY32
public static final PixelType RGB8
byte[] of width*height*3, samples ordered R,G,B.public static final int SAMPLE_FORMAT_UINT
public static final int SAMPLE_FORMAT_FLOAT
public static final int PHOTOMETRIC_MIN_IS_BLACK
public static final int PHOTOMETRIC_RGB
public static PixelType[] values()
for (PixelType c : PixelType.values()) System.out.println(c);
public static PixelType valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic String omeType()
Pixels/@Type string, e.g. "uint16".public int bytesPerPixel()
uint16, 1 for RGB8.public int samplesPerPixel()
public int bytesPerPixelPacked()
bytesPerPixel() * samplesPerPixel()).public boolean isRgb()
public int sampleFormat()
public int photometric()
PhotometricInterpretation tag value (1 = grayscale, 2 = RGB).public int bitDepth()
public static PixelType of(boolean rgb, int bitDepth)
(rgb, bitDepth) pair used by the putImage
API (which mirrors NDTiffStorage's signature).rgb - whether the image has multiple colour componentsbitDepth - nominal bits per component (8, 16 or 32)public static PixelType fromOmeType(String type)
Pixels/@Type string (e.g. "uint16"),
assuming a single sample per pixel (grayscale). For RGB, use fromOme(String, int).IllegalArgumentException - for types this library cannot represent, rather than
silently mis-reading the datapublic static PixelType fromOme(String type, int samplesPerPixel)
Pixels/@Type string and its
SamplesPerPixel. RGB shares the "uint8" type string with GRAY8, so
the sample count is what distinguishes them.type - OME pixel type string (e.g. "uint16", "float")samplesPerPixel - components per pixel (1 for grayscale, 3 for RGB)IllegalArgumentException - for types this library cannot representpublic int pixelCount(Object pixels)
Copyright © 2026. All rights reserved.