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 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(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(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.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
clean(java.lang.Object object) |
void |
close() |
protected void |
finalize() |
int |
getBackgroundValue() |
java.awt.image.BufferedImage |
getBufferedImage()
Make a BufferedImage for the first or only frame.
|
java.awt.image.BufferedImage |
getBufferedImage(int i)
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 |
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.
|
protected static boolean allowMemoryMapping
protected static boolean allowMemoryMappingFromMultiplePerFrameFiles
protected static boolean allowDeferredReadFromFileIfNotMemoryMapped
protected com.pixelmed.display.SourceImage.BufferedImageSource bufferedImageSource
protected java.io.FileInputStream memoryMappedFileInputStream
protected java.nio.channels.FileChannel memoryMappedFileChannel
protected java.io.FileInputStream[] memoryMappedFileInputStreams
protected java.nio.channels.FileChannel[] memoryMappedFileChannels
protected java.nio.MappedByteBuffer[] memoryMappedByteBuffers
protected static int memoryMapperNumberOfRetries
protected static int memoryMapperSleepTimeBetweenRetries
protected static int memoryMapperRetriesBeforeSleeping
protected SourceImage()
Allow subclasses to have their own constructors.
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.
filename
- java.io.IOException
DicomException
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).
i
- the input streamjava.io.IOException
DicomException
public SourceImage(AttributeList list) throws DicomException
Construct an image from a single or multi-frame DICOM image from a list of DICOM attributes.
list
- the list of attributes that include the description and values of the pixel dataDicomException
public 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 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, respectivelyprotected static void clean(java.lang.Object object) throws java.lang.Exception
java.lang.Exception
public void close() throws java.lang.Throwable
java.lang.Throwable
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
protected 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 fileprotected 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.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 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(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 int getNumberOfBufferedImages()
public int getWidth()
public int getHeight()
public java.awt.Dimension getDimension()
public double getMinimum()
public double getMaximum()
public int getMaskValue()
public boolean isSigned()
public boolean isInverted()
public boolean isPadded()
public int getPadValue()
public int getPadRangeLimit()
public int getBackgroundValue()
public boolean isGrayscale()
public boolean isYBR()
public java.lang.String getTitle()
public int getNumberOfFrames()
public int getPaletteColorLargestGray()
public int getPaletteColorFirstValueMapped()
public int getPaletteColorNumberOfEntries()
public int getPaletteColorBitsPerEntry()
public short[] getPaletteColorRedTable()
public short[] getPaletteColorGreenTable()
public short[] getPaletteColorBlueTable()
public SUVTransform getSUVTransform()
public RealWorldValueTransform getRealWorldValueTransform()
public ModalityTransform getModalityTransform()
public VOITransform getVOITransform()
public DisplayShutter getDisplayShutter()
public Overlay getOverlay()