Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

meaning of cv2.threshold() parameters

I am testing the cv2.threshold() function in with different values but I get each time unexpected results. So this means simply I do not understand the meaning of 2 parameters and their effect:

  • dst
  • maxval

Could someone clear me on this ?

Thank you in advance.

meaning of cv2.threshold() parameters

I am testing the cv2.threshold() function in with different values but I get each time unexpected results. So this means simply I do not understand the meaning of 2 parameters and their effect:

  • dst
  • maxval

Could someone clear me on this ?

Thank you in advance.

meaning of cv2.threshold() parameters

I am testing the cv2.threshold() function in with different values but I get each time unexpected results. So this means simply I do not understand the meaning of 2 parameters and their effect:

  • dst
  • maxval

Could someone clear me on this ?

EDIT:

When I run this code:

import cv2


im=cv2.imread('image.jpg')
imgray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)

ret,thresh=cv2.threshold(imgray,im.size,255,cv2.THRESH_BINARY_INV)

countours,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)


cv2.drawContours(im,countours,-1,(0,255,0),3)
cv2.imshow("Contour",im)

cv2.waitKey(0)
cv2.destroyAllWindows()

I do not see any result on the pictures I test (I want to draw their contour, they have white background)

Thank you in advance.

meaning of cv2.threshold() parameters

I am testing the cv2.threshold() function in with different values but I get each time unexpected results. So this means simply I do not understand the meaning of 2 parameters and their effect:

  • dst
  • maxval

Could someone clear me on this ?

EDIT:

When I run this code:

import cv2


im=cv2.imread('image.jpg')
imgray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)

ret,thresh=cv2.threshold(imgray,im.size,255,cv2.THRESH_BINARY_INV)

countours,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)


cv2.drawContours(im,countours,-1,(0,255,0),3)
cv2.imshow("Contour",im)
cv2.imshow("Begueradj",im)

cv2.waitKey(0)
cv2.destroyAllWindows()

I do not see any result on the pictures I test (I want to draw their contour, they have white background)

Thank you in advance.