Skip to content

Commit a09e863

Browse files
committed
Add blur effect
1 parent 1d1bd3f commit a09e863

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

batch_img/effect.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
"""class Effect: OpenCV advanced image effects operations
2-
* neon glow
3-
* hdr
1+
"""class Effect: OpenCV advanced image effects operations:
2+
** neon glow, hdr, blur **
43
Copyright © 2025 John Liu
54
"""
65

@@ -12,7 +11,7 @@
1211
EFFECTS = {
1312
"neon": {"glow_intensity": 2.0, "edge_thickness": 2},
1413
"hdr": {"gamma": 1.2, "saturation": 1.0},
15-
"blur": {"ksize": (12, 12), "sigmaX": 0},
14+
"blur": {"ksize": (29, 29), "sigmaX": 0},
1615
}
1716

1817

@@ -105,7 +104,8 @@ def apply_effects(self, img, in_path: Path, effect_name: str) -> tuple:
105104
elif effect_name == "hdr":
106105
new_img = self.hdr_effect(opencv_img, **val)
107106
elif effect_name == "blur":
108-
new_img = cv2.GaussianBlur(opencv_img, **val)
107+
tmp = cv2.cvtColor(opencv_img, cv2.COLOR_RGB2BGR)
108+
new_img = cv2.GaussianBlur(tmp, **val)
109109
if new_img is not None:
110110
rgb_img = cv2.cvtColor(new_img, cv2.COLOR_BGR2RGB)
111111
return rgb_img, out_file

tests/test_do_effect.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
@pytest.fixture(
1616
params=[
1717
# (
18-
# Path("~/Documents/IMG_0696.HEIC"),
18+
# Path("~/Documents/IMG_0231.HEIC"),
1919
# "",
20-
# "hdr",
21-
# (True, Path("~/Documents/IMG_0696_hdr.HEIC").expanduser()),
20+
# "blur",
21+
# (True, Path("~/Documents/IMG_0231_blur.HEIC").expanduser()),
2222
# ),
2323
(
2424
Path(f"{dirname(__file__)}/data/HEIC/IMG_0070.HEIC"),
@@ -32,6 +32,12 @@
3232
"hdr",
3333
(True, Path(f"{dirname(__file__)}/.out/IMG_0070_hdr.HEIC")),
3434
),
35+
(
36+
Path(f"{dirname(__file__)}/data/JPG/152.JPG"),
37+
Path(f"{dirname(__file__)}/.out/"),
38+
"blur",
39+
(True, Path(f"{dirname(__file__)}/.out/152_blur.JPG")),
40+
),
3541
]
3642
)
3743
def data_apply_1_image(request):

0 commit comments

Comments
 (0)