You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

13 lines
337 B

# 実験課題3
# 3.3 2値化
import cv2
image_path = 'sample.jpg'
gray_img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
if gray_img is not None:
threshold_value = 127
max_value = 255
ret, binary_img = cv2.threshold(gray_img, threshold_value, max_value, cv2.THRESH_BINARY)
cv2.imwrite('3_3_binarize.jpg', binary_img)