# # how to emulate Irfanview's Color balance correction # ### prepare source image ################################################ SRC="test.ppm" #ppmmake rgb:80/80/80 200 100 > $SRC # plain ppmwheel 256 > $SRC # color wheel ### method1: by pnmarith ################################################ W=`pnmfile $SRC | awk '{print $4}'` # get width H=`pnmfile $SRC | awk '{print $6}'` # get height ppmmake rgb:00/28/00 $W $H > to_add # G+=40 ppmmake rgb:14/00/3c $W $H > to_sub # R-=20, B-=60 pnmarith -add $SRC to_add > temp # do add pnmarith -sub temp to_sub > result1.ppm # do sub rm to_add to_sub temp # clean up ### method2: by pamfunc ################################################# cat $SRC | ppmtorgb3 # divide to 3 pgm pamfunc -sub 20 noname.red > temp.red # R-=20 pamfunc -add 40 noname.grn > temp.grn # G+=40 pamfunc -add -60 noname.blu > temp.blu # B-=60 rgb3toppm temp.red temp.grn temp.blu > result2.ppm # bind back to ppm rm noname.red noname.grn noname.blu # clean up rm temp.red temp.grn temp.blu # clean up #########################################################################