public class ImageEditUtilities
extends java.lang.Object
A class of utility methods for editing image pixel data.
Modifier and Type | Field and Description |
---|---|
protected static long |
useMultiplePixelDataTemporaryFilesIfPixelDataLengthGreaterThan |
protected static long |
usePixelDataTemporaryFilesIfPixelDataLengthGreaterThan |
Modifier and Type | Method and 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.
|
protected static long useMultiplePixelDataTemporaryFilesIfPixelDataLengthGreaterThan
protected static long usePixelDataTemporaryFilesIfPixelDataLengthGreaterThan
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()
.
srcImg
- the imagelist
- the attribute list corresponding imageshapes
- a java.util.Vector
of java.awt.Shape
, specifed in image-relative coordinatesDicomException
- if something bad happens handling the attribute listpublic 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()
.
srcImg
- the imagelist
- the attribute list corresponding imageshapes
- a java.util.Vector
of java.awt.Shape
, specifed in image-relative coordinatesburnInOverlays
- whether or not to burn in overlaysDicomException
- if something bad happens handling the attribute listpublic 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()
.
srcImg
- the imagelist
- the attribute list corresponding imageshapes
- a java.util.Vector
of java.awt.Shape
, specifed in image-relative coordinatesburnInOverlays
- whether or not to burn in overlaysusePixelPaddingValue
- whether or not to use any pixel paddding valueuseSpecifiedBlackoutValue
- 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 trueDicomException
- if something bad happens handling the attribute listpublic 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.
list
- the attribute list corresponding imageshapes
- a java.util.Vector
of java.awt.Shape
, specifed in image-relative coordinatesDicomException
- if something bad happens handling the attribute listjava.io.IOException
- if something bad happens reading or writing the filesjava.lang.Exception
- if something bad happens during processing of the JPEG blockspublic 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.
srcFile
- the DICOM file containing the JPEG compressed image to be blacked outdstFile
- the DICOM file containing the JPEG compressed image with the blocks intersecting the specified regions blacked outshapes
- a java.util.Vector
of java.awt.Shape
, specifed in image-relative coordinatesDicomException
- if something bad happens handling the attribute listjava.io.IOException
- if something bad happens reading or writing the filesjava.lang.Exception
- if something bad happens during processing of the JPEG blockspublic static final int getOffsetIntoMatrix(int offset, int row, int column, int width)
public static final int getOffsetIntoMatrix(int fixedOffset, int row, int column, int height, int width, int rotation, boolean horizontal_flip)
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()
.
srcImg
- the imagelist
- the attribute list corresponding imagerotation
- multiple of 90 degreeshorizontal_flip
- whether or not to flip horizontally AFTER rotationDicomException
- if something bad happens handling the attribute list