Skip to content

Instantly share code, notes, and snippets.

@yoya
Last active August 30, 2018 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoya/9a320b24d9370913786a9e1e2f0d1ec1 to your computer and use it in GitHub Desktop.
Save yoya/9a320b24d9370913786a9e1e2f0d1ec1 to your computer and use it in GitHub Desktop.
area of kernel filter
% # Nearest Neighbor
% convert xc: -define filter:verbose=1 -filter box -resize 8 null: | awk '$1==0{s+=$2} $1>0{s+=$2*2} END {print s/100}'
1.01
% # Bi-Linear
% convert xc: -define filter:verbose=1 -filter triangle -resize 8 null: | awk '$1==0{s+=$2} $1>0{s+=$2*2} END {print s/100}'
1
% # Mitchell-Netravali (Bi-Cubic B:1/3, C:1/3)
% convert xc: -define filter:verbose=1 -filter mitchell -resize 8 null: | awk '$1==0{s+=$2/2} $1>0{s+=$2*2} END {print s/100}'
1
% # Lanczos (Lobes:3)
% convert xc: -define filter:verbose=1 -filter lanczos -resize 8 null: | awk '$1==0{s+=$2/2} $1>0{s+=$2*2} END {print s/100}'
0.997055
% # CatmullRom (Bi-Cubic B:0, C:0.5)
% convert xc: -define filter:verbose=1 -filter mitchell -define filter:b=0 -define filter:c=0.5 -resize 8 null: | awk '$1==0{s+=$2/2} $1>0{s+=$2*2} END {print s/100}'
0.995
% # Lanczos (Lobes:1, 2, 3, 4, 100)
% for lobes in 1 2 3 4 100 ;
do echo lobes:$lobes
convert xc: -define filter:verbose=1 -filter lanczos -define filter:lobes=$lobes -resize 8 null: | awk '$1==0{s+=$2} $1>0{s+=$2*2} END {print s/100}' ;
done
lobes:1
0.902823
lobes:2
1.00979
lobes:3
0.997055
lobes:4
1.00126
lobes:100
1
% # Bi-Cubic (B:{0, 0.333, 0.5, 1}, C:0)
% for b in 0 0.333 0.5 1 ;
do echo b:$b ;
convert xc: -define filter:verbose=1 -filter mitchell -define filter:b=$b -define filter:c=0 -resize 8 null: | awk '$1==0{s+=$2/2} $1>0{s+=$2*2} END {print s/100}' ;
done
b:0
0.995
b:0.333
0.995555
b:0.5
0.995833
b:1
0.996667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment