| 1 |
/* Image Pixel Module Interface */ |
| 2 |
|
| 3 |
package DICOM.Module; |
| 4 |
import DICOM.Misc.PaletteColor; |
| 5 |
|
| 6 |
public class ImagePixelModule { |
| 7 |
public native void getPixelsByte(long dcmObj, byte pixels[], int rows, |
| 8 |
int cols, int samplesPerPixel); |
| 9 |
public native void getPixelsShort(long dcmObj, short pixels[], int rows, |
| 10 |
int cols, int samplesPerPixel); |
| 11 |
public native void remapPixelsByte(long dcmObj, byte pixelsIn[], int rows, |
| 12 |
int cols, int samplesPerPixel, |
| 13 |
int pixelsOut[]); |
| 14 |
public native void getPixelFrameByte(long dcmObj, byte pixels[], |
| 15 |
int rows, int cols, int samplesPerPixel, int frame); |
| 16 |
public native void getPixelFrameShort(long dcmObj, short pixels[], |
| 17 |
int rows, int cols, int samplesPerPixel, int frame); |
| 18 |
public native void getPixelFrameAsColor(long dcmObj, int pixels[], |
| 19 |
int rows, int cols, int frame); |
| 20 |
public native void getPixelFrameAsIndexed(long dcmObj, byte pixels[], |
| 21 |
int rows, int cols, int frame); |
| 22 |
public native void fillPaletteDescriptor(long dcmObj, String color, |
| 23 |
DICOM.Misc.PaletteColor palette); |
| 24 |
public native void fillPaletteMap(long dcmObj, String color, int entries, |
| 25 |
int bitsPerPixel, short pixels[]); |
| 26 |
|
| 27 |
private int SamplesPerPixel; |
| 28 |
private String PhotometricInterpretation; |
| 29 |
private int Rows; |
| 30 |
private int Columns; |
| 31 |
private int BitsAllocated; |
| 32 |
private int BitsStored; |
| 33 |
private int HighBit; |
| 34 |
private int PixelRepresentation; |
| 35 |
private float WindowCenter; |
| 36 |
private float WindowWidth; |
| 37 |
private float RescaleSlope; |
| 38 |
private float RescaleIntercept; |
| 39 |
|
| 40 |
// Really is defined in another module, but we will define it here for now |
| 41 |
private int FrameCount; |
| 42 |
private long DCMObject; // To allow access to pixel data |
| 43 |
|
| 44 |
public ImagePixelModule() { |
| 45 |
|
| 46 |
} |
| 47 |
|
| 48 |
public int getSamplesPerPixel() { |
| 49 |
return SamplesPerPixel; |
| 50 |
} |
| 51 |
public String getPhotometricInterpretation() { |
| 52 |
return PhotometricInterpretation; |
| 53 |
} |
| 54 |
public int getRows() { |
| 55 |
return Rows; |
| 56 |
} |
| 57 |
public int getColumns() { |
| 58 |
return Columns; |
| 59 |
} |
| 60 |
public int getBitsAllocated() { |
| 61 |
return BitsAllocated; |
| 62 |
} |
| 63 |
public int getBitsStored() { |
| 64 |
return BitsStored; |
| 65 |
} |
| 66 |
public int getHighBit() { |
| 67 |
return HighBit; |
| 68 |
} |
| 69 |
public int getPixelRepresentation() { |
| 70 |
return PixelRepresentation; |
| 71 |
} |
| 72 |
public float getWindowCenter() { |
| 73 |
return WindowCenter; |
| 74 |
} |
| 75 |
public float getWindowWidth() { |
| 76 |
return WindowWidth; |
| 77 |
} |
| 78 |
public float getRescaleSlope() { |
| 79 |
return RescaleSlope; |
| 80 |
} |
| 81 |
public float getRescaleIntercept() { |
| 82 |
return RescaleIntercept; |
| 83 |
} |
| 84 |
public void getPixels(byte pixels[], int rows, int cols) { |
| 85 |
getPixelsByte(DCMObject, pixels, rows, cols, SamplesPerPixel); |
| 86 |
} |
| 87 |
public void getPixels(short pixels[], int rows, int cols) { |
| 88 |
getPixelsShort(DCMObject, pixels, rows, cols, SamplesPerPixel); |
| 89 |
} |
| 90 |
public int getFrameCount() { |
| 91 |
return FrameCount; |
| 92 |
} |
| 93 |
public void getPixelFrame(byte pixels[], int rows, int cols, int frame) { |
| 94 |
getPixelFrameByte(DCMObject, pixels, rows, cols, SamplesPerPixel, frame); |
| 95 |
} |
| 96 |
public void getPixelFrame(short pixels[], int rows, int cols, int frame) { |
| 97 |
getPixelFrameShort(DCMObject, pixels, rows, cols, SamplesPerPixel, frame); |
| 98 |
} |
| 99 |
public void getFrameAsColor(int pixels[], int rows, int cols, int frame) { |
| 100 |
getPixelFrameAsColor(DCMObject, pixels, rows, cols, frame); |
| 101 |
} |
| 102 |
public void getFrameAsIndexed(byte pixels[], int rows, int cols, int frame) { |
| 103 |
getPixelFrameAsIndexed(DCMObject, pixels, rows, cols, frame); |
| 104 |
} |
| 105 |
public int[] ColorFrame(int rows, int cols, int index) { |
| 106 |
int frame[] = new int[rows * cols]; |
| 107 |
getPixelFrameAsColor(DCMObject, frame, rows, cols, index); |
| 108 |
return frame; |
| 109 |
} |
| 110 |
|
| 111 |
public DICOM.Misc.PaletteColor getPalette(String color) { |
| 112 |
DICOM.Misc.PaletteColor palette = new DICOM.Misc.PaletteColor(); |
| 113 |
|
| 114 |
fillPaletteDescriptor(DCMObject, color, palette); |
| 115 |
palette.Map = new short[palette.Entries]; |
| 116 |
fillPaletteMap(DCMObject, color, palette.Entries, palette.BitsPerPixel, |
| 117 |
palette.Map); |
| 118 |
|
| 119 |
return palette; |
| 120 |
} |
| 121 |
public void remapPixels(byte pixelsIn[], int rows, int cols, int pixelsOut[]){ |
| 122 |
remapPixelsByte(DCMObject, pixelsIn, rows, cols, SamplesPerPixel, pixelsOut); |
| 123 |
} |
| 124 |
|
| 125 |
public void dumpState() { |
| 126 |
System.out.println(" Samples Per Pixel: " + SamplesPerPixel); |
| 127 |
System.out.println(" Photometric Interp: " + PhotometricInterpretation); |
| 128 |
System.out.println(" Rows: " + Rows); |
| 129 |
System.out.println(" Columns: " + Columns); |
| 130 |
System.out.println(" Bits Allocated: " + BitsAllocated); |
| 131 |
System.out.println(" Bits Stored: " + BitsStored); |
| 132 |
System.out.println(" High Bit: " + HighBit); |
| 133 |
System.out.println("Pixel Representation: " + PixelRepresentation); |
| 134 |
System.out.println(" Window Center: " + WindowCenter); |
| 135 |
System.out.println(" Window Width: " + WindowWidth); |
| 136 |
System.out.println(" Rescale Slope: " + RescaleSlope); |
| 137 |
System.out.println(" Rescale Intercept: " + RescaleIntercept); |
| 138 |
System.out.println(" Frame Count: " + FrameCount); |
| 139 |
} |
| 140 |
} |