Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binarization augmentation: binarize channels together #9

Open
bertsky opened this issue Jan 30, 2021 · 0 comments
Open

binarization augmentation: binarize channels together #9

bertsky opened this issue Jan 30, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@bertsky
Copy link

bertsky commented Jan 30, 2021

IMO this is incorrect and can create bad results which could then deteriorate training:

def otsu_copy(img):
img_r=np.zeros(img.shape)
img1=img[:,:,0]
img2=img[:,:,1]
img3=img[:,:,2]
_, threshold1 = cv2.threshold(img1, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
_, threshold2 = cv2.threshold(img2, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
_, threshold3 = cv2.threshold(img3, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
img_r[:,:,0]=threshold1
img_r[:,:,1]=threshold1
img_r[:,:,2]=threshold1
return img_r

Thresholding must not apply to each color channel separately, but all combined – e.g. by doing grayscale reduction first.

@cneud cneud added the enhancement New feature or request label Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants