public class SourceImage
extends java.lang.Object
A class that encapsulates the pixel data and features and values from an image source (such as a DICOM image), usually for the purpose of displaying it.
SingleImagePanel
Modifier and Type | Field and Description |
---|---|
protected static boolean |
allowDeferredReadFromFileIfNotMemoryMapped |
protected static boolean |
allowMemoryMapping |
protected static boolean |
allowMemoryMappingFromMultiplePerFrameFiles |
protected boolean |
applyICCProfileIfPresent |
protected com.pixelmed.display.SourceImage.BufferedImageSource |
bufferedImageSource |
protected java.nio.MappedByteBuffer[] |
memoryMappedByteBuffers |
protected java.nio.channels.FileChannel |
memoryMappedFileChannel |
protected java.nio.channels.FileChannel[] |
memoryMappedFileChannels |
protected java.io.FileInputStream |
memoryMappedFileInputStream |
protected java.io.FileInputStream[] |
memoryMappedFileInputStreams |
protected static int |
memoryMapperNumberOfRetries |
protected static int |
memoryMapperRetriesBeforeSleeping |
protected static int |
memoryMapperSleepTimeBetweenRetries |
Modifier | Constructor and Description |
---|---|
protected |
SourceImage()
Allow subclasses to have their own constructors.
|
|
SourceImage(AttributeList list)
Construct an image from a single or multi-frame DICOM image from
a list of DICOM attributes.
|
|
SourceImage(AttributeList list,
boolean applyICCProfileIfPresent)
Construct an image from a single or multi-frame DICOM image from
a list of DICOM attributes.
|
|
SourceImage(DicomInputStream i)
Construct an image from a single or multi-frame DICOM image from
an input stream (such as from a file or the network).
|
|
SourceImage(DicomInputStream i,
boolean applyICCProfileIfPresent)
Construct an image from a single or multi-frame DICOM image from
an input stream (such as from a file or the network).
|
|
SourceImage(java.io.InputStream i,
int w,
int h,
int depth)
Construct a single-frame image from an unsigned raw image (no header) on
an input stream with the specified width, height and bit depth.
|
|
SourceImage(java.io.InputStream i,
int w,
int h,
int depth,
int frames)
Construct a multi-frame image from an unsigned raw image (no header) on
an input stream with the specified width, height and bit depth.
|
|
SourceImage(java.lang.String filename)
Construct an image from a single or multi-frame DICOM image from
a file.
|
|
SourceImage(java.lang.String filename,
boolean applyICCProfileIfPresent)
Construct an image from a single or multi-frame DICOM image from
a file.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
clean(java.lang.Object object) |
void |
close() |
static java.awt.image.BufferedImage |
createBandInterleavedByteThreeComponentColorImage(int w,
int h,
byte[] data,
int offset,
java.awt.color.ColorSpace colorSpace) |
static java.awt.image.BufferedImage |
createBandInterleavedShortThreeComponentColorImage(int w,
int h,
short[] data,
int offset,
java.awt.color.ColorSpace colorSpace) |
static java.awt.image.BufferedImage |
createByteGrayscaleImage(int w,
int h,
byte[] data,
int offset) |
static java.awt.image.BufferedImage |
createDoubleGrayscaleImage(int w,
int h,
double[] data,
int offset) |
static java.awt.image.BufferedImage |
createFloatGrayscaleImage(int w,
int h,
float[] data,
int offset) |
static java.awt.image.BufferedImage |
createPixelInterleavedByteThreeComponentColorImage(int w,
int h,
byte[] data,
int offset,
java.awt.color.ColorSpace colorSpace,
boolean isChrominanceHorizontallyDownsampledBy2) |
static java.awt.image.BufferedImage |
createPixelInterleavedShortThreeComponentColorImage(int w,
int h,
short[] data,
int offset,
java.awt.color.ColorSpace colorSpace) |
static java.awt.image.BufferedImage |
createSignedShortGrayscaleImage(int w,
int h,
short[] data,
int offset) |
static java.awt.image.BufferedImage |
createUnsignedShortGrayscaleImage(int w,
int h,
short[] data,
int offset) |
protected void |
finalize() |
int |
getBackgroundValue() |
java.awt.image.BufferedImage |
getBufferedImage()
Make a BufferedImage for the first or only frame.
|
java.awt.image.BufferedImage |
getBufferedImage(boolean useICC)
Make a BufferedImage for the first or only frame.
|
java.awt.image.BufferedImage |
getBufferedImage(int i)
Make a BufferedImage for the selected frame.
|
java.awt.image.BufferedImage |
getBufferedImage(int i,
boolean useICC)
Make a BufferedImage for the selected frame.
|
protected java.nio.ByteBuffer[] |
getByteBuffersFromOtherAttributeOnDisk(OtherAttributeOnDisk oad,
int nframes)
Get memory mapped file buffers for the specified attribute.
|
protected java.nio.ByteBuffer[] |
getByteBuffersFromOtherByteAttributeMultipleFilesOnDisk(OtherByteAttributeMultipleFilesOnDisk oad,
int nframes)
Get memory mapped file buffers for the specified attribute.
|
java.awt.Dimension |
getDimension() |
DisplayShutter |
getDisplayShutter() |
int |
getHeight() |
int |
getMaskValue() |
double |
getMaximum() |
double |
getMinimum() |
ModalityTransform |
getModalityTransform() |
int |
getNumberOfBufferedImages() |
int |
getNumberOfFrames() |
Overlay |
getOverlay() |
int |
getPadRangeLimit() |
int |
getPadValue() |
int |
getPaletteColorBitsPerEntry() |
short[] |
getPaletteColorBlueTable() |
int |
getPaletteColorFirstValueMapped() |
short[] |
getPaletteColorGreenTable() |
int |
getPaletteColorLargestGray() |
int |
getPaletteColorNumberOfEntries() |
short[] |
getPaletteColorRedTable() |
RealWorldValueTransform |
getRealWorldValueTransform() |
protected java.nio.ShortBuffer[] |
getShortBuffersFromOtherWordAttributeOnDisk(OtherWordAttributeOnDisk oad,
int nframes)
Get a memory mapped file buffer for value of the specified attribute.
|
SUVTransform |
getSUVTransform() |
java.lang.String |
getTitle() |
VOITransform |
getVOITransform() |
int |
getWidth() |
boolean |
isGrayscale() |
boolean |
isImage() |
boolean |
isInverted() |
boolean |
isPadded() |
boolean |
isSigned() |
boolean |
isYBR() |
static void |
setAllowDeferredReadFromFileIfNotMemoryMapped(boolean allowDeferredReadFromFileIfNotMemoryMapped)
Static method to set whether or not to reading of per-frame data from a file to be deferred when subsequently
constructing SourceImage objects from attributes whose pixel data has been left on disk
rather than all frames to be read and constructed in memory.
|
static void |
setAllowMemoryMapping(boolean allowMemoryMapping)
Static method to set whether or not to allow memory mapping to be used at all when subsequently
constructing SourceImage objects from attributes whose pixel data has been left on disk
rather than read or constructed in memory.
|
static void |
setAllowMemoryMappingFromMultiplePerFrameFiles(boolean allowMemoryMappingFromMultiplePerFrameFiles)
Static method to set whether or not to allow memory mapping to be used in the special
case that the images on disk have their frames spread across separate files rather
than one large contiguous file.
|
void |
setClipRect(int i,
java.awt.Rectangle clipRect)
Set the rectanguler clipping region for the selected frame.
|
protected static boolean allowDeferredReadFromFileIfNotMemoryMapped
protected static boolean allowMemoryMapping
protected static boolean allowMemoryMappingFromMultiplePerFrameFiles
protected boolean applyICCProfileIfPresent
protected com.pixelmed.display.SourceImage.BufferedImageSource bufferedImageSource
protected java.nio.MappedByteBuffer[] memoryMappedByteBuffers
protected java.nio.channels.FileChannel memoryMappedFileChannel
protected java.nio.channels.FileChannel[] memoryMappedFileChannels
protected java.io.FileInputStream memoryMappedFileInputStream
protected java.io.FileInputStream[] memoryMappedFileInputStreams
protected static int memoryMapperNumberOfRetries
protected static int memoryMapperRetriesBeforeSleeping
protected static int memoryMapperSleepTimeBetweenRetries
protected SourceImage()
Allow subclasses to have their own constructors.
public SourceImage(AttributeList list) throws DicomException
Construct an image from a single or multi-frame DICOM image from a list of DICOM attributes.
If decompression was deferred during AttributeList read, take care not to remove the Transfer Syntax from the AttributeList until after deferred decompression.
Applies any ICC Profile that is present.
list
- the list of attributes that include the description and values of the pixel dataDicomException
public SourceImage(AttributeList list, boolean applyICCProfileIfPresent) throws DicomException
Construct an image from a single or multi-frame DICOM image from a list of DICOM attributes.
If decompression was deferred during AttributeList read, take care not to remove the Transfer Syntax from the AttributeList until after deferred decompression.
list
- the list of attributes that include the description and values of the pixel dataapplyICCProfileIfPresent
- whether or not to apply any ICC profile present in the attribute listDicomException
public SourceImage(DicomInputStream i) throws java.io.IOException, DicomException
Construct an image from a single or multi-frame DICOM image from an input stream (such as from a file or the network).
Applies any ICC Profile that is present.
i
- the input streamjava.io.IOException
DicomException
public SourceImage(DicomInputStream i, boolean applyICCProfileIfPresent) throws java.io.IOException, DicomException
Construct an image from a single or multi-frame DICOM image from an input stream (such as from a file or the network).
i
- the input streamapplyICCProfileIfPresent
- whether or not to apply any ICC profile present in the attribute listjava.io.IOException
DicomException
public SourceImage(java.io.InputStream i, int w, int h, int depth) throws java.io.IOException
Construct a single-frame image from an unsigned raw image (no header) on an input stream with the specified width, height and bit depth.
i
- the input streamw
- image widthh
- image heightdepth
- bit depthjava.io.IOException
public SourceImage(java.io.InputStream i, int w, int h, int depth, int frames) throws java.io.IOException
Construct a multi-frame image from an unsigned raw image (no header) on an input stream with the specified width, height and bit depth.
i
- the input streamw
- image widthh
- image heightdepth
- bit depthframes
- number of framesjava.io.IOException
public SourceImage(java.lang.String filename) throws java.io.IOException, DicomException
Construct an image from a single or multi-frame DICOM image from a file.
Applies any ICC Profile that is present.
filename
- java.io.IOException
DicomException
public SourceImage(java.lang.String filename, boolean applyICCProfileIfPresent) throws java.io.IOException, DicomException
Construct an image from a single or multi-frame DICOM image from a file.
filename
- applyICCProfileIfPresent
- whether or not to apply any ICC profile present in the attribute listjava.io.IOException
DicomException
protected static void clean(java.lang.Object object) throws java.lang.Exception
java.lang.Exception
public void close() throws java.lang.Throwable
java.lang.Throwable
public static java.awt.image.BufferedImage createBandInterleavedByteThreeComponentColorImage(int w, int h, byte[] data, int offset, java.awt.color.ColorSpace colorSpace)
w
- h
- data
- offset
- public static java.awt.image.BufferedImage createBandInterleavedShortThreeComponentColorImage(int w, int h, short[] data, int offset, java.awt.color.ColorSpace colorSpace)
w
- h
- data
- offset
- public static java.awt.image.BufferedImage createByteGrayscaleImage(int w, int h, byte[] data, int offset)
w
- h
- data
- offset
- public static java.awt.image.BufferedImage createDoubleGrayscaleImage(int w, int h, double[] data, int offset)
w
- h
- data
- offset
- public static java.awt.image.BufferedImage createFloatGrayscaleImage(int w, int h, float[] data, int offset)
w
- h
- data
- offset
- public static java.awt.image.BufferedImage createPixelInterleavedByteThreeComponentColorImage(int w, int h, byte[] data, int offset, java.awt.color.ColorSpace colorSpace, boolean isChrominanceHorizontallyDownsampledBy2)
w
- h
- data
- offset
- public static java.awt.image.BufferedImage createPixelInterleavedShortThreeComponentColorImage(int w, int h, short[] data, int offset, java.awt.color.ColorSpace colorSpace)
w
- h
- data
- offset
- public static java.awt.image.BufferedImage createSignedShortGrayscaleImage(int w, int h, short[] data, int offset)
w
- h
- data
- offset
- public static java.awt.image.BufferedImage createUnsignedShortGrayscaleImage(int w, int h, short[] data, int offset)
w
- h
- data
- offset
- protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public int getBackgroundValue()
public java.awt.image.BufferedImage getBufferedImage()
Make a BufferedImage for the first or only frame.
The BufferedImage will have the bit depth and photometric interpretation of the original SourceImage.
If it is an RGB photometric interpretation, and an ICC profile is present, it will be applied.
public java.awt.image.BufferedImage getBufferedImage(boolean useICC)
Make a BufferedImage for the first or only frame.
The BufferedImage will have the bit depth and photometric interpretation of the original SourceImage.
useICC
- if true, if image has an RGB photometric interpretation, and an ICC profile is present, it will be appliedpublic java.awt.image.BufferedImage getBufferedImage(int i)
Make a BufferedImage for the selected frame.
The BufferedImage will have the bit depth and photometric interpretation of the original SourceImage.
If it is an RGB photometric interpretation, and an ICC profile is present, it will be applied.
i
- frame number (from 0)public java.awt.image.BufferedImage getBufferedImage(int i, boolean useICC)
Make a BufferedImage for the selected frame.
The BufferedImage will have the bit depth and photometric interpretation of the original SourceImage.
i
- frame number (from 0)useICC
- if true, if image has an RGB photometric interpretation, and an ICC profile is present, it will be appliedprotected java.nio.ByteBuffer[] getByteBuffersFromOtherAttributeOnDisk(OtherAttributeOnDisk oad, int nframes) throws DicomException, java.io.IOException, java.lang.Throwable
Get memory mapped file buffers for the specified attribute.
oad
- the attribute on disk to memory mapDicomException
- if cannot memory map filejava.io.IOException
- of cannot open filejava.lang.Throwable
- if problem closing memory mapped fileprotected java.nio.ByteBuffer[] getByteBuffersFromOtherByteAttributeMultipleFilesOnDisk(OtherByteAttributeMultipleFilesOnDisk oad, int nframes) throws DicomException, java.io.IOException, java.lang.Throwable
Get memory mapped file buffers for the specified attribute.
oad
- the attribute on disk to memory mapDicomException
- if cannot memory map filejava.io.IOException
- of cannot open filejava.lang.Throwable
- if problem closing memory mapped filepublic java.awt.Dimension getDimension()
public DisplayShutter getDisplayShutter()
public int getHeight()
public int getMaskValue()
public double getMaximum()
public double getMinimum()
public ModalityTransform getModalityTransform()
public int getNumberOfBufferedImages()
public int getNumberOfFrames()
public Overlay getOverlay()
public int getPadRangeLimit()
public int getPadValue()
public int getPaletteColorBitsPerEntry()
public short[] getPaletteColorBlueTable()
public int getPaletteColorFirstValueMapped()
public short[] getPaletteColorGreenTable()
public int getPaletteColorLargestGray()
public int getPaletteColorNumberOfEntries()
public short[] getPaletteColorRedTable()
public RealWorldValueTransform getRealWorldValueTransform()
protected java.nio.ShortBuffer[] getShortBuffersFromOtherWordAttributeOnDisk(OtherWordAttributeOnDisk oad, int nframes) throws DicomException, java.io.IOException, java.lang.Throwable
Get a memory mapped file buffer for value of the specified attribute.
oad
- the attribute on disk to memory mapnframes
- the number of framesDicomException
- if cannot memory map filejava.io.IOException
- of cannot open filejava.lang.Throwable
- if problem closing memory mapped filepublic SUVTransform getSUVTransform()
public java.lang.String getTitle()
public VOITransform getVOITransform()
public int getWidth()
public boolean isGrayscale()
public boolean isImage()
public boolean isInverted()
public boolean isPadded()
public boolean isSigned()
public boolean isYBR()
public static void setAllowDeferredReadFromFileIfNotMemoryMapped(boolean allowDeferredReadFromFileIfNotMemoryMapped)
Static method to set whether or not to reading of per-frame data from a file to be deferred when subsequently constructing SourceImage objects from attributes whose pixel data has been left on disk rather than all frames to be read and constructed in memory.
Does not apply if memory mapping is enabled and succeeds.
Default is to to allow deferred reading.
Reading of the pixel data for a frame (and allocation of memory for it) is deferred until SourceImage.getBufferedImage(int)
is called.
allowDeferredReadFromFileIfNotMemoryMapped
- true or false to allow or disallow deferred read of per-frame data from file, respectivelypublic static void setAllowMemoryMapping(boolean allowMemoryMapping)
Static method to set whether or not to allow memory mapping to be used at all when subsequently constructing SourceImage objects from attributes whose pixel data has been left on disk rather than read or constructed in memory.
Default is to allow memory mapping.
Performance will generally be suprior with memory mapping turned on, and less heap will be used, but apparent issues with native memory allocation and revovery after a failed mapping on some platforms may require disabling it.
allowMemoryMapping
- true or false to allow or disallow memory mapping, respectivelypublic static void setAllowMemoryMappingFromMultiplePerFrameFiles(boolean allowMemoryMappingFromMultiplePerFrameFiles)
Static method to set whether or not to allow memory mapping to be used in the special case that the images on disk have their frames spread across separate files rather than one large contiguous file.
Default is to to disable memory mapping in this case.
allowMemoryMappingFromMultiplePerFrameFiles
- true or false to allow or disallow memory mapping of per-frame files, respectivelypublic void setClipRect(int i, java.awt.Rectangle clipRect)
Set the rectanguler clipping region for the selected frame.
i
- frame number (from 0)