Unverified Commit 5a517402 authored by tilman's avatar tilman
Browse files

final results from tuesday with new parameters

parent 21257951
......@@ -32,7 +32,7 @@ OVERLAY_ALPHA = 0.2
COLORED_CANVAS = True
BISEC_SKIP_LOWER_LEVELS = False
DISPLAY_RASTER_ELEMENTS = 500
KMEANS_AREA_MASK_THRESHOLD = 0.08 #max 1.0 (percent of pixels), cur 0.09, sonntag mittag 0.05, #smaller threshold -> more colors, higher threshold -> less colors
KMEANS_AREA_MASK_THRESHOLD = 0.08 #0.08 #max 1.0 (percent of pixels), cur 0.09, sonntag mittag 0.05, #smaller threshold -> more colors, higher threshold -> less colors
KMEANS_K = 7 #10
#KMEANS_K = 6 #10
OUT_DIR = 'images/out/images_imdahl/kmeans_output_canvas/final'
......@@ -78,8 +78,8 @@ images_bdcn.sort()
os.chdir(OUT_DIR) #save images in this dir
#for img_name in images:
# for img_name, img_bdcn in list(zip(images, images_bdcn)):
# for img_name, img_bdcn in list(zip(images, images_bdcn))[16:17]:
for img_name, img_bdcn in (list(zip(images, images_bdcn))[15:16] if SKIP_OPENPOSE else list(zip(images, images_bdcn))): #jesus
for img_name, img_bdcn in list(zip(images, images_bdcn))[0:1]:
# for img_name, img_bdcn in (list(zip(images, images_bdcn))[15:16] if SKIP_OPENPOSE else list(zip(images, images_bdcn))): #jesus
# for img_name, img_bdcn in list(zip(images, images_bdcn))[6:7]: #fusswaschung
# Process Image
print("calculating: "+img_name)
......@@ -125,12 +125,12 @@ for img_name, img_bdcn in (list(zip(images, images_bdcn))[15:16] if SKIP_OPENPOS
convexhull = Polygon(pose).convex_hull
#inpainting
# sconvexhull = affinity.scale(convexhull, xfact=1.5, yfact=1.7, origin=convexhull.centroid)
sconvexhull = affinity.scale(convexhull, xfact=1.3, yfact=1.6, origin=convexhull.centroid)
sconvexhull = affinity.scale(convexhull, xfact=1.7, yfact=1.4, origin=convexhull.centroid)
cv2.drawContours(mask, [polyToArr(sconvexhull)], 0, 255, int(15*esz))
cv2.drawContours(mask, [polyToArr(sconvexhull)], 0, 255, -1)
#kmeans check
sconvexhull = affinity.scale(convexhull, xfact=0.7, yfact=0.7, origin=convexhull.centroid)
sconvexhull = affinity.scale(convexhull, xfact=1, yfact=0.5, origin=convexhull.centroid)
cv2.drawContours(kmout_mask, [polyToArr(sconvexhull)], 0, 255, int(7*esz))
cv2.drawContours(kmout_mask, [polyToArr(sconvexhull)], 0, 255, -1)
cv2.rectangle(mask, (0,0), (len(img[0]),len(img)), 255, int(40*esz)) #remove frames
......@@ -156,14 +156,16 @@ for img_name, img_bdcn in (list(zip(images, images_bdcn))[15:16] if SKIP_OPENPOS
km_mask_colors, km_mask_counts = np.unique(km_mask_out.reshape(-1, km_mask_out.shape[-1]),axis=0,return_counts=True)
mask_colors, mask_counts = np.unique(kmout_mask.reshape(-1, kmout_mask.shape[-1]),axis=0,return_counts=True)
threshold_count = int(KMEANS_AREA_MASK_THRESHOLD*mask_counts[(np.argwhere(mask_colors>0))[0,0]]) #select counts from white color and generate threshold with it.
white_pixels = mask_counts[(np.argwhere(mask_colors>0))[0,0]]
threshold_count = int(KMEANS_AREA_MASK_THRESHOLD*white_pixels) #select counts from white color and generate threshold with it.
print("white_pixels",white_pixels,"threshold_count",threshold_count)
kmeans_colors = kmeans_colors[kmeans_counts.argsort()][::-1] # sort kmeans_counts by count
kmeans_counts = kmeans_counts[kmeans_counts.argsort()][::-1] # sort kmeans_counts by count
km_mask_colors = km_mask_colors[km_mask_counts.argsort()][::-1] # sort mask colors by count
km_mask_counts = km_mask_counts[km_mask_counts.argsort()][::-1] # sort mask counts by count
print("km_mask_colors",km_mask_colors,"km_mask_counts",km_mask_counts)
filtered_km_mask_FG_colors = km_mask_colors[np.argwhere(km_mask_counts>=threshold_count)]
filtered_km_mask_FG_colors = filtered_km_mask_FG_colors[np.sum(filtered_km_mask_FG_colors, axis=2)>0] #filter out black from mask
......@@ -389,9 +391,10 @@ for img_name, img_bdcn in (list(zip(images, images_bdcn))[15:16] if SKIP_OPENPOS
cv2.arrowedLine(output_canvas, trp(bisecVector[1]), trp(bisecVector[0]), (0,0,255), int(4*esz))
if SAVE_FILE:
cv2.imwrite(os.path.basename(img_name),img)
#cv2.imwrite(os.path.basename(img_name),img)
if COLORED_CANVAS:
cv2.imwrite(os.path.basename(img_bdcn)+'_final_colored_canvas.jpg',output_canvas)
print("saved _final_colored_canvas")
else:
cv2.imwrite(os.path.basename(img_bdcn)+'_final_binary_canvas.jpg',output_canvas)
if SHOW_WINDOW:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment