Need advice on how to clean noise out of image
Does anyone have any general advice on how to clean out the noise in my result? I can't seem to get the threshold correct.
I'm following this research and building the binary mask in figure 2.
import cv2
import numpy as np
from skimage import io
import copy
urls = [
"https://coinmodel.s3.amazonaws.com/69A.jpg",
"https://coinmodel.s3.amazonaws.com/68A.jpg",
"https://coinmodel.s3.amazonaws.com/67A.jpg",
"https://coinmodel.s3.amazonaws.com/66A.jpg",
"https://coinmodel.s3.amazonaws.com/65A.jpg",
"https://coinmodel.s3.amazonaws.com/64A.jpg",
"https://coinmodel.s3.amazonaws.com/63A.jpg",
"https://coinmodel.s3.amazonaws.com/62A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_0A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_2A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_3A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_4A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_5A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_6A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_7A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_8A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_9A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_10A.jpg",
"https://coinmodel.s3.amazonaws.com/1884_67_11A.jpg",
]
i = 0
for url in urls:
img = io.imread(url)
img_blur = cv2.GaussianBlur(img, (3, 3), 0)
img_bgrL = cv2.cvtColor(img_blur, cv2.COLOR_BGR2GRAY)
img_bgrT = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
imgL = cv2.Laplacian(img_bgrL, 0)
ret, imgT = cv2.threshold(img_bgrT, 100, 255, cv2.THRESH_BINARY_INV)
if i != 0:
Laplacian_sum = cv2.add(imgL, imgL_last)
Threshold_sum = cv2.add(imgT, imgT_last)
imgL_last = copy.copy(imgL)
imgT_last = copy.copy(imgT)
i=i+1
mean_gradient_map = Laplacian_sum #/ i
mean_threshold_image = Threshold_sum #/ i
binary_reference_coin_mask = cv2.add(mean_gradient_map, mean_threshold_image)
cv2.imshow("Laplacian mean", mean_gradient_map)
cv2.imshow("Threshold mean", mean_threshold_image)
cv2.imshow("binary_reference_coin_mask", binary_reference_coin_mask)
cv2.waitKey(0)