Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scale_dcci2x_new : -check "${1=1.15}>=0 && ${2=5}>=0" -skip ${3=0}
- -e[^-1] "Double xy-dimensions of image$?, using DCCI2x algorithm."
- -v - -repeat $! -l[$>]
- -r {2*w-(!$3)},{2*h-(!$3)},1,100%,4
- # Estimate diagonal values.
- -f "init(
- const threshold = $1;
- const exponent = $2;
- interpolation = 0;
- boundary = 1;
- drp() = -j(-3,-3) + 9*j(-1,-1) + 9*j(1,1) - j(3,3);
- urp() = -j(3,-3) + 9*j(1,-1) + 9*j(-1,1) - j(-3,3);
- );
- if (x%2==0 || y%2==0,i,
- d1 = sum(abs([
- j(-1,-3) - j(-3,-1), j(1,-3) - j(-1,-1), j(3,-3) - j(1,-1),
- j(-1,-1) - j(-3,1), j(1,-1) - j(-1,1), j(3,-1) - j(1,1),
- j(-1,1) - j(-3,3), j(1,1) - j(-1,3), j(3,1) - j(1,3)
- ]));
- d2 = sum(abs([
- j(-3,-3) - j(-1,-1), j(-1,-3) - j(1,-1), j(1,-3) - j(3,-1),
- j(-3,-1) - j(-1,1), j(-1,-1) - j(1,1), j(1,-1) - j(3,1),
- j(-3,1) - j(-1,3), j(-1,1) - j(1,3), j(1,1) - j(3,3)
- ]));
- ratio = (1 + d1)/(1 + d2);
- value = ratio>threshold ? drp(): # Up-right edge
- ratio<(1/threshold) ? urp(): # Down-right edge
- (w1 = 1/(1 + d1^exponent); w2 = 1/(1 + d2^exponent); (drp()*w1 + urp()*w2)/(w1 + w2)); # Smooth area
- value/=16)"
- # Estimate remaining values.
- -f "init(
- const threshold = $1;
- const exponent = $2;
- interpolation = 0;
- boundary = 1;
- hp() = -j(-3,0) + 9*j(-1,0) + 9*j(1,0) - j(3,0);
- vp() = -j(0,-3) + 9*j(0,-1) + 9*j(0,1) - j(0,3);
- );
- if ((x%2) + (y%2)!=1,i,
- d1 = sum(abs([
- j(-1,-2) - j(1,-2),
- j(-2,-1) - j(0,-1), j(0,-1) - j(2,-1),
- j(-3,0) - j(-1,0), j(-1,0) - j(1,0), j(1,0) - j(3,0),
- j(-2,1) - j(0,1), j(0,1) - j(2,1),
- j(-1,2) - j(1,2)
- ]));
- d2 = sum(abs([
- j(-2,-1) - j(-2,1),
- j(-1,-2) - j(-1,0), j(-1,0) - j(-1,2),
- j(0,-3) - j(0,-1), j(0,-1) - j(0,1), j(0,1) - j(0,3),
- j(1,-2) - j(1,0), j(1,0) - j(1,2),
- j(2,-1) - j(2,1)
- ]));
- ratio = (1 + d1)/(1 + d2);
- value = ratio>threshold ? vp() : # Horizontal edge
- ratio<(1/threshold) ? hp() : # Vertical edge
- (w1 = 1/(1 + d1^exponent); w2 = 1/(1 + d2^exponent); (vp()*w1 + hp()*w2)/(w1 + w2)); # Smooth area
- value/=16)"
- -endl -done -v +
Add Comment
Please, Sign In to add comment