czwartek, 19 czerwca 2008

Najprostsze pliki graficzne

Trzy formaty plików graficznych: PPM, PGM i PBM (portable pixmap, portable graymap, portable bitmap) wspólnie określane popularnie jako "portable anymap" stanowią w zamyśle autorów "wspólny mianownik" formatów graficznych, format prosty i oczywisty, pozwalający na wymianę danych graficznych pomiędzy systemami i programami. Format zdefiniowany w latach 80-tych i używany do dziś.

Wszystkie trzy oparte są na wspólnej zasadzie: plik zawiera nagłówek z koniecznymi danymi (rozmar, typ) i prostokątną macierz pixeli. Pixel określa kolor w postaci składowych RGB (dla pixmap PPM), stopień szarości (dla greymap) lub jednobitową wartość biało-czarną (dla bitmap). Format zdefiniowano w wariancie binarnym i tekstowym. W przyrodzie występują z rozszerzeniem .ppm, .pbm i .pgm, ale także .pnm (Portable aNyMap).

Dalszym rozwinięciem tego formatu jest PAM, występujący tylko w formie binarnej, pozwalający na dalsze rozszerzenia, kanał alfa itp.

W Twoim Unixie znajdziesz mnóstwo programów - narzędzi zawierających w nazwie ciąg znaków ppm, pnm, pgm itp. Oto rezultat komendy "apropos pnm" na komputerze, na którym piszę ten artykuł (pierwszy fragment) :

anytopnm (1)         - attempt to convert an unknown type of image file to a portable anymap
bmptopnm (1)         - convert a BMP file into a portable anymap
calibrate_ppa (8)    - pnm2ppa calibration tool
fiascotopnm (1)      - Convert compressed FIASCO image to PGM, or PPM
fitstopnm (1)        - convert a FITS file into a portable anymap
gemtopnm (1)         - convert a GEM .img file into a portable anymap
giftopnm (1)         - convert a GIF file into a portable anymap
jpegtopnm (1)        - convert JPEG/JFIF file to portable pixmap or graymap
palmtopnm (1)        - convert a Palm pixmap into a portable anymap
pamdeinterlace (1)   - remove ever other row from a PAM/PNM image
pamfile (1)          - describe a Netpbm (PAM or PNM) file
pamstretch (1)       - scale up a PNM or PAM image by interpolating
between pixels
pamstretch-gen (1) - use pamstretch and pnmscale to scale by non-integer values pngtopnm (1) - convert a Portable Network Graphics file into portable anymap pnm2ppa (1) - convert portable anymap (PNM) images to HP's
PPA printer format. pnmalias (1) - antialias a portable anyumap. pnmarith (1) - perform arithmetic on two portable anymaps pnmcat (1) - concatenate portable anymaps pnmcolormap (1) - create quantization color map for a portable anymap pnmcomp (1) - composite (overlay) two portable anymap files together pnmconvol (1) - general MxN convolution on a portable anymap pnmcrop (1) - crop a portable anymap pnmcut (1) - cut a rectangle out of a portable anymap pnmdepth (1) - change the maxval in a portable anymap pnmenlarge (1) - read a portable anymap and enlarge it N times pnmfile (1) - describe a portable anymap pnmflip (1) - perform one or more flip operations on a portable anymap pnmgamma (1) - perform gamma correction on a portable anymap pnmhisteq (1) - histogram equalise a portable anymap pnmhistmap (1) - draw a histogram for a PGM or PPM file pnmindex (1) - build a visual index of a bunch of anymaps pnminterp (1) - scale up a PNM or PAM image by interpolating between pixels pnminterp-gen (1) - use pamstretch and pnmscale to scale by non-integer values pnminvert (1) - invert a portable anymap pnmmargin (1) - add a border to a portable anymap pnmmontage (1) - create a montage of portable anymaps pnmnlfilt (1) - non-linear filters: smooth, alpha trim mean, optimal estimation smoothing, edge enhancement.
.......

Biorąc pod uwagę, że każdy taki plik można zamienić na postać tekstową, którą łatwo przetwarzać przy użyciu narzędzi typu awk/perl/bash/sed, mamy w ręce pełną bibliotekę graficzną ...

Brak komentarzy: