Last active
June 6, 2019 14:42
-
-
Save tejasvi/11777404af5fa5ab57fd7918b4dcf031 to your computer and use it in GitHub Desktop.
This file contains 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
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