ij.plugin
Class PGM_Reader
java.lang.Object
ij.ImagePlus
ij.plugin.PGM_Reader
- All Implemented Interfaces:
- Measurements, PlugIn, java.awt.image.ImageObserver
public class PGM_Reader
- extends ImagePlus
- implements PlugIn
This plug-in opens PGM (portable graymap) format images.
The portable graymap format is a lowest common denominator
grayscale file format. The definition is as follows:
- A "magic number" for identifying the file type. A pgm
file's magic number is the two characters "P2".
- Whitespace (blanks, TABs, CRs, LFs).
- A width, formatted as ASCII characters in decimal.
- Whitespace.
- A height, again in ASCII decimal.
- Whitespace.
- The maximum gray value, again in ASCII decimal.
- Whitespace.
- Width * height gray values, each in ASCII decimal, between
0 and the specified maximum value, separated by whi-
tespace, starting at the top-left corner of the graymap,
proceeding in normal English reading order. A value of 0
means black, and the maximum value means white.
- Characters from a "#" to the next end-of-line are ignored
(comments).
- No line should be longer than 70 characters.
Here is an example of a small graymap in this format:
P2
# feep.pgm
24 7
15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0
0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0
0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
There is a PGM variant that stores the pixel data as raw bytes:
-The "magic number" is "P5" instead of "P2".
-The gray values are stored as plain bytes, instead of ASCII decimal.
-No whitespace is allowed in the grays section, and only a single
character of whitespace (typically a newline) is allowed after the maxval.
-The files are smaller and many times faster to read and write.
Fields inherited from class ij.ImagePlus |
changes, COLOR_256, COLOR_RGB, GRAY16, GRAY32, GRAY8, img, ip, locked, pixelDepth, pixelHeight, pixelWidth, sCalibrated, unit, units, win |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Fields inherited from interface ij.measure.Measurements |
AREA, CENTER_OF_MASS, CENTROID, LABELS, LIMIT, MAX_STANDARDS, MEAN, MIN_MAX, MODE, PERIMETER, RECT, STD_DEV |
Method Summary |
void |
openAsciiImage(java.io.StreamTokenizer tok,
int size,
byte[] pixels)
|
ImageProcessor |
openFile(java.lang.String path)
|
void |
openHeader(java.io.StreamTokenizer tok)
|
void |
openRawImage(java.io.InputStream is,
int size,
byte[] pixels)
|
void |
run(java.lang.String arg)
This method is called when the plug-in is loaded. |
Methods inherited from class ij.ImagePlus |
copyScale, createEmptyStack, createImagePlus, createLut, createNewRoi, draw, draw, flush, getCalibration, getCurrentSlice, getFileInfo, getHeight, getID, getImage, getMask, getOriginalFileInfo, getPixel, getProcessor, getProperties, getProperty, getRoi, getStack, getStackSize, getStartTime, getStatistics, getStatistics, getStatistics, getTitle, getType, getWidth, getWindow, hide, imageUpdate, isInvertedLut, isProcessor, killProcessor, killRoi, killStack, lock, lockSilently, mouseMoved, repaintWindow, setCalibration, setColor, setFileInfo, setGlobalCalibration, setImage, setProcessor, setProperty, setRoi, setRoi, setRoi, setSlice, setStack, setTitle, setType, setWindow, show, show, startTiming, trimProcessor, unlock, updateAndDraw, updateAndRepaintWindow, updateImage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PGM_Reader
public PGM_Reader()
run
public void run(java.lang.String arg)
- Description copied from interface:
PlugIn
- This method is called when the plug-in is loaded.
'arg', which may be blank, is the argument specified
for this plug-in in IJ_Props.txt.
- Specified by:
run
in interface PlugIn
openFile
public ImageProcessor openFile(java.lang.String path)
throws java.io.IOException
- Throws:
java.io.IOException
openHeader
public void openHeader(java.io.StreamTokenizer tok)
throws java.io.IOException
- Throws:
java.io.IOException
openAsciiImage
public void openAsciiImage(java.io.StreamTokenizer tok,
int size,
byte[] pixels)
throws java.io.IOException
- Throws:
java.io.IOException
openRawImage
public void openRawImage(java.io.InputStream is,
int size,
byte[] pixels)
throws java.io.IOException
- Throws:
java.io.IOException