jebin2 commited on
Commit
359e487
·
1 Parent(s): 8b56694

inver blck for black and white image

Browse files
.gitignore CHANGED
@@ -208,4 +208,5 @@ __marimo__/
208
  temp_dir
209
  input.jpg
210
  comic_panel_extractor/api_outputs/
211
- temp.py
 
 
208
  temp_dir
209
  input.jpg
210
  comic_panel_extractor/api_outputs/
211
+ temp.py
212
+ test*.jpg
comic_panel_extractor/image_processor.py CHANGED
@@ -52,7 +52,7 @@ class ImageProcessor:
52
  cv2.imwrite(str(binary_path), binary)
53
  cv2.imwrite(str(dilated_path), dilated)
54
 
55
- return str(gray_path), str(binary_path), str(dilated_path)
56
 
57
  def invert_if_black_dominates(self, binary):
58
  # Threshold to binary image
 
52
  cv2.imwrite(str(binary_path), binary)
53
  cv2.imwrite(str(dilated_path), dilated)
54
 
55
+ return str(gray_path), str(binary_path), str(dilated_path), is_inverted
56
 
57
  def invert_if_black_dominates(self, binary):
58
  # Threshold to binary image
comic_panel_extractor/main.py CHANGED
@@ -32,10 +32,11 @@ class ComicPanelExtractor:
32
  masked_image_path = self.image_processor.mask_text_regions([bubble["bbox"] for bubble in text_bubbles])
33
 
34
  # Step 2: Preprocess image
35
- _, _, processed_image_path = self.image_processor.preprocess_image(masked_image_path)
36
 
37
- # Step 3: Remove Inner Sketch
38
- processed_image_path = self.image_processor.remove_inner_sketch(processed_image_path)
 
39
 
40
  # Step 4: Thin border line
41
  processed_image_path = self.image_processor.thin_image_borders(processed_image_path)
 
32
  masked_image_path = self.image_processor.mask_text_regions([bubble["bbox"] for bubble in text_bubbles])
33
 
34
  # Step 2: Preprocess image
35
+ _, _, processed_image_path, is_inverted = self.image_processor.preprocess_image(masked_image_path)
36
 
37
+ if is_inverted:
38
+ # Step 3: Remove Inner Sketch
39
+ processed_image_path = self.image_processor.remove_inner_sketch(processed_image_path)
40
 
41
  # Step 4: Thin border line
42
  processed_image_path = self.image_processor.thin_image_borders(processed_image_path)