#!/bin/sh # # pnmIVed - emulate IrfanView's Edge Detection # by uratan! 2023.11.16 # if [ $# -ne 1 ]; then echo "usage: pnmIVed gain(0,1,..,5)" 1>&2 exit 1; fi PP="$1" TMP_PNM="$$_in" # # once feed stdin to a file # cat > $TMP_PNM # # take top edge out, then take difference: direction top to bottom # pnmcut -bottom 0 $TMP_PNM > $$edge pnmcat -tb $$edge $TMP_PNM > $$tmp0 # dup top-edge pnmcat -tb $TMP_PNM $$edge > $$tmp1 # (dummy, will be cut below) pnmarith -diff $$tmp0 $$tmp1 | pnmcut -bottom -2 | ppmtoppm -plain > $$dV # # take right edge out, then take difference: direction right to left # pnmcut -left -1 $TMP_PNM > $$edge pnmcat -lr $$edge $TMP_PNM > $$tmp0 # (dummy, will be cut below) pnmcat -lr $TMP_PNM $$edge > $$tmp1 # dup right-edge pnmarith -diff $$tmp0 $$tmp1 | pnmcut -left 1 | ppmtoppm -plain > $$dH # # sum-up 2 diffs and tune gains, output for stdout # vvvvvvvv back for PPM-binary awk -f v-ppmRMS.awk -v p=$PP $$dH $$dV | ppmtoppm #./netpbm-10.73.29/other/pamarith -gain $PP -rms $$dH $$dV #./netpbm-10.73.29/other/pamRMS -gain $PP $$dH $$dV # /home/uratan/bin/pamRMS -gain $PP $$dH $$dV # awk: 28.9sec -> pamRMS: 1.7sec rm $$edge $$tmp0 $$tmp1 $$dV $$dH rm $TMP_PNM