feat 处理多层sketch design出现的内搭越界问题
fix
This commit is contained in:
@@ -65,8 +65,12 @@ def synthesis(data, size):
|
||||
try:
|
||||
|
||||
all_mask_shape = (size[1], size[0])
|
||||
top_outer_mask = np.zeros(all_mask_shape, dtype=np.uint8)
|
||||
bottom_outer_mask = np.zeros(all_mask_shape, dtype=np.uint8)
|
||||
body_mask = None
|
||||
for d in data:
|
||||
if d['name'] == 'body':
|
||||
body_mask = d['image'].split()[3]
|
||||
top_outer_mask = np.array(body_mask)
|
||||
bottom_outer_mask = np.array(body_mask)
|
||||
|
||||
top = True
|
||||
bottom = True
|
||||
@@ -101,10 +105,10 @@ def synthesis(data, size):
|
||||
if layer['name'] != "body":
|
||||
test_image = Image.new('RGBA', size, (0, 0, 0, 0))
|
||||
test_image.paste(layer['image'], (layer['position'][1], layer['position'][0]), layer['image'])
|
||||
# mask_data = np.where(all_mask > 0, 255, 0).astype(np.uint8)
|
||||
# mask_alpha = Image.fromarray(mask_data)
|
||||
# cropped_image = Image.composite(test_image, Image.new("RGBA", test_image.size, (255, 255, 255, 0)), mask_alpha)
|
||||
base_image.paste(test_image, (0, 0), test_image)
|
||||
mask_data = np.where(all_mask > 0, 255, 0).astype(np.uint8)
|
||||
mask_alpha = Image.fromarray(mask_data)
|
||||
cropped_image = Image.composite(test_image, Image.new("RGBA", test_image.size, (255, 255, 255, 0)), mask_alpha)
|
||||
base_image.paste(test_image, (0, 0), cropped_image)
|
||||
else:
|
||||
base_image.paste(layer['image'], (layer['position'][1], layer['position'][0]), layer['image'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user