Optimize: export speed, fix scaling bug, and improve workflow
- Parallelized folder export for massive speedup - Implemented exclusion mask caching - Fixed statistics discrepancy by scaling exclusion coordinates - Hardcoded CSV format to semicolon separator and comma decimal - Defaulted file/folder dialogs to images/ directory - Added unit test for coordinate scaling
This commit is contained in:
@@ -87,3 +87,37 @@ def test_set_overlay_color():
|
||||
# invalid hex does nothing
|
||||
proc.set_overlay_color("blue")
|
||||
assert proc.overlay_r == 0
|
||||
|
||||
def test_coordinate_scaling():
|
||||
proc = QtImageProcessor()
|
||||
|
||||
# Create a 200x200 image where everything is red
|
||||
red_img_small = Image.new("RGBA", (200, 200), (255, 0, 0, 255))
|
||||
proc.orig_img = red_img_small # satisfy preview logic
|
||||
proc.preview_img = red_img_small
|
||||
|
||||
# All red. Thresholds cover all red.
|
||||
proc.hue_min = 0
|
||||
proc.hue_max = 360
|
||||
proc.sat_min = 10
|
||||
proc.val_min = 10
|
||||
|
||||
# Exclude the right half (100-200)
|
||||
proc.set_exclusions([{"kind": "rect", "coords": (100, 0, 200, 200)}])
|
||||
|
||||
# Verify small stats
|
||||
s_small = proc.get_stats_headless(red_img_small)
|
||||
# total=40000, keep=20000, excl=20000
|
||||
assert s_small.total_all == 40000
|
||||
assert s_small.total_keep == 20000
|
||||
assert s_small.total_excl == 20000
|
||||
|
||||
# Now check on a 1000x1000 image (5x scale)
|
||||
red_img_large = Image.new("RGBA", (1000, 1000), (255, 0, 0, 255))
|
||||
s_large = proc.get_stats_headless(red_img_large)
|
||||
|
||||
# total=1,000,000. If scaling works, keep=500,000, excl=500,000.
|
||||
# If scaling FAILED, the mask is still 100x200 (20,000 px) -> excl=20,000.
|
||||
assert s_large.total_all == 1000000
|
||||
assert s_large.total_keep == 500000
|
||||
assert s_large.total_excl == 500000
|
||||
|
||||
Reference in New Issue
Block a user