Class ImageEditUtilities


  • public class ImageEditUtilities
    extends java.lang.Object

    A class of utility methods for editing image pixel data.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void blackout​(SourceImage srcImg, AttributeList list, java.util.Vector shapes)
      Blackout specified regions in an image, for example to remove burned in identification.
      static void blackout​(SourceImage srcImg, AttributeList list, java.util.Vector shapes, boolean burnInOverlays)
      Blackout specified regions in an image, for example to remove burned in identification.
      static void blackout​(SourceImage srcImg, AttributeList list, java.util.Vector shapes, boolean burnInOverlays, boolean usePixelPaddingValue, boolean useSpecifiedBlackoutValue, int specifiedBlackoutValue)
      Blackout specified regions in an image, for example to remove burned in identification.
      static java.io.File blackoutJPEGBlocks​(AttributeList list, java.util.Vector shapes)
      Blackout JPEG encoded blocks of specified regions in an image, for example to remove burned in identification.
      static void blackoutJPEGBlocks​(java.io.File srcFile, java.io.File dstFile, java.util.Vector shapes)
      Blackout JPEG encoded blocks of specified regions in an image, for example to remove burned in identification.
      static int getOffsetIntoMatrix​(int offset, int row, int column, int width)  
      static int getOffsetIntoMatrix​(int fixedOffset, int row, int column, int height, int width, int rotation, boolean horizontal_flip)  
      static void rotateAndFlip​(SourceImage srcImg, AttributeList list, int rotation, boolean horizontal_flip)
      Rotate an image in 90 degree increments, optionally followed by a horizontal flip.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • usePixelDataTemporaryFilesIfPixelDataLengthGreaterThan

        protected static long usePixelDataTemporaryFilesIfPixelDataLengthGreaterThan
      • useMultiplePixelDataTemporaryFilesIfPixelDataLengthGreaterThan

        protected static long useMultiplePixelDataTemporaryFilesIfPixelDataLengthGreaterThan
    • Method Detail

      • blackoutJPEGBlocks

        public static java.io.File blackoutJPEGBlocks​(AttributeList list,
                                                      java.util.Vector shapes)
                                               throws DicomException,
                                                      java.io.IOException,
                                                      java.lang.Exception

        Blackout JPEG encoded blocks of specified regions in an image, for example to remove burned in identification.

        Other JPEG blocks remain untouched, i.e., to avoid loss involved in decompression and recompression of blocks that do not intersect with the specified regions.

        Overlays are not burned in.

        The replacement pixel value is not controllable

        The accompanying attribute list will be updated with new Pixel Data and other Image Pixel Module attributes will be unchanged.

        Parameters:
        list - the attribute list corresponding image
        shapes - a java.util.Vector of java.awt.Shape, specifed in image-relative coordinates
        Returns:
        the temporary File used to store the JPEG frames, if any, already set to deleteOnExit()
        Throws:
        DicomException - if something bad happens handling the attribute list
        java.io.IOException - if something bad happens reading or writing the files
        java.lang.Exception - if something bad happens during processing of the JPEG blocks
      • blackoutJPEGBlocks

        public static void blackoutJPEGBlocks​(java.io.File srcFile,
                                              java.io.File dstFile,
                                              java.util.Vector shapes)
                                       throws DicomException,
                                              java.io.IOException,
                                              java.lang.Exception

        Blackout JPEG encoded blocks of specified regions in an image, for example to remove burned in identification.

        Other JPEG blocks remain untouched, i.e., to avoid loss involved in decompression and recompression of blocks that do not intersect with the specified regions.

        Overlays are not burned in.

        The replacement pixel value is not controllable

        The accompanying attribute list will be updated with new Pixel Data and other Image Pixel Module attributes will be unchanged.

        Parameters:
        srcFile - the DICOM file containing the JPEG compressed image to be blacked out
        dstFile - the DICOM file containing the JPEG compressed image with the blocks intersecting the specified regions blacked out
        shapes - a java.util.Vector of java.awt.Shape, specifed in image-relative coordinates
        Throws:
        DicomException - if something bad happens handling the attribute list
        java.io.IOException - if something bad happens reading or writing the files
        java.lang.Exception - if something bad happens during processing of the JPEG blocks
      • blackout

        public static void blackout​(SourceImage srcImg,
                                    AttributeList list,
                                    java.util.Vector shapes)
                             throws DicomException

        Blackout specified regions in an image, for example to remove burned in identification.

        Overlays are not burned in.

        The replacement pixel value is the smallest possible pixel value based on signedness and bit depth.

        The accompanying attribute list will be updated with new Pixel Data and related Image Pixel Module attributes.

        Note that original PhotometricInterpretation will be retained; care should be taken by the caller to change this as appropriate, e.g., from YBR_FULL_422 if read as JPEG to RGB if written as uncompressed. See, for example, AttributeList.correctDecompressedImagePixelModule().

        Parameters:
        srcImg - the image
        list - the attribute list corresponding image
        shapes - a java.util.Vector of java.awt.Shape, specifed in image-relative coordinates
        Throws:
        DicomException - if something bad happens handling the attribute list
      • blackout

        public static void blackout​(SourceImage srcImg,
                                    AttributeList list,
                                    java.util.Vector shapes,
                                    boolean burnInOverlays)
                             throws DicomException

        Blackout specified regions in an image, for example to remove burned in identification.

        Overlays may be burned in (and their corresponding attribues removed from the AttributeList).

        The replacement pixel value is the smallest possible pixel value based on signedness and bit depth.

        The accompanying attribute list will be updated with new Pixel Data and related Image Pixel Module attributes.

        Note that original PhotometricInterpretation will be retained; care should be taken by the caller to change this as appropriate, e.g., from YBR_FULL_422 if read as JPEG to RGB if written as uncompressed. See, for example, AttributeList.correctDecompressedImagePixelModule().

        Parameters:
        srcImg - the image
        list - the attribute list corresponding image
        shapes - a java.util.Vector of java.awt.Shape, specifed in image-relative coordinates
        burnInOverlays - whether or not to burn in overlays
        Throws:
        DicomException - if something bad happens handling the attribute list
      • blackout

        public static void blackout​(SourceImage srcImg,
                                    AttributeList list,
                                    java.util.Vector shapes,
                                    boolean burnInOverlays,
                                    boolean usePixelPaddingValue,
                                    boolean useSpecifiedBlackoutValue,
                                    int specifiedBlackoutValue)
                             throws DicomException

        Blackout specified regions in an image, for example to remove burned in identification.

        Overlays may be burned in (and their corresponding attribues removed from the AttributeList).

        The replacement pixel value may be constrained to a specific value (typically zero), rather than the using the pixel padding value, if present, or the default, which is the smallest possible pixel value based on signedness and bit depth.

        The accompanying attribute list will be updated with new Pixel Data and related Image Pixel Module attributes.

        Note that original PhotometricInterpretation will be retained; care should be taken by the caller to change this as appropriate, e.g., from YBR_FULL_422 if read as JPEG to RGB if written as uncompressed. See, for example, AttributeList.correctDecompressedImagePixelModule().

        Parameters:
        srcImg - the image
        list - the attribute list corresponding image
        shapes - a java.util.Vector of java.awt.Shape, specifed in image-relative coordinates
        burnInOverlays - whether or not to burn in overlays
        usePixelPaddingValue - whether or not to use any pixel paddding value
        useSpecifiedBlackoutValue - whether or not to use the specifiedBlackoutValue or the default based on signedness and bit depth (overrides usePixelPaddingValue)
        specifiedBlackoutValue - the value used to replace blacked out pixel values, only used if useSpecifiedBlackoutValue is true
        Throws:
        DicomException - if something bad happens handling the attribute list
      • getOffsetIntoMatrix

        public static final int getOffsetIntoMatrix​(int fixedOffset,
                                                    int row,
                                                    int column,
                                                    int height,
                                                    int width,
                                                    int rotation,
                                                    boolean horizontal_flip)
      • getOffsetIntoMatrix

        public static final int getOffsetIntoMatrix​(int offset,
                                                    int row,
                                                    int column,
                                                    int width)
      • rotateAndFlip

        public static void rotateAndFlip​(SourceImage srcImg,
                                         AttributeList list,
                                         int rotation,
                                         boolean horizontal_flip)
                                  throws DicomException

        Rotate an image in 90 degree increments, optionally followed by a horizontal flip.

        The accompanying attribute list will be updated with new Pixel Data and related Image Pixel Module attributes.

        Note that original PhotometricInterpretation will be retained; care should be taken by the caller to change this as appropriate, e.g., from YBR_FULL_422 if read as JPEG to RGB if written as uncompressed. See, for example, AttributeList.correctDecompressedImagePixelModule().

        Parameters:
        srcImg - the image
        list - the attribute list corresponding image
        rotation - multiple of 90 degrees
        horizontal_flip - whether or not to flip horizontally AFTER rotation
        Throws:
        DicomException - if something bad happens handling the attribute list