sirtopnm
Convert Sun rasterfile to portable anymap
TLDR
Convert a SIR image to a PNM file
SYNOPSIS
sirtopnm [-xsize width] [-ysize height] [-nsize depth] [-maxval value] [-info] [-endian {big|little}] [sirtfile]
PARAMETERS
sirtfile
The path to the input Siemens SIRT image file. If this argument is omitted, sirtopnm reads the image data from standard input.
-xsize width
Specifies the width of the image in pixels. This option is frequently mandatory as SIRT files often lack embedded dimension information.
-ysize height
Specifies the height of the image in pixels. Like -xsize, this is often a required parameter for correct image interpretation.
-nsize depth
Specifies the depth or number of slices for 3D image data. If this option is omitted, sirtopnm assumes a 2D image.
-maxval value
Sets the maximum pixel value for the output PNM image. This is crucial for proper scaling and display of the image intensities. If not specified, sirtopnm attempts to determine it or defaults to a common value (e.g., 255 or 65535).
-info
Prints information about the SIRT file, such as inferred or required dimensions, maximum value, and detected/assumed endianness, without performing the actual image conversion.
-endian {big|little}
Specifies the byte order (endianness) of the raw data within the SIRT file. Use 'big' for big-endian or 'little' for little-endian. If not specified, sirtopnm tries to guess the endianness or defaults to the system's native byte order.
DESCRIPTION
sirtopnm is a powerful utility within the Netpbm image manipulation toolkit. Its primary function is to convert raw image data files created using the Siemens Image Reconstruction Toolkit (SIRT) into the Netpbm Portable Anymap (PNM) format. SIRT files often store uncompressed 2D or 3D pixel data, commonly encountered in scientific and medical imaging applications such as MRI or CT scans.
Due to the raw nature of SIRT files, sirtopnm frequently requires users to explicitly specify critical image parameters like width (-xsize), height (-ysize), and optionally depth (-nsize for 3D data), as this metadata is often not embedded within the file itself. It also allows setting the maximum pixel value (-maxval) for proper scaling. The output PNM file can be a Portable Graymap (PGM) for grayscale images or a Portable Pixmap (PPM) if the source data implicitly supports color. This conversion capability is vital for integrating SIRT image data into a broader workflow, allowing it to be viewed, processed, and manipulated using the vast array of Netpbm tools and other graphics software that support the PNM standard. The command also provides options to handle byte order (endianness), which is crucial for correct interpretation of raw binary image streams.
CAVEATS
sirtopnm relies heavily on user-provided or correctly inferred metadata, especially dimensions and endianness. Incorrect -xsize, -ysize, -nsize, or -maxval settings will lead to garbled, distorted, or incorrectly scaled output images. Mismatched endianness is a common source of corruption, often resulting in a severely distorted or noisy image. Furthermore, sirtopnm is designed for raw pixel data; if the SIRT file contains proprietary headers or compressed data, it may not be able to correctly interpret the file.
STANDARD INPUT/OUTPUT
sirtopnm is designed to work seamlessly with Unix-like pipes. If no sirtfile is specified, it reads the raw image data from standard input. The resulting PNM image is always written to standard output. This behavior allows for chaining commands, for example: cat image.sirt | sirtopnm -x 256 -y 256 -maxval 4095 > output.pgm.
DATA TYPE ASSUMPTIONS
By default, sirtopnm generally assumes that the input raw data consists of 8-bit or 16-bit unsigned integer pixel values. If the SIRT file contains floating-point data, signed integers, or other complex data types, pre-processing or a different specialized tool might be required before or after using sirtopnm to ensure correct interpretation and display.
HISTORY
sirtopnm is a component of the comprehensive Netpbm project, a suite of image processing tools with roots tracing back to the early 1990s. Initially known as Pbmplus and developed by Jef Poskanzer, Netpbm has evolved to become a widely used and highly flexible toolkit for handling various image formats. Converters like sirtopnm were integrated into the Netpbm suite to meet the specific demands of scientific and medical imaging communities, providing a robust solution for converting raw data outputs from specialized equipment or software, such as the Siemens Image Reconstruction Toolkit, into a universally accessible format for further analysis and visualization.