Create an Abel-Deconvolved Cross-Section with pgmabel
You will finish with a PGM image containing a calculated cross-section from a rotationally symmetric source image. pgmabel uses Abel integration for deconvolution, so the input needs a vertical symmetry axis and must represent a transparent object viewed through that axis. This guide uses Netpbm 2:11.05.02-1.1build1, whose installed pgmabel reports itself as version 1.009.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about fifteen minutes for a first run. You need Netpbm's image tools, a readable PGM file, and enough image knowledge to identify the symmetry axis. The examples write to a new file in the current directory. They do not need sudo.
1. Check the installed command
Confirm that the executable and package are the ones you expect. This is a read-only check:
$ command -v pgmabel
/usr/bin/pgmabel
$ dpkg-query -W -f='${Package} ${Version}\n' netpbm
netpbm 2:11.05.02-1.1build1
$ pgmabel -help
pgmabel: Use 'man pgmabel' for help.
The last message is normal for this build. The full option list is in the manual, and the program accepts unique abbreviations. Use full option names in scripts so a later option addition cannot make an abbreviation ambiguous.
2. Prepare a vertical-axis PGM
pgmabel reads one PGM image from the named file, or from standard input when no file name is supplied. The image must be arranged so its axis of symmetry is vertical. If your source is rotated, use another Netpbm tool first and inspect the result before invoking pgmabel.
For a harmless local smoke test, this command converts an installed sample PPM to PGM and sends it through pgmabel. It demonstrates the data path, not the quality of a real deconvolution:
$ ppmtopgm /usr/share/netpbm/pcxstd.ppm | pgmabel > cross-section.pgm
$ printf 'exit status: %s\n' "$?"
exit status: 0
$ file cross-section.pgm
cross-section.pgm: Netpbm image data, size = 16 x 1, rawbits, greymap
Checkpoint: the output should be non-empty and identified as a greymap. Keep the input unchanged. If the source is valuable, choose a new destination rather than redirecting over an existing PGM.
3. Set the axis explicitly
By default, pgmabel places the symmetry axis at the image centre. That is convenient only when the source is centred. The -axis value is a pixel position measured from the left edge, so establish the coordinate from the image dimensions and your inspection of the source.
$ ppmtopgm /path/to/source.ppm | pgmabel -axis 140 > cross-section-axis-140.pgm
$ file cross-section-axis-140.pgm
cross-section-axis-140.pgm: Netpbm image data, size = ...
The ellipsis above is a placeholder for your local file output, not text to paste. If the axis is wrong, the calculation can still complete while producing a misleading cross-section. A successful exit status proves that the command ran, not that the physical alignment is correct.
4. Control scale and output weighting
pgmabel applies a user factor to the calculated values. The default -factor is 1.0. A value below 1 reduces the resulting grey values; a value above 1 increases the enhancement. The default -pixsize is 0.1, the pixel size used for scale-invariant weighting.
$ pgmabel -axis 140 -factor 0.75 -pixsize 0.10 /path/to/source.pgm \
> cross-section-scaled.pgm
$ file cross-section-scaled.pgm
These options describe the calculation, not a generic brightness adjustment. Record the factor and pixel size with your result if the image will be compared with another run. Keep values unquoted unless your shell command needs quoting; they are ordinary numeric arguments.
5. Calculate one side when the input requires it
Use -left or -right when you want pgmabel to calculate only one side of the image. They are alternatives, not cumulative switches:
$ pgmabel -left /path/to/source.pgm > cross-section-left.pgm
$ pgmabel -right /path/to/source.pgm > cross-section-right.pgm
Do not specify both. If the object is not symmetric enough for the two sides to agree, save both results and compare them rather than silently choosing the one that looks better. Where the integration produces a negative result, pgmabel writes black for that result.
6. Inspect the calculation without changing the image
Add -verbose when you need the weighting information. Diagnostics are written separately from the PGM data, so keep standard output redirected to the image and capture standard error if you want a record:
$ pgmabel -verbose /path/to/source.pgm \
> cross-section.pgm 2> cross-section.log
$ sed -n '1,12p' cross-section.log
pgmabel: $VER: pgmabel 1.009 (24 Jan 2002)
pgmabel: Calculating a portable graymap with ...
pgmabel: resuming a pixelsize of ...
pgmabel: axis = ..., stretching factor = ...
Exact dimensions, axis values and weighting lines depend on the input and options. Do not parse the displayed wording as a stable machine interface. If you need a scriptable success check, use the process exit status and then inspect the output with file or another image-aware tool.
7. Handle failure and protect previous results
A missing or malformed PGM commonly produces an error about the Netpbm magic number. Check the input before rerunning:
$ test -r /path/to/source.pgm && echo readable
readable
$ file /path/to/source.pgm
Shell redirection truncates its destination before pgmabel starts. For a replacement, write to a temporary name in the same directory, verify it, then move it into place:
$ pgmabel /path/to/source.pgm > cross-section.pgm.new
$ file cross-section.pgm.new
$ mv cross-section.pgm.new cross-section.pgm
The final mv replaces the old output, so run it only after checking the new file. If the calculation fails, leave the old output alone and investigate the input, axis or dimensions. The computation is also unstable against periodic structures with a size of two pixels in the vertical direction, so treat results from that kind of input with suspicion.
Done means
- The installed Netpbm package and pgmabel version were checked.
- The source is a readable PGM with a justified vertical symmetry axis.
- The output is a non-empty PGM, and the chosen factor and pixel size are recorded when non-default.
- Any one-sided calculation uses exactly one of
-leftand-right. - Verbose diagnostics were kept separate from image data.
- A failed replacement cannot overwrite the previous cross-section.