I need to threshold my image without using OpenCV function.
I know this way only, but in this case I am using cv2.threshold function from OpenCV:
img = cv2.imread('filename', 0)
_, thresh = cv2.threshold(img,127,255,cv.THRESH_BINARY)
How can I code thresholding without using cv2.threshold function.
I tried this one:
def thresholdimg(img, n):
img_shape = img.shape
height = img_shape[0]
width = img_shape[1]
for row in range(width):
for column in range(height):
if img[column, row] > s:
img[column, row] = 0
else:
img[column, row] = 255
return
Where, n is equal to 127
Thanks in advance.
You can use numpy to threshold in Python without OpenCV.
if image is a grayscale image.