fffiloni commited on
Commit
27b7d92
·
verified ·
1 Parent(s): ab86061

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -25,13 +25,13 @@ def make_anaglyph(left_img, right_img, color_method):
25
  right = right.resize(left.size, Image.LANCZOS)
26
 
27
  # Create a copy of the left image to modify
28
- result = left.copy()
29
 
30
  # Get the pixel maps
31
  width, height = left.size
32
  leftMap = left.load()
33
  rightMap = right.load()
34
- resultMap = result.load()
35
 
36
  # Use the selected color matrix
37
  m = matrices[color_method]
@@ -41,14 +41,14 @@ def make_anaglyph(left_img, right_img, color_method):
41
  for x in range(0, width):
42
  r1, g1, b1 = leftMap[x, y]
43
  r2, g2, b2 = rightMap[x, y]
44
- resultMap[x, y] = (
45
  int(r1*m[0][0] + g1*m[0][1] + b1*m[0][2] + r2*m[1][0] + g2*m[1][1] + b2*m[1][2]),
46
  int(r1*m[0][3] + g1*m[0][4] + b1*m[0][5] + r2*m[1][3] + g2*m[1][4] + b2*m[1][5]),
47
  int(r1*m[0][6] + g1*m[0][7] + b1*m[0][8] + r2*m[1][6] + g2*m[1][7] + b2*m[1][8])
48
  )
49
 
50
  # Convert back to numpy array for Gradio
51
- return np.array(result)
52
 
53
  def make_stereopair(left_img, right_img, color_method):
54
  """Generate a stereo pair from left and right images"""
 
25
  right = right.resize(left.size, Image.LANCZOS)
26
 
27
  # Create a copy of the left image to modify
28
+ #result = left.copy()
29
 
30
  # Get the pixel maps
31
  width, height = left.size
32
  leftMap = left.load()
33
  rightMap = right.load()
34
+ #resultMap = result.load()
35
 
36
  # Use the selected color matrix
37
  m = matrices[color_method]
 
41
  for x in range(0, width):
42
  r1, g1, b1 = leftMap[x, y]
43
  r2, g2, b2 = rightMap[x, y]
44
+ leftMap[x, y] = (
45
  int(r1*m[0][0] + g1*m[0][1] + b1*m[0][2] + r2*m[1][0] + g2*m[1][1] + b2*m[1][2]),
46
  int(r1*m[0][3] + g1*m[0][4] + b1*m[0][5] + r2*m[1][3] + g2*m[1][4] + b2*m[1][5]),
47
  int(r1*m[0][6] + g1*m[0][7] + b1*m[0][8] + r2*m[1][6] + g2*m[1][7] + b2*m[1][8])
48
  )
49
 
50
  # Convert back to numpy array for Gradio
51
+ return np.array(left)
52
 
53
  def make_stereopair(left_img, right_img, color_method):
54
  """Generate a stereo pair from left and right images"""