Measuring color difference from an ROI within the image using DeltaE color difference?
I Have coded this far and I think there is some problem and that is why I can not get the proper result:
# Open image and discard alpha channel which makes wheel round rather than square
import numpy as np
from skimage import color, io
import matplotlib.pyplot as plt
import imageio
import cv2
import skimage
import PIL
# Open image and make Numpy arrays 'rgb' and 'Lab'
pic = imageio.imread('E:\JU_V2_DIGIT\RGB_Crop\RGB_P7_G0_8.png')
pic2 = pic.copy()
total_row, total_col, layers = pic2.shape
mask= np.zeros_like(pic2)
x,y = np.ogrid[:total_row, :total_col]
Lab_pic = color.rgb2lab(pic)
L_pic, A_pic, B_pic = cv2.split(Lab_pic)
cv2.imshow("L_Channel", L_pic) # For L Channel
cv2.imshow("A_Channel", A_pic) # For A Channel
cv2.imshow("B_Channel", B_pic) # For B Channel
cen_x, cen_y = total_row/2, total_col/2
distance_from_center = np.sqrt((x-cen_x+10)**2+(y-cen_y-15)**2)
radius = (total_row/3)
circular_pic = distance_from_center>radius
pic2[circular_pic] = 0
pic2[mask] = 0
#cv2.imwrite('D:\SHROUTI\Testpictures\opencvmasking_human.jpg',dst)
cv2.imshow("cir_mask",pic2)
Lab = color.rgb2lab(pic2)
L_mask,A_mask,B_mask = cv2.split(Lab)
cv2.imshow("L_Channel_mask", L_mask) # For L Channel
cv2.imshow("A_Channel_mask", A_mask) # For A Channel
cv2.imshow("B_Channel_mask", B_mask) # For B Channel
LMean = L_mask.mean()
AMean = A_mask.mean()
BMean = B_mask.mean()
'''LStandard = LMean*np.ones([total_row, total_col], dtype = int)
AStandard = AMean*np.ones([total_row, total_col], dtype = int)
BStandard = BMean*np.ones([total_row, total_col], dtype = int)'''
DeltaL = L_pic-LMean
DeltaA = A_pic- AMean
DeltaB = B_pic - BMean
DeltaE = np.sqrt(pow(DeltaA,2)+pow(DeltaB,2)+pow(DeltaL,2))
print(DeltaE)
cv2.imshow("deltaE",DeltaE)
cv2.waitKey()
I am using the code for the RGB image below
My moto is to measure Euclidean distance from the hand gesture to the whole image and so that we can Display the masked Delta E image - the delta E within the masked region only and also Display the Delta E image - the delta E over the entire image.
and the problem is ?
the delta E within the masked region only and also Display the Delta E image - the delta E over the entire image.
Oh ok ^^ But what you actually want to archieve - detection of a gesture and their meaning?
yes, I want to segment the gesture. After applying deltaE over the whole image it should highlight the roi and should make the other portions of the image grey. But I am getting a completely white picture, having just nothing inside