Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2015
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.51 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 -
  9.   -r 200%,200%,1,100%,4
  10.   -f "*
  11. if (!(x%2 && y%2),i,
  12.  d1 = abs(j(-1,-3) - j(-3,-1)) + abs(j(1,-3) - j(-1,-1)) + abs(j(3,-3) - j(1,-1)) +
  13.       abs(j(-1,-1) - j(-3,1)) + abs(j(1,-1) - j(-1,1)) + abs(j(3,-1) - j(1,1)) +
  14.       abs(j(-1,1) - j(-3,3)) + abs(j(1,1) - j(-1,3)) + abs(j(3,1) - j(1,3));
  15.  d2 = abs(j(-3,-3) - j(-1,-1)) + abs(j(-1,-3) - j(1,-1)) + abs(j(1,-3) - j(3,-1)) +
  16.       abs(j(-3,-1) - j(-1,1)) + abs(j(-1,-1) - j(1,1)) + abs(j(1,-1) - j(3,1)) +
  17.       abs(j(-3,1) - j(-1,3)) + abs(j(-1,1) - j(1,3)) + abs(j(1,1) - j(3,3));
  18.  if ((1 + d1)/(1 + d2)>$1,
  19.    (-j(-3,-3) + 9*j(-1,-1) + 9*j(1,1) - j(3,3))/16,
  20.  if ((1 + d2)/(1 + d1)>$1,
  21.    (-j(3,-3) + 9*j(1,-1) + 9*j(-1,1) - j(-3,3))/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) + 9*j(-1,-1) + 9*j(1,1) - j(3,3))/16;
  28.      UpRightPixel = (-j(3,-3) + 9*j(1,-1) + 9*j(-1,1) - j(-3,3))/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) - j(-1,-2)) +
  37.       abs(j(2,-1) - j(0,-1)) + abs(j(0,-1) - j(-2,-1)) +
  38.       abs(j(3,0) - j(1,0)) + abs(j(1,0) - j(-1,0)) + abs(j(-1,0) - j(-3,0)) +
  39.       abs(j(2,1) - j(0,1)) + abs(j(0,1) - j(-2,1)) +
  40.       abs(j(1,2) - j(-1,2));
  41.  d2 = abs(j(-2,1) - j(-2,-1)) +
  42.       abs(j(-1,2) - j(-1,0)) + abs(j(-1,0) - j(-1,-2)) +
  43.       abs(j(0,3) - j(0,1)) + abs(j(0,1) - j(0,-1)) + abs(j(0,-1) - j(0,-3)) +
  44.       abs(j(1,2) - j(1,0)) + abs(j(1,0) - j(1,-2)) +
  45.       abs(j(2,1) - j(2,-1));
  46.  if ((1 + d1)/(1 + d2)>$1,
  47.    (-j(0,-3) + 9*j(0,-1) + 9*j(0,1) - j(0,3))/16,
  48.  if ((1 + d2)/(1 + d1)>$1,
  49.    (-j(-3,0) + 9*j(-1,0) + 9*j(1,0) - j(3,0))/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) + 9*j(-1,0) + 9*j(1,0) - j(3,0))/16;
  56.      VerticalPixel = (-j(0,-3) + 9*j(0,-1) + 9*j(0,1) - j(0,3))/16;
  57.      VerticalPixel*weight1 + HorizontalPixel*weight2
  58.    )
  59.  ))
  60. )
  61. "
  62.   -v +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement