Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement