Class ColorImages

java.lang.Object
inra.ijpb.data.image.ColorImages

public class ColorImages
extends java.lang.Object
A set of static methods for working with color images.
Author:
David Legland
  • Method Summary

    Modifier and Type Method Description
    static ij.ImagePlus binaryOverlay​(ij.ImagePlus imagePlus, ij.ImagePlus maskPlus, java.awt.Color color)
    Applies an overlay of a binary image mask onto a grayscale or color image, using the specified color.
    static ij.ImagePlus binaryOverlay​(ij.ImagePlus refImage, ij.ImagePlus binaryMask, java.awt.Color overlayColor, double overlayOpacity)
    Applies an overlay of a binary image mask onto a 2D or 3D grayscale image, using the specified color and opacity.
    static ij.ImageStack binaryOverlay​(ij.ImageStack refImage, ij.ImageStack mask, java.awt.Color color)
    Applies an overlay of a binary image mask onto a grayscale or color image, using the specified color.
    static ij.ImageStack binaryOverlay​(ij.ImageStack refImage, ij.ImageStack binaryMask, java.awt.Color overlayColor, double overlayOpacity)
    Computes the overlay of a binary image over a grayscale image, using an opacity for the binary layer.
    static ij.process.ColorProcessor binaryOverlay​(ij.process.ByteProcessor refImage, ij.process.ImageProcessor binaryMask, java.awt.Color overlayColor, double overlayOpacity)
    Applies an overlay of a binary image mask onto a grayscale image, using the specified color and opacity.
    static ij.process.ImageProcessor binaryOverlay​(ij.process.ImageProcessor refImage, ij.process.ImageProcessor mask, java.awt.Color color)
    Applies an overlay of a binary image mask onto a grayscale or color image, using the specified color.
    static ij.ImagePlus labelMapOverlay​(ij.ImagePlus refImage, ij.ImagePlus labelMap, double overlayOpacity)
    Applies an overlay of a label map onto a 2D/3D grayscale image, using the specified opacity.
    static ij.ImageStack labelMapOverlay​(ij.ImageStack refImage, ij.ImageStack labelMap, double overlayOpacity)
    Applies an overlay of a label map onto a 3D grayscale image, using the specified opacity.
    static ij.process.ImageProcessor labelMapOverlay​(ij.process.ImageProcessor refImage, ij.process.ImageProcessor labelMap, double overlayOpacity)
    Applies an overlay of a label map onto a grayscale image, using the specified opacity.
    static java.util.HashMap<java.lang.String,​ij.ImageStack> mapChannels​(ij.ImageStack image)
    Splits the channels of the 3D color image into three new instances of ImageStack containing ByteProcessors.
    static java.util.HashMap<java.lang.String,​ij.process.ByteProcessor> mapChannels​(ij.process.ImageProcessor image)
    Splits the channels of the color image and returns the new ByteImages into a Map, using channel names as key.
    static ij.ImageStack mergeChannels​(ij.ImageStack red, ij.ImageStack green, ij.ImageStack blue)
    Creates a new color ImageStack from the red, green and blue ImageStack instances.
    static ij.process.ColorProcessor mergeChannels​(ij.process.ImageProcessor red, ij.process.ImageProcessor green, ij.process.ImageProcessor blue)
    Creates a new ColorProcessor from the red, green and blue channels.
    static ij.process.ColorProcessor mergeChannels​(java.util.Collection<ij.process.ImageProcessor> channels)
    Creates a new ColorProcessor from a collection of three channels.
    static void print​(ij.process.ColorProcessor image)
    Prints the content of the input color image on the console.
    static java.util.Collection<ij.ImageStack> splitChannels​(ij.ImageStack image)
    Splits the channels of the color image into three new instances of ByteProcessor.
    static java.util.Collection<ij.process.ByteProcessor> splitChannels​(ij.process.ImageProcessor image)
    Splits the channels of the color image into three new instances of ByteProcessor.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • print

      public static final void print​(ij.process.ColorProcessor image)
      Prints the content of the input color image on the console. This can be used for debugging (small) images.
      Parameters:
      image - the color image to display on the console
    • splitChannels

      public static final java.util.Collection<ij.process.ByteProcessor> splitChannels​(ij.process.ImageProcessor image)
      Splits the channels of the color image into three new instances of ByteProcessor.
      Parameters:
      image - the original image, assumed to be a ColorProcessor
      Returns:
      a collection containing the red, green and blue channels
    • splitChannels

      public static final java.util.Collection<ij.ImageStack> splitChannels​(ij.ImageStack image)
      Splits the channels of the color image into three new instances of ByteProcessor.
      Parameters:
      image - the original image, assumed to be a ColorProcessor
      Returns:
      a collection containing the red, green and blue channels
    • mapChannels

      public static final java.util.HashMap<java.lang.String,​ij.process.ByteProcessor> mapChannels​(ij.process.ImageProcessor image)
      Splits the channels of the color image and returns the new ByteImages into a Map, using channel names as key. Example:
      
       ColorProcessor colorImage = ...
       HashMap<String, ByteProcessor> channels = mapChannels(colorImage);
       ByteProcessor blue = channels.get("blue");
       
      Parameters:
      image - the original image, assumed to be a ColorProcessor
      Returns:
      a hashmap indexing the three channels by their names
    • mapChannels

      public static final java.util.HashMap<java.lang.String,​ij.ImageStack> mapChannels​(ij.ImageStack image)
      Splits the channels of the 3D color image into three new instances of ImageStack containing ByteProcessors.
      Parameters:
      image - the original image, assumed to be a ColorProcessor
      Returns:
      a collection containing the red, green and blue channels
    • mergeChannels

      public static final ij.process.ColorProcessor mergeChannels​(java.util.Collection<ij.process.ImageProcessor> channels)
      Creates a new ColorProcessor from a collection of three channels.
      Parameters:
      channels - a collection containing the red, green and blue channels
      Returns:
      the color image corresponding to the concatenation of the three channels
      Throws:
      java.lang.IllegalArgumentException - if the collection contains less than three channels
    • mergeChannels

      public static final ij.process.ColorProcessor mergeChannels​(ij.process.ImageProcessor red, ij.process.ImageProcessor green, ij.process.ImageProcessor blue)
      Creates a new ColorProcessor from the red, green and blue channels. Each channel must be an instance of ByteProcessor.
      Parameters:
      red - the image for the red channel (must be a ByteProcessor)
      green - the image for the green channel (must be a ByteProcessor)
      blue - the image for the blue channel (must be a ByteProcessor)
      Returns:
      the color image corresponding to the concatenation of the three channels
      Throws:
      java.lang.IllegalArgumentException - if one of the channel is not an instance of ByteProcessor
    • mergeChannels

      public static final ij.ImageStack mergeChannels​(ij.ImageStack red, ij.ImageStack green, ij.ImageStack blue)
      Creates a new color ImageStack from the red, green and blue ImageStack instances. Each channel must contains instances of ByteProcessor.
      Parameters:
      red - the image for the red channel (must contain ByteProcessor instances)
      green - the image for the green channel (must contain ByteProcessor instances)
      blue - the image for the blue channel (must contain ByteProcessor instances)
      Returns:
      the color image corresponding to the concatenation of the three channels
      Throws:
      java.lang.IllegalArgumentException - if one of the ImageStack does not contain instances of ByteProcessor
    • binaryOverlay

      public static final ij.ImagePlus binaryOverlay​(ij.ImagePlus imagePlus, ij.ImagePlus maskPlus, java.awt.Color color)
      Applies an overlay of a binary image mask onto a grayscale or color image, using the specified color. Both images must have the same size.
      Parameters:
      imagePlus - the original 2D or 3D image used as background
      maskPlus - the binary 2D or 3D mask image
      color - the color used to display overlay
      Returns:
      a new ImagePlus instance containing a 2D or 3D color image
    • binaryOverlay

      public static final ij.process.ImageProcessor binaryOverlay​(ij.process.ImageProcessor refImage, ij.process.ImageProcessor mask, java.awt.Color color)
      Applies an overlay of a binary image mask onto a grayscale or color image, using the specified color. Both images must have the same size.
      Parameters:
      refImage - the original image used as background
      mask - the binary mask image
      color - the color used to display overlay
      Returns:
      a new ImageProcessor instance containing a 2D color image
    • binaryOverlay

      public static final ij.ImageStack binaryOverlay​(ij.ImageStack refImage, ij.ImageStack mask, java.awt.Color color)
      Applies an overlay of a binary image mask onto a grayscale or color image, using the specified color. Both images must have the same size.
      Parameters:
      refImage - the original 3D image used as background
      mask - the binary 3D mask image
      color - the color used to display overlay
      Returns:
      a new ImageStack containing a 3D color image
    • binaryOverlay

      public static final ij.ImagePlus binaryOverlay​(ij.ImagePlus refImage, ij.ImagePlus binaryMask, java.awt.Color overlayColor, double overlayOpacity)
      Applies an overlay of a binary image mask onto a 2D or 3D grayscale image, using the specified color and opacity. Both images must have the same size.
      Parameters:
      refImage - the original 2D or 3D image used as background
      binaryMask - the binary mask image
      overlayColor - the color used to display overlay
      overlayOpacity - the overlay opacity, between 0 and 1.
      Returns:
      a new ImageProcessor instance containing a 2D color image
    • binaryOverlay

      public static final ij.process.ColorProcessor binaryOverlay​(ij.process.ByteProcessor refImage, ij.process.ImageProcessor binaryMask, java.awt.Color overlayColor, double overlayOpacity)
      Applies an overlay of a binary image mask onto a grayscale image, using the specified color and opacity. Both images must have the same size.
      Parameters:
      refImage - the original 2D image used as background
      binaryMask - the binary mask image
      overlayColor - the color used to display overlay
      overlayOpacity - the overlay opacity, between 0 and 1.
      Returns:
      a new ImageProcessor instance containing a 2D color image
    • binaryOverlay

      public static final ij.ImageStack binaryOverlay​(ij.ImageStack refImage, ij.ImageStack binaryMask, java.awt.Color overlayColor, double overlayOpacity)
      Computes the overlay of a binary image over a grayscale image, using an opacity for the binary layer. The result is returned as a Color Stack.
      Parameters:
      refImage - the grayscale image used as reference.
      binaryMask - the binary mask, with non zero values where a overlay must occur
      overlayColor - the color used for painting overlay
      overlayOpacity - the opacity used for painting overlay, between 0 (totally transparent) and 1 (totally opaque)
      Returns:
      the result of overlay, as a Color stack
    • labelMapOverlay

      public static final ij.ImagePlus labelMapOverlay​(ij.ImagePlus refImage, ij.ImagePlus labelMap, double overlayOpacity)
      Applies an overlay of a label map onto a 2D/3D grayscale image, using the specified opacity. Both images must have the same size.
      Parameters:
      refImage - the original 2D or 3D image used as background
      labelMap - the label map used as overlay
      overlayOpacity - the overlay opacity, between 0 and 1.
      Returns:
      a new ImageProcessor instance containing a 2D color image
    • labelMapOverlay

      public static final ij.process.ImageProcessor labelMapOverlay​(ij.process.ImageProcessor refImage, ij.process.ImageProcessor labelMap, double overlayOpacity)
      Applies an overlay of a label map onto a grayscale image, using the specified opacity. Both images must have the same size.
      Parameters:
      refImage - the original 2D image used as background
      labelMap - the label map used as overlay
      overlayOpacity - the overlay opacity, between 0 and 1.
      Returns:
      a new ImageProcessor instance containing a 2D color image
    • labelMapOverlay

      public static final ij.ImageStack labelMapOverlay​(ij.ImageStack refImage, ij.ImageStack labelMap, double overlayOpacity)
      Applies an overlay of a label map onto a 3D grayscale image, using the specified opacity. Both images must have the same size.
      Parameters:
      refImage - the original 3D image used as background
      labelMap - the label map used as overlay
      overlayOpacity - the overlay opacity, between 0 and 1.
      Returns:
      a new ImageStack instance containing a 3D color image