Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2015
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.38 KB | None | 0 0
  1. #@gmic scale_dcci2x : _edge_threshold>=0
  2. #@gmic : Double image size using directional cubic convolution interpolation,
  3. #@gmic : as described in https://en.wikipedia.org/wiki/Directional_Cubic_Convolution_Interpolation.
  4. #@gmic : Default value: 'edge_threshold=1.15'.
  5. #@gmic : $ image.jpg --scale_dcci2x ,
  6. scale_dcci2x : -check "${1=1.15}>=0"
  7.   -e[^-1] "Double image size using directional cubic convolution interpolation."
  8.   -v - -repeat $! -l[$>]
  9.     -r 200%,200%,1,100%,4 -r {w-1},{h-1},1,100%,0
  10.     -f "*
  11. if (!(x%2 && y%2),i,
  12.  d1 = abs(j(-1,-3,0,0,0,1) - j(-3,-1,0,0,0,1)) + abs(j(1,-3,0,0,0,1) - j(-1,-1,0,0,0,1)) + abs(j(3,-3,0,0,0,1) - j(1,-1,0,0,0,1)) +
  13.       abs(j(-1,-1,0,0,0,1) - j(-3,1,0,0,0,1)) + abs(j(1,-1,0,0,0,1) - j(-1,1,0,0,0,1)) + abs(j(3,-1,0,0,0,1) - j(1,1,0,0,0,1)) +
  14.       abs(j(-1,1,0,0,0,1) - j(-3,3,0,0,0,1)) + abs(j(1,1,0,0,0,1) - j(-1,3,0,0,0,1)) + abs(j(3,1,0,0,0,1) - j(1,3,0,0,0,1));
  15.  d2 = abs(j(-3,-3,0,0,0,1) - j(-1,-1,0,0,0,1)) + abs(j(-1,-3,0,0,0,1) - j(1,-1,0,0,0,1)) + abs(j(1,-3,0,0,0,1) - j(3,-1,0,0,0,1)) +
  16.       abs(j(-3,-1,0,0,0,1) - j(-1,1,0,0,0,1)) + abs(j(-1,-1,0,0,0,1) - j(1,1,0,0,0,1)) + abs(j(1,-1,0,0,0,1) - j(3,1,0,0,0,1)) +
  17.       abs(j(-3,1,0,0,0,1) - j(-1,3,0,0,0,1)) + abs(j(-1,1,0,0,0,1) - j(1,3,0,0,0,1)) + abs(j(1,1,0,0,0,1) - j(3,3,0,0,0,1));
  18.  if ((1 + d1)/(1 + d2)>$1,
  19.    (-j(-3,-3,0,0,0,1) + 9*j(-1,-1,0,0,0,1) + 9*j(1,1,0,0,0,1) - j(3,3,0,0,0,1))/16,
  20.  if ((1 + d2)/(1 + d1)>$1,
  21.    (-j(3,-3,0,0,0,1) + 9*j(1,-1,0,0,0,1) + 9*j(-1,1,0,0,0,1) - j(-3,3,0,0,0,1))/16,
  22.    (
  23.      w1 = 1/(1 + d1^5);
  24.      w2 = 1/(1 + d2^5);
  25.      weight1 = w1/(w1 + w2);
  26.      weight2 = w2/(w1 + w2);
  27.      DownRightPixel = (-j(-3,-3,0,0,0,1) + 9*j(-1,-1,0,0,0,1) + 9*j(1,1,0,0,0,1) - j(3,3,0,0,0,1))/16;
  28.      UpRightPixel = (-j(3,-3,0,0,0,1) + 9*j(1,-1,0,0,0,1) + 9*j(-1,1,0,0,0,1) - j(-3,3,0,0,0,1))/16;
  29.      DownRightPixel*weight1 + UpRightPixel*weight2
  30.    )
  31.  ))
  32. )
  33. "
  34.     -f "*
  35. if ((!(x%2) && !(y%2)) || ((x%2) && (y%2)),i,
  36.  d1 = abs(j(1,-2,0,0,0,1) - j(-1,-2,0,0,0,1)) +
  37.       abs(j(2,-1,0,0,0,1) - j(0,-1,0,0,0,1)) + abs(j(0,-1,0,0,0,1) - j(-2,-1,0,0,0,1)) +
  38.       abs(j(3,0,0,0,0,1) - j(1,0,0,0,0,1)) + abs(j(1,0,0,0,0,1) - j(-1,0,0,0,0,1)) + abs(j(-1,0,0,0,0,1) - j(-3,0,0,0,0,1)) +
  39.       abs(j(2,1,0,0,0,1) - j(0,1,0,0,0,1)) + abs(j(0,1,0,0,0,1) - j(-2,1,0,0,0,1)) +
  40.       abs(j(1,2,0,0,0,1) - j(-1,2,0,0,0,1));
  41.  d2 = abs(j(-2,1,0,0,0,1) - j(-2,-1,0,0,0,1)) +
  42.       abs(j(-1,2,0,0,0,1) - j(-1,0,0,0,0,1)) + abs(j(-1,0,0,0,0,1) - j(-1,-2,0,0,0,1)) +
  43.       abs(j(0,3,0,0,0,1) - j(0,1,0,0,0,1)) + abs(j(0,1,0,0,0,1) - j(0,-1,0,0,0,1)) + abs(j(0,-1,0,0,0,1) - j(0,-3,0,0,0,1)) +
  44.       abs(j(1,2,0,0,0,1) - j(1,0,0,0,0,1)) + abs(j(1,0,0,0,0,1) - j(1,-2,0,0,0,1)) +
  45.       abs(j(2,1,0,0,0,1) - j(2,-1,0,0,0,1));
  46.  if ((1 + d1)/(1 + d2)>$1,
  47.    (-j(0,-3,0,0,0,1) + 9*j(0,-1,0,0,0,1) + 9*j(0,1,0,0,0,1) - j(0,3,0,0,0,1))/16,
  48.  if ((1 + d2)/(1 + d1)>$1,
  49.    (-j(-3,0,0,0,0,1) + 9*j(-1,0,0,0,0,1) + 9*j(1,0,0,0,0,1) - j(3,0,0,0,0,1))/16,
  50.    (
  51.      w1 = 1/(1 + d1^5);
  52.      w2 = 1/(1 + d2^5);
  53.      weight1 = w1/(w1 + w2);
  54.      weight2 = w2/(w1 + w2);
  55.      HorizontalPixel = (-j(-3,0,0,0,0,1) + 9*j(-1,0,0,0,0,1) + 9*j(1,0,0,0,0,1) - j(3,0,0,0,0,1))/16;
  56.      VerticalPixel = (-j(0,-3,0,0,0,1) + 9*j(0,-1,0,0,0,1) + 9*j(0,1,0,0,0,1) - j(0,3,0,0,0,1))/16;
  57.      VerticalPixel*weight1 + HorizontalPixel*weight2
  58.    )
  59.  ))
  60. )
  61. "
  62.   -endl -done -v +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement