Resolves #4; The base configuration for stipple_gen contained a hardcoded width and height. This was forcing the preview image to be generated at an arbitrary size compared to the input image

This commit is contained in:
Matt McWilliams 2023-12-16 09:45:24 -05:00
parent c9e65dc962
commit 1f0cc59037
4 changed files with 11 additions and 9 deletions

View File

@ -26,7 +26,7 @@ class ComparisonComparison:
comp_colors = [white, red, green, blue, black]
pallete = PalleteSchema('./palletes/printed_pallete.json')
pallete = PalleteSchema('./palletes/colored_pallete.json')
i = 0
row = []

View File

@ -1,9 +1,4 @@
canvasWidth=1301
canvasHeight=914
windowWidth=1301
windowHeight=914
maxGenerations=50
maxParticles=10000
minDotSize=2.3
maxDotSize=2.3
dotSizeFactor=0

View File

@ -45,7 +45,7 @@ class Posterize:
output = None
def __init__ (self, image, pallete, n_colors, output, headless, jobs) :
def __init__ (self, image, pallete, n_colors, output, headless, jobs, particles) :
self.image = cv2.imread(image)
(self.h, self.w) = self.image.shape[:2]
self.pallete = pallete
@ -53,6 +53,7 @@ class Posterize:
self.output = output
self.headless = headless
self.jobs = jobs
self.max_particles = particles
if not os.path.exists(self.output) :
print(f'Output directory {self.output} does not exist, creating...')
@ -177,7 +178,11 @@ class Posterize:
'--outputImage', output_image,
'--outputSVG', output_svg,
'--config', self.conf,
'--maxParticles', str(max_particles)
'--maxParticles', str(max_particles),
'--canvasWidth', str(self.w),
'--canvasHeight', str(self.h),
'--windowWidth', str(self.w),
'--windowHeight', str(self.h)
]
cmds.append({
'cmd' : cmd,
@ -218,6 +223,7 @@ class Posterize:
def preview (self) :
composite = create_colored_image(self.w, self.h, [255, 255, 255])
for layer in self.previews :
print(f'Compositing {layer["layer"]}')
l = cv2.imread(layer['layer'], 0)
mask = cv2.bitwise_not(l)
composite[mask > 0] = np.array(convert_color(layer['color'], self.pallete_space, 'BGR'))

View File

@ -11,6 +11,7 @@ parser.add_argument('pallete', type=str, help='Pallete file')
parser.add_argument('output', type=str, help='Output dir to write to')
parser.add_argument('--headless', type=bool, default=False, help='Run script headless')
parser.add_argument('-j', '--jobs', type=int, default=1, help="Number of jobs to run in parallel")
parser.add_argument('-p', '--particles', type=int, default=17000, help="Max particles to use in entire composition")
class Separate :
input = ''
@ -30,7 +31,7 @@ class Separate :
print(f'File {args.pallete} does not exist')
exit(2)
Posterize(self.input, self.pallete, args.colors, args.output, args.headless, args.jobs)
Posterize(self.input, self.pallete, args.colors, args.output, args.headless, args.jobs, args.particles)
if __name__ == "__main__" :