Class ConsumerFormatImageMaker

java.lang.Object
com.pixelmed.display.ConsumerFormatImageMaker

public class ConsumerFormatImageMaker extends Object

A class of static methods to make consumer format images from DICOM images.

The formats supported depend on what JIIO codecs are available in the JRE and or provided through JIIO; see http://download.java.net/media/jai-imageio/javadoc/1.1/

  • Field Details

  • Constructor Details

    • ConsumerFormatImageMaker

      public ConsumerFormatImageMaker()
  • Method Details

    • makeEightBitFrame

      public static final BufferedImage makeEightBitFrame(SourceImage sImg, int f)

      Create a single frame 8-bit per channel image (windowed if grayscale) from the specified frame.

      Uses the window center and width in the attribute list.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      sImg - the image
      f - the frame, numbered from 0 (not 1)
      Returns:
      an 8 bit BufferedImage of the most favourable type for the platform
    • makeEightBitImage

      public static final BufferedImage makeEightBitImage(AttributeList list) throws DicomException

      Create a single frame 8-bit per channel image (windowed if grayscale) from the first, or only, frame.

      Uses the window center and width in the attribute list.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      list - the DICOM attributes
      Returns:
      an 8 bit BufferedImage
      Throws:
      DicomException - if attribute is not an image
    • makeEightBitImages

      public static final BufferedImage[] makeEightBitImages(AttributeList list) throws DicomException

      Create an array of single frame 8-bit per channel image (windowed if grayscale) from the from the only or all frames.

      Uses the window center and width in the attribute list.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      list - the DICOM attributes
      Returns:
      an array of 8 bit BufferedImages
      Throws:
      DicomException - if attribute is not an image
    • makeEightBitImages

      public static final BufferedImage[] makeEightBitImages(AttributeList list, GeometryOfVolume imageGeometry, Vector<SuperimposedImage> superimposedImages, Vector<Shape>[] arrayOfPerFrameDrawingShapes, int firstFrame, int lastFrame) throws DicomException

      Create an array of single frame 8-bit per channel image (windowed if grayscale) from the from the only or all frames.

      Uses the window center and width in the attribute list.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      list - the DICOM attributes
      imageGeometry - the geometry already extracted from the list, or null if need to extract it (only needed if have superimposedImages)
      superimposedImages - images to to be displayed superimposed on the appropriate frames, or null if none
      arrayOfPerFrameDrawingShapes - per-frame shapes to be displayed on the respective frame
      firstFrame - the first frame to include, numbered from 0 (not 1)
      lastFrame - the last frame to include, numbered from 0 (not 1), or -1 if all frames
      Returns:
      an array of 8 bit BufferedImages
      Throws:
      DicomException - if attribute is not an image
    • makeEightBitImages

      public static final BufferedImage[] makeEightBitImages(AttributeList list, GeometryOfVolume imageGeometry, Vector<SuperimposedImage> superimposedImages, double superimposedToleranceDistance, Vector<Shape>[] arrayOfPerFrameDrawingShapes, int firstFrame, int lastFrame) throws DicomException

      Create an array of single frame 8-bit per channel image (windowed if grayscale) from the from the only or all frames.

      Uses the window center and width in the attribute list.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      list - the DICOM attributes
      imageGeometry - the geometry already extracted from the list, or null if need to extract it (only needed if have superimposedImages)
      superimposedImages - images to to be displayed superimposed on the appropriate frames, or null if none
      superimposedToleranceDistance - difference in distance along normal to orientation for underlying and superimposed frames to be close enough to superimpose, in mm
      arrayOfPerFrameDrawingShapes - per-frame shapes to be displayed on the respective frame
      firstFrame - the first frame to include, numbered from 0 (not 1)
      lastFrame - the last frame to include, numbered from 0 (not 1), or -1 if all frames
      Returns:
      an array of 8 bit BufferedImages
      Throws:
      DicomException - if attribute is not an image
    • convertFileToEightBitImage

      public static String[] convertFileToEightBitImage(String dicomFileName, String outputFileName, String outputFormat) throws DicomException, IOException

      Read a DICOM image input file, and create single frame 8-bit per channel images (windowed if grayscale) from the only or all frames.

      If the input file has multiple frames, the output file name will be postfixed with the frame number before the format extension, e.g., "output.jpg" will become "output_001.jpg", etc.

      Uses the window center and width in the file.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      dicomFileName - the input file name
      outputFileName - the output file name (or basis of names for multiple frames)
      outputFormat - the output file format name that a JIIO SPI will recognize (e.g. "jpeg")
      Returns:
      a String[] of the output filenames ordered by the frame order of the input image
      Throws:
      DicomException
      IOException
    • replaceWindowWidthAndCenterInAttributeList

      public static void replaceWindowWidthAndCenterInAttributeList(AttributeList list, Attribute aWindowWidth, Attribute aWindowCenter)
    • replaceWindowWidthAndCenterInFunctionalGroupSequences

      public static void replaceWindowWidthAndCenterInFunctionalGroupSequences(AttributeList list, int nFrames, Attribute aWindowWidth, Attribute aWindowCenter)
    • convertFileToEightBitImage

      public static String[] convertFileToEightBitImage(String dicomFileName, String outputFileName, String outputFormat, double windowCenter, double windowWidth, int imageWidth, int imageHeight, int imageQuality, String annotation) throws DicomException, IOException

      Read a DICOM image input file, and create single frame 8-bit per channel images (windowed if grayscale) from the only or all frames.

      If the input file has multiple frames, the output file name will be postfixed with the frame number before the format extension, e.g., "output.jpg" will become "output_001.jpg", etc.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      dicomFileName - the input file name
      outputFileName - the output file name (or basis of names for multiple frames)
      outputFormat - the output file format name that a JIIO SPI will recognize (e.g. "jpeg")
      windowCenter - the window center to use
      windowWidth - the window width to use, or 0 if to use the width and center in the DICOM file
      imageWidth - the width (number of columns) to make, or <= 0 if default (the width in the DICOM file, or scaled by height with pixel aspect ratio preserved)
      imageHeight - the height (number of rows) to make, or <= 0 if default (the height in the DICOM file, or scaled by width with pixel aspect ratio preserved)
      imageQuality - the image quality from 1 to 100 (best), or -1 if absent
      annotation - the type of annotation to apply (choice is "all"; anything else means no annotation), or null if absent
      Returns:
      a String[] of the output filenames ordered by the frame order of the input image
      Throws:
      DicomException
      IOException
    • convertFileToEightBitImage

      public static String[] convertFileToEightBitImage(String dicomFileName, String outputFileName, String outputFormat, double windowCenter, double windowWidth, int imageWidth, int imageHeight, int regionX, int regionY, int regionWidth, int regionHeight, int firstFrame, int lastFrame, int imageQuality, String annotation) throws DicomException, IOException

      Read a DICOM image input file, and create single frame 8-bit per channel images (windowed if grayscale) from the only or all frames.

      If the input file has multiple frames, the output file name will be postfixed with the frame number before the format extension, e.g., "output.jpg" will become "output_001.jpg", etc.

      The aspect ratio of the sub-region width and height, if any, should be the same as that of any explicitly specified image width and height, to avoid distortion.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      dicomFileName - the input file name
      outputFileName - the output file name (or basis of names for multiple frames)
      outputFormat - the output file format name that a JIIO SPI will recognize (e.g. "jpeg")
      windowCenter - the window center to use
      windowWidth - the window width to use, or 0 if to use the width and center in the DICOM file
      imageWidth - the width (number of columns) to make, or <= 0 if default (the width in the DICOM file, or scaled by height with pixel aspect ratio preserved)
      imageHeight - the height (number of rows) to make, or <= 0 if default (the height in the DICOM file, or scaled by width with pixel aspect ratio preserved)
      regionX - the x (along row) integer offset (from 0 being the TLHC pixel) of the sub-region to write
      regionY - the y (down column) integer offset (from 0 being the TLHC pixel) of the sub-region to write
      regionWidth - the width (number of columns) to write, or <= 0 if no sub-region selected (i.e., write the whole image)
      regionHeight - the height (number of rows) to write, or <= 0 if no sub-region selected (i.e., write the whole image)
      firstFrame - the first frame to include, numbered from 0 (not 1)
      lastFrame - the last frame to include, numbered from 0 (not 1), or -1 if all frames
      imageQuality - the image quality from 1 to 100 (best), or -1 if absent
      annotation - the type of annotation to apply (choice is "all"; anything else means no annotation), or null if absent
      Returns:
      a String[] of the output filenames ordered by the frame order of the input image
      Throws:
      DicomException
      IOException
    • convertFileToEightBitImage

      public static String[] convertFileToEightBitImage(String dicomFileName, String outputFileName, String outputFormat, double windowCenter, double windowWidth, int imageWidth, int imageHeight, int imageQuality, String annotation, Vector<SuperimposedImage> superimposedImages, double superimposedToleranceDistance, Vector<Shape>[] arrayOfPerFrameDrawingShapes) throws DicomException, IOException

      Read a DICOM image input file, and create single frame 8-bit per channel images (windowed if grayscale) from the only or all frames.

      If the input file has multiple frames, the output file name will be postfixed with the frame number before the format extension, e.g., "output.jpg" will become "output_001.jpg", etc.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      dicomFileName - the input file name
      outputFileName - the output file name (or basis of names for multiple frames)
      outputFormat - the output file format name that a JIIO SPI will recognize (e.g. "jpeg")
      windowCenter - the window center to use
      windowWidth - the window width to use, or 0 if to use the width and center in the DICOM file
      imageWidth - the width (number of columns) to make, or <= 0 if default (the width in the DICOM file, or scaled by height with pixel aspect ratio preserved)
      imageHeight - the height (number of rows) to make, or <= 0 if default (the height in the DICOM file, or scaled by width with pixel aspect ratio preserved)
      imageQuality - the image quality from 1 to 100 (best), or -1 if absent
      annotation - the type of annotation to apply (choice is "all"; anything else means no annotation), or null if absent
      superimposedImages - images to to be displayed superimposed on the appropriate frames, or null if none
      superimposedToleranceDistance - difference in distance along normal to orientation for underlying and superimposed frames to be close enough to superimpose, in mm
      arrayOfPerFrameDrawingShapes - per-frame shapes to be displayed on the respective frame, or null if none
      Returns:
      a String[] of the output filenames ordered by the frame order of the input image
      Throws:
      DicomException
      IOException
    • convertFileToEightBitImage

      public static String[] convertFileToEightBitImage(String dicomFileName, String outputFileName, String outputFormat, double windowCenter, double windowWidth, int imageWidth, int imageHeight, int imageQuality, String annotation, Vector<SuperimposedImage> superimposedImages, Vector<Shape>[] arrayOfPerFrameDrawingShapes) throws DicomException, IOException

      Read a DICOM image input file, and create single frame 8-bit per channel images (windowed if grayscale) from the only or all frames.

      If the input file has multiple frames, the output file name will be postfixed with the frame number before the format extension, e.g., "output.jpg" will become "output_001.jpg", etc.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      dicomFileName - the input file name
      outputFileName - the output file name (or basis of names for multiple frames)
      outputFormat - the output file format name that a JIIO SPI will recognize (e.g. "jpeg")
      windowCenter - the window center to use
      windowWidth - the window width to use, or 0 if to use the width and center in the DICOM file
      imageWidth - the width (number of columns) to make, or <= 0 if default (the width in the DICOM file, or scaled by height with pixel aspect ratio preserved)
      imageHeight - the height (number of rows) to make, or <= 0 if default (the height in the DICOM file, or scaled by width with pixel aspect ratio preserved)
      imageQuality - the image quality from 1 to 100 (best), or -1 if absent
      annotation - the type of annotation to apply (choice is "all"; anything else means no annotation), or null if absent
      superimposedImages - images to to be displayed superimposed on the appropriate frames, or null if none
      arrayOfPerFrameDrawingShapes - per-frame shapes to be displayed on the respective frame, or null if none
      Returns:
      a String[] of the output filenames ordered by the frame order of the input image
      Throws:
      DicomException
      IOException
    • convertFileToEightBitImage

      public static String[] convertFileToEightBitImage(String dicomFileName, String outputFileName, String outputFormat, double windowCenter, double windowWidth, int imageWidth, int imageHeight, int regionX, int regionY, int regionWidth, int regionHeight, int firstFrame, int lastFrame, int imageQuality, String annotation, Vector<SuperimposedImage> superimposedImages, Vector<Shape>[] arrayOfPerFrameDrawingShapes) throws DicomException, IOException

      Read a DICOM image input file, and create single frame 8-bit per channel images (windowed if grayscale) from the only or all frames.

      If the input file has multiple frames, the output file name will be postfixed with the frame number before the format extension, e.g., "output.jpg" will become "output_001.jpg", etc.

      The aspect ratio of the sub-region width and height, if any, should be the same as that of any explicitly specified image width and height, to avoid distortion.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      dicomFileName - the input file name
      outputFileName - the output file name (or basis of names for multiple frames)
      outputFormat - the output file format name that a JIIO SPI will recognize (e.g. "jpeg")
      windowCenter - the window center to use
      windowWidth - the window width to use, or 0 if to use the width and center in the DICOM file
      imageWidth - the width (number of columns) to make, or <= 0 if default (the width in the DICOM file, or scaled by height with pixel aspect ratio preserved)
      imageHeight - the height (number of rows) to make, or <= 0 if default (the height in the DICOM file, or scaled by width with pixel aspect ratio preserved)
      regionX - the x (along row) integer offset (from 0 being the TLHC pixel) of the sub-region to write
      regionY - the y (down column) integer offset (from 0 being the TLHC pixel) of the sub-region to write
      regionWidth - the width (number of columns) to write, or <= 0 if no sub-region selected (i.e., write the whole image)
      regionHeight - the height (number of rows) to write, or <= 0 if no sub-region selected (i.e., write the whole image)
      firstFrame - the first frame to include, numbered from 0 (not 1)
      lastFrame - the last frame to include, numbered from 0 (not 1), or -1 if all frames
      imageQuality - the image quality from 1 to 100 (best), or -1 if absent
      annotation - the type of annotation to apply (choice is "all"; anything else means no annotation), or null if absent
      superimposedImages - images to to be displayed superimposed on the appropriate frames, or null if none
      arrayOfPerFrameDrawingShapes - per-frame shapes to be displayed on the respective frame, or null if none
      Returns:
      a String[] of the output filenames ordered by the frame order of the input image
      Throws:
      DicomException
      IOException
    • convertFileToEightBitImage

      public static String[] convertFileToEightBitImage(String dicomFileName, String outputFileName, String outputFormat, double windowCenter, double windowWidth, int imageWidth, int imageHeight, int regionX, int regionY, int regionWidth, int regionHeight, int firstFrame, int lastFrame, int imageQuality, String annotation, Vector<SuperimposedImage> superimposedImages, double superimposedToleranceDistance, Vector<Shape>[] arrayOfPerFrameDrawingShapes) throws DicomException, IOException

      Read a DICOM image input file, and create single frame 8-bit per channel images (windowed if grayscale) from the only or all frames.

      If the input file has multiple frames, the output file name will be postfixed with the frame number before the format extension, e.g., "output.jpg" will become "output_001.jpg", etc.

      The aspect ratio of the sub-region width and height, if any, should be the same as that of any explicitly specified image width and height, to avoid distortion.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      dicomFileName - the input file name
      outputFileName - the output file name (or basis of names for multiple frames)
      outputFormat - the output file format name that a JIIO SPI will recognize (e.g. "jpeg")
      windowCenter - the window center to use
      windowWidth - the window width to use, or 0 if to use the width and center in the DICOM file
      imageWidth - the width (number of columns) to make, or <= 0 if default (the width in the DICOM file, or scaled by height with pixel aspect ratio preserved)
      imageHeight - the height (number of rows) to make, or <= 0 if default (the height in the DICOM file, or scaled by width with pixel aspect ratio preserved)
      regionX - the x (along row) integer offset (from 0 being the TLHC pixel) of the sub-region to write
      regionY - the y (down column) integer offset (from 0 being the TLHC pixel) of the sub-region to write
      regionWidth - the width (number of columns) to write, or <= 0 if no sub-region selected (i.e., write the whole image)
      regionHeight - the height (number of rows) to write, or <= 0 if no sub-region selected (i.e., write the whole image)
      firstFrame - the first frame to include, numbered from 0 (not 1)
      lastFrame - the last frame to include, numbered from 0 (not 1), or -1 if all frames
      imageQuality - the image quality from 1 to 100 (best), or -1 if absent
      annotation - the type of annotation to apply (choice is "all"; anything else means no annotation), or null if absent
      superimposedImages - images to to be displayed superimposed on the appropriate frames, or null if none
      superimposedToleranceDistance - difference in distance along normal to orientation for underlying and superimposed frames to be close enough to superimpose, in mm
      arrayOfPerFrameDrawingShapes - per-frame shapes to be displayed on the respective frame, or null if none
      Returns:
      a String[] of the output filenames ordered by the frame order of the input image
      Throws:
      DicomException
      IOException
    • writeEightBitImageForFrame

      public static void writeEightBitImageForFrame(BufferedImage renderedImage, Iterator<TextAnnotationPositioned> annotations, String outputFileName, String outputFormat, int imageWidth, int imageHeight, int regionX, int regionY, int regionWidth, int regionHeight, int imageQuality, boolean useColorForAnnotations) throws DicomException, IOException

      Write a single frame 8-bit per channel BufferedImage.

      The aspect ratio of the sub-region width and height, if any, should be the same as that of any explicitly specified image width and height, to avoid distortion.

      Parameters:
      renderedImage - the 8 bit image (already windowed if grayscale)
      annotations - an Iterator of annotations to apply, or null if none
      outputFileName - the output file name
      outputFormat - the output file format name that a JIIO SPI will recognize (e.g. "jpeg")
      imageWidth - the width (number of columns) to write, or <= 0 if default (the width in the DICOM file, or scaled by height with pixel aspect ratio preserved)
      imageHeight - the height (number of rows) to weite, or <= 0 if default (the height in the DICOM file, or scaled by width with pixel aspect ratio preserved)
      regionX - the x (along row) integer offset (from 0 being the TLHC pixel) of the sub-region to write
      regionY - the y (down column) integer offset (from 0 being the TLHC pixel) of the sub-region to write
      regionWidth - the width (number of columns) to write, or <= 0 if no sub-region selected (i.e., write the whole image)
      regionHeight - the height (number of rows) to write, or <= 0 if no sub-region selected (i.e., write the whole image)
      imageQuality - the image quality from 1 to 100 (best), or -1 if absent
      useColorForAnnotations - use color for annotations (i.e., produce color output image even if input is grayscale)
      Throws:
      DicomException
      IOException
    • main

      public static void main(String[] arg)

      Read a DICOM image input file, and create single frame 8-bit per channel images (windowed if grayscale) from the only or all frames.

      If the input file has multiple frames, the output file name will be postfixed with the frame number before the format extension, e.g., "output.jpg" will become "output_001.jpg", etc.

      The aspect ratio of the sub-region width and height, if any, should be the same as that of any explicitly specified image width and height, to avoid distortion.

      Performs any necessary color space transformation (e.g., from YBR to RGB) to make the result displayable.

      Parameters:
      arg - two required parameters, the input file name, output file name (or basis of names for multiple frames), optionally the format (defaults to jpeg), then optionally the window center and width, then optionally the desired width and height (or 0 if to use the width and center in the DICOM file and more arguments), then optionally the image quality from 0 to 100 (or -1 to use default), then optionally whether or not to include annotation (choice is "all" or "icon" +/- "color", e.g., "all_color"; anything else means no annotation; default is "all_color") then optionally the sub region x, y, width and height then optionally the first and last frame (-1 if all frames)