Say you want to compare two PBM (black and white) images
visually. Each consists of black foreground pixels on a
white background. You want to create an image that contains
background where both images contain background and
foreground where both images contain foreground. But where
Image 1 has a foreground pixel and Image 2 does not, you
want red in the output; where Image 2 has a foreground pixel
and Image 1 does not, you want green.
First, we create a single image that contains the
information from both input PBMs:
pamstack image1.pbm image2.pbm >bothimages.pam
Note that this image has 1 of 4 possible tuple values at
each location: (0,0), (0,1), (1,0), or (1,1).
Now, we create a lookup table that we can index with
those 4 values:
ppmmake white 1 1 >white.ppm
ppmmake black 1 1 >black.ppm
ppmmake red 1 1 >red.ppm
ppmmake green 1 1 >green.ppm
pnmcat -leftright black.ppm red.ppm >blackred.ppm
pnmcat -leftright green.ppm white.ppm >greenwhite.ppm
pnmcat -topbottom blackred.ppm greenwhite.ppm >lookup.ppm
Finally, we look up the indices from our index in our
lookup table and produce the output:
pamlookup bothimages.ppm -lookupfile=lookup.ppm >imagediff.ppm
|