Fuzzy Color Image Enhancement
Fuzzy Color Image Enhancement
img_name = '/content/enishtein.png'
if os.path.exists(img_name):
img = cv.imread(img_name)
#img = cv.resize(img, (200, 200))
layer = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
WIDTH = layer.shape[1]
HEIGHT = layer.shape[0]
x0, x1, y0, y1 = 0, WIDTH - 1, 0, HEIGHT - 1
def norm(value):
return abs(phy(value))
def C(m,i):
return math.factorial(m)/((math.factorial(i)*math.factorial(m-i))+EPSILON)
def qx(i, x): # i: window index in rows, x: number of current pixel on x-axis
if (x == WIDTH - 1):
return 0
return C(m,i)*(np.power((x-x0)/(x1-x), i) * np.power((x1-x)/(x1-x0), m))
#This is the seconf implementation
#return C(m,i)*((np.power(x-x0,i) * np.power(x1-x,m-i)) / (np.power(x1-x0,m)
+EPSILON))
ws = np.zeros((m, n, w, h))
def one_layer_enhacement(e_layer):
#card_image = layer.shape[0]*layer.shape[1]
new_E_image = image_enh(ws, e_layer)
res_image = mapping(new_E_image, (-1, 1), (0, 255))
res_image = np.round(res_image)
res_image = res_image.astype(np.uint8)
return res_image
res_img = one_layer_enhacement(e_layer_gray)
plt.subplot(1, 2, 1)
plt.imshow(img, cmap = 'gray')
plt.subplot(1, 2, 2)
plt.imshow(res_img, cmap = 'gray')
plt.title('Fuzzy Grayscale image enhacement.')
plt.show()