# ch9_1.py
import cv2
import numpy as np

thresh = 127                        # 定義閾值
maxval = 255                        # 定義像素最大值
src = np.random.randint(0,256,size=[3,5],dtype=np.uint8)
ret, dst = cv2.threshold(src,thresh,maxval,cv2.THRESH_BINARY)
print(f"src =\n {src}")
print(f"threshold = {ret}")
print(f"dst =\n {dst}")







578922e497ac54c2bf29978422245da8c06972a3
<mask token>

<mask token>
print(f'src =\n {src}')
print(f'threshold = {ret}')
print(f'dst =\n {dst}')

<mask token>
thresh = 127
maxval = 255
src = np.random.randint(0, 256, size=[3, 5], dtype=np.uint8)
ret, dst = cv2.threshold(src, thresh, maxval, cv2.THRESH_BINARY)
print(f'src =\n {src}')
print(f'threshold = {ret}')
print(f'dst =\n {dst}')

import cv2
import numpy as np
thresh = 127
maxval = 255
src = np.random.randint(0, 256, size=[3, 5], dtype=np.uint8)
ret, dst = cv2.threshold(src, thresh, maxval, cv2.THRESH_BINARY)
print(f'src =\n {src}')
print(f'threshold = {ret}')
print(f'dst =\n {dst}')

# ch9_1.py
import cv2
import numpy as np

thresh = 127                        # 定義閾值
maxval = 255                        # 定義像素最大值
src = np.random.randint(0,256,size=[3,5],dtype=np.uint8)
ret, dst = cv2.threshold(src,thresh,maxval,cv2.THRESH_BINARY)
print(f"src =\n {src}")
print(f"threshold = {ret}")
print(f"dst =\n {dst}")






