Spaces:
Running
Running
size
Browse files
comic_panel_extractor/border_panel_extractor.py
CHANGED
|
@@ -106,7 +106,7 @@ class BorderPanelExtractor:
|
|
| 106 |
area = w * h
|
| 107 |
|
| 108 |
# Check size thresholds
|
| 109 |
-
if self._meets_size_requirements(area, w, h, image_area, img_w, img_h):
|
| 110 |
continue
|
| 111 |
|
| 112 |
# Check if region is mostly white
|
|
@@ -383,7 +383,7 @@ class BorderPanelExtractor:
|
|
| 383 |
w, h = maxc - minc, maxr - minr
|
| 384 |
area = w * h
|
| 385 |
|
| 386 |
-
if self._meets_size_requirements(area, w, h, image_area, img_w, img_h):
|
| 387 |
continue
|
| 388 |
count += 1
|
| 389 |
|
|
@@ -446,9 +446,8 @@ class BorderPanelExtractor:
|
|
| 446 |
|
| 447 |
def _meets_size_requirements(self, area: int, width: int, height: int, image_area: int, img_width: int, img_height: int) -> bool:
|
| 448 |
"""Check if region meets minimum size requirements."""
|
| 449 |
-
return (
|
| 450 |
-
|
| 451 |
-
height < self.config.min_height_ratio * img_height)
|
| 452 |
|
| 453 |
def _is_mostly_white_region(self, region, idx: int) -> bool:
|
| 454 |
"""Check if region is mostly white (allowing small percentage of black)."""
|
|
@@ -606,7 +605,7 @@ class BorderPanelExtractor:
|
|
| 606 |
w, h = x2 - x1, y2 - y1
|
| 607 |
area = w * h
|
| 608 |
|
| 609 |
-
if self._meets_size_requirements(area, w, h, image_area, img_w, img_h):
|
| 610 |
continue
|
| 611 |
|
| 612 |
filtered_box.append((x1, y1, x2, y2))
|
|
|
|
| 106 |
area = w * h
|
| 107 |
|
| 108 |
# Check size thresholds
|
| 109 |
+
if not self._meets_size_requirements(area, w, h, image_area, img_w, img_h):
|
| 110 |
continue
|
| 111 |
|
| 112 |
# Check if region is mostly white
|
|
|
|
| 383 |
w, h = maxc - minc, maxr - minr
|
| 384 |
area = w * h
|
| 385 |
|
| 386 |
+
if not self._meets_size_requirements(area, w, h, image_area, img_w, img_h):
|
| 387 |
continue
|
| 388 |
count += 1
|
| 389 |
|
|
|
|
| 446 |
|
| 447 |
def _meets_size_requirements(self, area: int, width: int, height: int, image_area: int, img_width: int, img_height: int) -> bool:
|
| 448 |
"""Check if region meets minimum size requirements."""
|
| 449 |
+
return (width >= self.config.min_width_ratio * img_width and
|
| 450 |
+
height >= self.config.min_height_ratio * img_height)
|
|
|
|
| 451 |
|
| 452 |
def _is_mostly_white_region(self, region, idx: int) -> bool:
|
| 453 |
"""Check if region is mostly white (allowing small percentage of black)."""
|
|
|
|
| 605 |
w, h = x2 - x1, y2 - y1
|
| 606 |
area = w * h
|
| 607 |
|
| 608 |
+
if not self._meets_size_requirements(area, w, h, image_area, img_w, img_h):
|
| 609 |
continue
|
| 610 |
|
| 611 |
filtered_box.append((x1, y1, x2, y2))
|