starbucksdolcelatte

dominant colors

No preview for this file type
No preview for this file type
......@@ -6,4 +6,4 @@ rgb = sRGBColor(222.5, 201.4, 188.9, is_upscaled=True)
print(rgb)
#lab로 변환. through_rgb_type=sRGBColor 로 넣어준다.(AdobeRGBColor클래스 사용 X)
lab = convert_color(rgb, LabColor, through_rgb_type=sRGBColor)
print(lab)
print(type(lab.lab_l))
......
......@@ -119,34 +119,28 @@ class DetectFace:
# Fill image with blue color(set each pixel to blue)
blue[:] = [255, 0, 0]
# extract background by applying inversed_mask
print(inversed_mask.shape)
print(blue.shape)
print(type(self.img))
print(type(blue))
print(mask.shape)
print(self.img.shape)
# extract right eye by applying polygon mask
out2 = np.zeros_like(self.img)
out2[inversed_mask] = blue[inversed_mask]
cv2.imshow("out2", out2)
cv2.waitKey(0)
#cv2.imshow("out2", out2)
#cv2.waitKey(0)
# extract right eye by applying polygon mask
out = np.zeros_like(self.img)
out[mask] = self.img[mask]
#out = out[mask] + blue
cv2.imshow("out", out)
cv2.waitKey(0)
#cv2.imshow("out", out)
#cv2.waitKey(0)
# crop the image
(x, y, w, h) = cv2.boundingRect(pts)
crop1 = out[y:y + h, x:x + w]
crop2 = out2[y:y + h, x:x + w]
crop = cv2.add(crop1,crop2)
cv2.imshow("Image2", crop)
cv2.waitKey(0)
#cv2.imshow("Image2", crop)
#cv2.waitKey(0)
return crop
......
......@@ -98,3 +98,4 @@ class DominantColors:
plt.axis("off")
plt.imshow(chart)
plt.show()
print(" ")
......
......@@ -83,6 +83,4 @@ class ListFromExcel:
temp.append([skin_list[i][s], hair_list[i][s], eye_list[i][s]])
ret.append(temp)
temp = []
for x in ret:
print(x)
return ret
......
......@@ -6,7 +6,7 @@ from getjson import GetJson
import imutils
from colormath.color_objects import LabColor, sRGBColor
from colormath.color_conversions import convert_color
'''
# 이성경(res/lees.jpg) dominant colors by order of histogram
# skin, hair, eye 순서
lsk_rgb = [[222.5, 201.4, 188.9], [138.6, 98.4, 55.0], [159.8, 115.8, 61.7]]
......@@ -59,29 +59,34 @@ r_cheek = df.cheek_img[1]
clusters = 5
lc_dc = DominantColors(l_cheek, clusters)
lc_colors = lc_dc.dominantColors()
print(lc_colors)
print("left cheek")
lc_dc.plotHistogram()
# Create an DominantColors instance on left cheek image
rc_dc = DominantColors(r_cheek, clusters)
rc_colors = rc_dc.dominantColors()
print(rc_colors)
print("right cheek")
rc_dc.plotHistogram()
# Try : Dominant color on right_eye
# Try : Dominant color on left_eye
clusters = 6
dc_le = DominantColors(l_eye, clusters)
colors = dc_le.dominantColors()
print("left eye")
dc_le.plotHistogram()
# Try : Dominant color on right_eye
dc_re = DominantColors(r_eye, clusters)
colors = dc_re.dominantColors()
print(colors)
print("right eye")
dc_re.plotHistogram()
# hair
hair_img = "res/lees_hair.jpg"
img = cv2.imread(hair_img)
resized_img = imutils.resize(img, width = 100)
clusters = 6
dc_re = DominantColors(resized_img, clusters)
colors = dc_re.dominantColors()
print(colors)
dc_re.plotHistogram()
'''
clusters = 5
dc_hair = DominantColors(resized_img, clusters)
colors = dc_hair.dominantColors()
dc_hair.plotHistogram()
......