Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 = LMeannp.ones([total_row, total_col], dtype = int) AStandard = AMeannp.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 image description

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.

click to hide/show revision 2
None

updated 2020-04-07 01:42:41 -0600

berak gravatar image

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

square import numpy as np from skimage import color, io import matplotlib.pyplot as plt import imageio import cv2 import skimage import PIL

PIL # Open image and make Numpy arrays 'rgb' and 'Lab'

'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.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

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) 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)

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.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

Channel LMean = L_mask.mean() AMean = A_mask.mean() BMean = B_mask.mean()

B_mask.mean() '''LStandard = LMeannp.ones([total_row, LMean*np.ones([total_row, total_col], dtype = int) AStandard = AMeannp.ones([total_row, AMean*np.ones([total_row, total_col], dtype = int) BStandard = BMean*np.ones([total_row, total_col], dtype = int)'''

int)''' DeltaL = L_pic-LMean DeltaA = A_pic- AMean DeltaB = B_pic - BMean

BMean DeltaE = np.sqrt(pow(DeltaA,2)+pow(DeltaB,2)+pow(DeltaL,2)) print(DeltaE) cv2.imshow("deltaE",DeltaE) cv2.waitKey()

cv2.waitKey()

I am using the code for the RGB image below image description

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.