#!/usr/bin/python import numpy as np import cv2 import math def HSV(largura, altura, raio): if (raio > largura or raio > altura): print("Raio deve ser menor que largura e altura!\n") return else: img = np.ones((largura, altura, 3), np.float32) ll, cc = np.indices((largura,altura)) #coloca os indices (0,0) no centro das matrizes ll = ll - (largura/2) cc = cc - (altura/2) rad = np.arctan2(ll.astype(np.float32), cc.astype(np.float32)) graus = np.degrees(rad) #HUE img[:,:,0] = graus #Saturation img[:,:,1] = 1 - ((ll**2 + cc**2).astype(np.float32) / (raio**2)) #Value img[:,:,2] = ll**2 + cc**2 < raio**2 img = cv2.cvtColor(img, cv2.COLOR_HSV2BGR) cv2.imshow("HSV", img) cv2.imwrite('HSVinv.jpg', (img*256).astype(np.float32)) cv2.waitKey() cv2.destroyAllWindows() HSV(1000,1200,475)