Skip to content

Commit 43defd5

Browse files
committed
update pre-check function (noise)
1 parent dad00c1 commit 43defd5

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

evaluation_function/evaluation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"- brightness: {brightness_mean}\n"
4242
"- contrast: {contrast_std}\n"
4343
"- sharpness: {sharpness_score}\n"
44-
"- lighting uniformity: {illumination_nonuniformity}\n"
44+
"- noise: {noise_score}\n"
4545
"These values are provided as reference only and do not determine whether the assembly is correct."
4646
),
4747
},
@@ -532,7 +532,7 @@ def qfmt(key: str) -> str:
532532
brightness_mean=qfmt("brightness_mean"),
533533
contrast_std=qfmt("contrast_std"),
534534
sharpness_score=qfmt("sharpness_score"),
535-
illumination_nonuniformity=qfmt("illumination_nonuniformity"),
535+
noise_score=qfmt("noise_score"),
536536
)
537537

538538
if task == "single_stage":

evaluation_function/yolo_pipeline.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -717,26 +717,15 @@ def compute_image_quality_metrics(img_bgr: np.ndarray) -> Dict[str, float]:
717717
brightness_mean = float(np.mean(gray))
718718
contrast_std = float(np.std(gray))
719719
sharpness_score = float(cv2.Laplacian(gray, cv2.CV_64F).var())
720-
721-
h, w = gray.shape
722-
block_means: List[float] = []
723-
for r in range(4):
724-
for c in range(4):
725-
y0 = int(r * h / 4)
726-
y1 = int((r + 1) * h / 4)
727-
x0 = int(c * w / 4)
728-
x1 = int((c + 1) * w / 4)
729-
patch = gray[y0:y1, x0:x1]
730-
if patch.size > 0:
731-
block_means.append(float(np.mean(patch)))
732-
733-
illumination_nonuniformity = float(np.std(block_means)) if block_means else 0.0
720+
blur = cv2.GaussianBlur(gray, (5, 5), 0)
721+
noise_residual = gray.astype(np.float32) - blur.astype(np.float32)
722+
noise_score = float(np.std(noise_residual))
734723

735724
return {
736725
"brightness_mean": brightness_mean,
737726
"contrast_std": contrast_std,
738727
"sharpness_score": sharpness_score,
739-
"illumination_nonuniformity": illumination_nonuniformity,
728+
"noise_score": noise_score,
740729
}
741730

742731

0 commit comments

Comments
 (0)