Sagar Bharadwaj commited on
Commit
dc882c7
·
1 Parent(s): 534e13a

Changed the color indexing to 1-based

Browse files
colorbynumber/main.py CHANGED
@@ -107,9 +107,10 @@ class ColorByNumber:
107
  image[start_row:end_row, end_col] = border_color # Right Border
108
 
109
  # Draw text label below the square
110
- text_size, _ = cv.getTextSize(str(i), font, font_size, 1)
 
111
  text_row = (end_row + text_size[1]) + 5
112
  text_col = start_col + (square_size // 2) - (text_size[0] // 2)
113
- cv.putText(image, str(i), (text_col, text_row), font, font_size, (0, 0, 0), 1)
114
 
115
  return image
 
107
  image[start_row:end_row, end_col] = border_color # Right Border
108
 
109
  # Draw text label below the square
110
+ text = str(i + 1)
111
+ text_size, _ = cv.getTextSize(text, font, font_size, 1)
112
  text_row = (end_row + text_size[1]) + 5
113
  text_col = start_col + (square_size // 2) - (text_size[0] // 2)
114
+ cv.putText(image, text, (text_col, text_row), font, font_size, (0, 0, 0), 1)
115
 
116
  return image
colorbynumber/simplify_image.py CHANGED
@@ -26,6 +26,9 @@ def _choose_closest_colors(image, color_list):
26
  indices_color_choices = norm_diff.argmin(axis = -1)
27
  simplified_image = color_list[indices_color_choices.flatten(), :].reshape(image.shape)
28
 
 
 
 
29
  return simplified_image, indices_color_choices
30
 
31
  def _denoise_image(image, h):
 
26
  indices_color_choices = norm_diff.argmin(axis = -1)
27
  simplified_image = color_list[indices_color_choices.flatten(), :].reshape(image.shape)
28
 
29
+ # Adding 1 to indices_color_choices as so the first color is labeled as 1 and not 0.
30
+ indices_color_choices = indices_color_choices + 1
31
+
32
  return simplified_image, indices_color_choices
33
 
34
  def _denoise_image(image, h):