java.lang.Object
imagingbook.common.image.PixelPack
imagingbook.common.image.ColorPack
This class defines a "color stack" as a subtype of
PixelPack
with exactly 3 components (slices), representing
a color image in a specific color space (default is sRGB65ColorSpace
). It allows simple conversion to other
color spaces (see convertFromSrgbTo(ColorSpace)
). All conversions are 'destructive', i.e., the affected
color stack is modified. Pixel values are typically in [0,1], depending on the associated color space. A
ColorPack
may be created from an existing ColorProcessor
whose pixels are assumed to be in sRGB color
space (see ColorPack(ColorProcessor)
). To be converted back to a ColorProcessor
, the
ColorPack
must be in sRGB color space (see convertToSrgb()
).- Version:
- 2022/09/10
-
Nested Class Summary
Nested classes/interfaces inherited from class imagingbook.common.image.PixelPack
PixelPack.PixelSlice
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
convertFromSrgbTo
(ColorSpace targetColorspace) Converts the pixel values of thisColorPack
to the specified color space.void
Converts thisColorPack
to sRGB space.Returns the current color space instance of thisColorPack
.Returns the 3 color components as an array ofFloatProcessor
.Converts thisPixelPack
to a newColorProcessor
instance.toColorProcessor
(double scale) Converts thisPixelPack
to a newColorProcessor
instance.Converts thisPixelPack
to a newImageStack
with the same number of slices (seePixelPack.getDepth()
).Methods inherited from class imagingbook.common.image.PixelPack
copyFromImageProcessor, copyFromImageProcessor, copyTo, copyToImageProcessor, copyToImageProcessor, get3x3Neighborhood, getData, getDepth, getEmptySlice, getFloatProcessor, getFloatProcessors, getHeight, getOutOfBoundsStrategy, getPix, getPix, getPix, getPix, getSlice, getSlices, getVec, getVec, getWidth, isCompatibleTo, isCompatibleTo, setPix, setPix, setVec, toByteProcessor, toByteProcessor, toFloatProcessor, toFloatProcessor, toShortProcessor, toShortProcessor, zero
-
Constructor Details
-
ColorPack
Constructor.- Parameters:
cp
- a color image assumed to be in sRGB
-
-
Method Details
-
getProcessors
Returns the 3 color components as an array ofFloatProcessor
.- Returns:
- a
FloatProcessor
array
-
getColorspace
Returns the current color space instance of thisColorPack
.- Returns:
- the current color space
-
convertFromSrgbTo
Converts the pixel values of thisColorPack
to the specified color space. The color stack must be in sRGB space. An exceptions is thrown if the color stack is not in sRGB color space. Has no effect if the target color space already is sRGB.- Parameters:
targetColorspace
- the new color space
-
convertToSrgb
Converts thisColorPack
to sRGB space. Has no effect if the color stack is in sRGB color space already. -
toColorProcessor
Description copied from class:PixelPack
Converts thisPixelPack
to a newColorProcessor
instance. An exception is thrown if the depth of the pack is not equal 3. Component values are rounded, no scale factor is applied.- Overrides:
toColorProcessor
in classPixelPack
- Returns:
- a new
ColorProcessor
instance
-
toColorProcessor
Description copied from class:PixelPack
Converts thisPixelPack
to a newColorProcessor
instance. An exception is thrown if the depth of the pack is not equal 3.- Overrides:
toColorProcessor
in classPixelPack
- Parameters:
scale
- scale factor applied to component values (before rounding)- Returns:
- a new
ColorProcessor
instance
-
toImageStack
Description copied from class:PixelPack
Converts thisPixelPack
to a newImageStack
with the same number of slices (seePixelPack.getDepth()
). The stack images are of typeFloatProcessor
. The resultingImageStack
does not share any pixel data with thisPixelPack
.- Overrides:
toImageStack
in classPixelPack
- Returns:
- a new
ImageStack
instance
-