Skip to content

Instantly share code, notes, and snippets.

@tejasvi
Last active June 6, 2019 14:42
Show Gist options
  • Save tejasvi/11777404af5fa5ab57fd7918b4dcf031 to your computer and use it in GitHub Desktop.
Save tejasvi/11777404af5fa5ab57fd7918b4dcf031 to your computer and use it in GitHub Desktop.
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
import sys
np.set_printoptions(threshold=sys.maxsize)
ig1 = cv.imread('i2.jpg', 0)
ic1 = cv.imread('i2.jpg', 1)
ig2 = cv.imread('i1.png', 0)
ic2 = cv.imread('i1.png', 1)
blue1 = ic1[:, :, 0]
blur = cv.GaussianBlur(blue1, (5, 5), 0)
trash, masker = cv.threshold(blur, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)
mask1 = np.ones(blue1.shape, np.uint8)*255
contours, trash = cv.findContours(
masker, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
cv.drawContours(mask1, contours, -1, (0,0,0),-1)
mcol = cv.mean(ic1, mask=mask1)
ic2 = cv.cvtColor(ic2, cv.COLOR_BGR2HSV)
ic2[:, :, 2] = 0
ic2[:, :, 0] = ic2[:, :, 0]*8
""" sat2 = ic2[:, :, 1]
sat2 = np.divide(sat2, 2*256)
# print(sat2)
hue2 = ic2[:, :, 0]
hue2 = hue2 * 4+sat2
maxo = 0
for x in hue2:
for y in x:
if (y > maxo):
maxo = y
print(maxo) """
cv.imshow('1', ic2)
cv.waitKey(0)
cv.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment