This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # get shape of arrow image | |
| rows,cols,channel = img2.shape | |
| # region of image of logo image with same dimensions as arrow image | |
| roi = img3[0:rows,0:cols] | |
| # converting arrow image to grayscale and thresholding | |
| img2gray = cv2.cvtColor(img2,cv2.COLOR_BGR2GRAY) | |
| _ , mask = cv2.threshold(img2gray,200,255,cv2.THRESH_BINARY) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cv2.imshow('not',cv2.bitwise_not(img1)) # not | |
| cv2.imshow('and',cv2.bitwise_and(img1,img2)) # and | |
| cv2.imshow('or',cv2.bitwise_or(img1,img2)) # or | |
| cv2.imshow('xor',cv2.bitwise_xor(img1,img2)) # xor | |
| cv2.waitKey(0) | |
| cv2.destroyAllWindows() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cv2.imshow('wadd',cv2.addWeighted(img1,0.6,img2,0.4,0)) | |
| cv2.waitKey(0) | |
| cv2.destroyAllWindows() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # mathematical operators | |
| cv2.imshow('+',img1+img2) | |
| cv2.imshow('-',img1-img2) | |
| cv2.imshow('*',img1*img2) | |
| # cv2 functions | |
| cv2.imshow('add',cv2.add(img1,img2)) | |
| cv2.imshow('sub',cv2.subtract(img1,img2)) | |
| cv2.imshow('mul',cv2.multiply(img1,img2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cv2.imshow('+100',cv2.add(img1,100)) # add 100 | |
| cv2.imshow('-100',cv2.subtract(img1,100)) # subtract 100 | |
| cv2.imshow('*5',cv2.multiply(img1,5)) # multiply 5 | |
| cv2.waitKey(0) | |
| cv2.destroyAllWindows() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| img1 = cv2.imread('c:/Users/siddhant.dash/Downloads/left.jpg') | |
| img2 = cv2.imread('c:/Users/siddhant.dash/Downloads/up.jpg') | |
| img3 = cv2.imread('c:/Users/siddhant.dash/Downloads/among_us.png') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cv2.imshow('+150',img1+150) | |
| cv2.imshow('-250',img1-250) | |
| cv2.imshow('x10',img1*10) | |
| cv2.waitKey(0) | |
| cv2.destroyAllWindows() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) | |
| cv2.imshow('gray',gray) | |
| val1,th1 = cv2.threshold(gray,125,255,cv2.THRESH_BINARY) | |
| cv2.imshow('t1',th1) | |
| val2,th2 = cv2.threshold(gray,125,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU) | |
| cv2.imshow('t2',th2) | |
| th3 = cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,155,1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Write Text on Image | |
| img1 = cv2.putText(img.copy(),'Klaus',(30,150),cv2.FONT_HERSHEY_SIMPLEX,1,(200,100,0),2,cv2.LINE_AA) | |
| cv2.imshow('1',img1) | |
| # Draw Rectangle on Image | |
| img2 = cv2.rectangle(img.copy(),(60,0),(150,120),(0,0,255),2) | |
| cv2.imshow('2',img2) | |
| # Draw Circle on Image | |
| img3 = cv2.circle(img.copy(),(80,80),30,(0,255,255),2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cv2.imshow('Cropped',img[0:120,60:150]) | |
| cv2.waitKey(0) | |
| cv2.destroyAllWindows() |
NewerOlder