Fixed output paths for stipple_gen command

This commit is contained in:
Matt McWilliams 2023-11-29 18:33:02 -05:00
parent 7fd2dc0793
commit 08a47465c5
1 changed files with 5 additions and 10 deletions

View File

@ -16,7 +16,6 @@ class Posterize:
pallete = None pallete = None
pallete_space = 'BGR' pallete_space = 'BGR'
comparison_space = 'BGR' comparison_space = 'BGR'
image = None image = None
@ -91,7 +90,7 @@ class Posterize:
for i in range(self.n_colors) : for i in range(self.n_colors) :
if list_match(self.original_colors[i], white) : if list_match(self.original_colors[i], white) :
continue continue
original = self.original_colors[i] #BGR original = self.original_colors[i]
mask = self.extract_color_mask(self.image, original) mask = self.extract_color_mask(self.image, original)
original_normalized = convert_color(original, 'BGR', self.pallete_space) original_normalized = convert_color(original, 'BGR', self.pallete_space)
if self.pallete_space == 'RGB' or self.pallete_space == 'BGR' : if self.pallete_space == 'RGB' or self.pallete_space == 'BGR' :
@ -108,9 +107,6 @@ class Posterize:
'color' : closest, 'color' : closest,
'space' : self.pallete_space 'space' : self.pallete_space
}) })
#color_mat = create_colored_image(self.w, self.h, closest)
#color_mask = cv2.bitwise_or(color_mat, color_mat, mask = (255-mask))
#color_mask = cv2.inRange(mask, np.array([0, 0, 0]), np.array([1, 1, 1]))
mask = cv2.bitwise_not(mask) mask = cv2.bitwise_not(mask)
composite[mask > 0] = np.array(closest) composite[mask > 0] = np.array(closest)
@ -143,9 +139,8 @@ class Posterize:
ratio = black/total ratio = black/total
max_particles = round(ratio * self.max_particles) max_particles = round(ratio * self.max_particles)
input_image = os.path.abspath(layer['layer']) input_image = os.path.abspath(layer['layer'])
file_name, dir_name = os.path.split(input_image) dir_name, file_name = os.path.split(input_image)
file_part, ext = os.path.splitext(file_name) file_part, ext = os.path.splitext(file_name)
output_image = os.path.join(dir_name, f'{file_part}_preview.png') output_image = os.path.join(dir_name, f'{file_part}_preview.png')
output_svg = os.path.join(dir_name, f'{file_part}.svg') output_svg = os.path.join(dir_name, f'{file_part}.svg')
cmd = [ cmd = [
@ -158,11 +153,11 @@ class Posterize:
'--maxParticles', str(max_particles) '--maxParticles', str(max_particles)
] ]
print(cmd) print(cmd)
#subprocess.call(cmd, cwd = self.stipple_gen) subprocess.call(cmd, cwd = self.stipple_gen)
self.previews.append(output_image) self.previews.append(output_image)
def preview (self) : def preview (self) :
#composite = create_colored_image(self.w, self.h, [255, 255, 255])
print(self.previews)