|
import sys
import cv2
#if len(sys.argv)<3 : sys.exit(f'usage: {sys.argv[0]} infile.jpg outfile.jpg')
#image = cv2.imread(sys.argv[1])
image = cv2.imread('J20240228_001.jpg')
h,w,c = image.shape
print(h,w,c)
white=[255,255,255]
black=[0,0,0]
yellow=[0,255,255]
for i in range(0, int(h/4)):
for j in range(0, int(w/2)):
if j%10<5 : continue
b,g,r = image[i,j]
if r > g + 30 or r > b + 30 : image[i,j]=yellow
if r < 50 : image[i,j]=[0,255,0]
#if r > 250 : image[i,j]=white
#if r < 20 : image[i,j]=black
cv2.imshow('image',image)
cv2.waitKey(0)
cv2.imwrite('abc.jpg',image)
cv2.destroyAllWindows() |
|