Skip to content

Instantly share code, notes, and snippets.

@Praveen76
Created April 15, 2022 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Praveen76/f67f7111636c3eec56626f5906d30799 to your computer and use it in GitHub Desktop.
Save Praveen76/f67f7111636c3eec56626f5906d30799 to your computer and use it in GitHub Desktop.
blank=np.zeros((400,400),dtype='uint8')
rect=cv.rectangle(blank.copy(),(30,30),(370,370),255,-1)
circle=cv.circle(blank.copy(),(200,200),200,255,-1)
cv.imshow('Rectangle',rect)
cv.imshow('Circle',circle)
#BitWise And --> Intersection Region
bitwiseAND=cv.bitwise_and(rect,circle)
#BitWise OR
bitwiseOR=cv.bitwise_or(rect,circle)
#BitWise XOR --> Intersect- Union
bitwiseXOR=cv.bitwise_xor(rect,circle)
#BitWise NOT --> Invert the color
bitwiseNOT=cv.bitwise_not(rect,circle)
cv.imshow('bitwiseAND',bitwiseAND)
cv.imshow('bitwiseOR',bitwiseOR)
cv.imshow('bitwiseXOR',bitwiseXOR)
cv.imshow('bitwiseNOT',bitwiseNOT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment