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:
parent
c9e65dc962
commit
1f0cc59037
|
@ -26,7 +26,7 @@ class ComparisonComparison:
|
||||||
|
|
||||||
comp_colors = [white, red, green, blue, black]
|
comp_colors = [white, red, green, blue, black]
|
||||||
|
|
||||||
pallete = PalleteSchema('./palletes/printed_pallete.json')
|
pallete = PalleteSchema('./palletes/colored_pallete.json')
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
row = []
|
row = []
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
canvasWidth=1301
|
|
||||||
canvasHeight=914
|
|
||||||
windowWidth=1301
|
|
||||||
windowHeight=914
|
|
||||||
maxGenerations=50
|
maxGenerations=50
|
||||||
maxParticles=10000
|
|
||||||
minDotSize=2.3
|
minDotSize=2.3
|
||||||
maxDotSize=2.3
|
maxDotSize=2.3
|
||||||
dotSizeFactor=0
|
dotSizeFactor=0
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Posterize:
|
||||||
|
|
||||||
output = None
|
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.image = cv2.imread(image)
|
||||||
(self.h, self.w) = self.image.shape[:2]
|
(self.h, self.w) = self.image.shape[:2]
|
||||||
self.pallete = pallete
|
self.pallete = pallete
|
||||||
|
@ -53,6 +53,7 @@ class Posterize:
|
||||||
self.output = output
|
self.output = output
|
||||||
self.headless = headless
|
self.headless = headless
|
||||||
self.jobs = jobs
|
self.jobs = jobs
|
||||||
|
self.max_particles = particles
|
||||||
|
|
||||||
if not os.path.exists(self.output) :
|
if not os.path.exists(self.output) :
|
||||||
print(f'Output directory {self.output} does not exist, creating...')
|
print(f'Output directory {self.output} does not exist, creating...')
|
||||||
|
@ -177,7 +178,11 @@ class Posterize:
|
||||||
'--outputImage', output_image,
|
'--outputImage', output_image,
|
||||||
'--outputSVG', output_svg,
|
'--outputSVG', output_svg,
|
||||||
'--config', self.conf,
|
'--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({
|
cmds.append({
|
||||||
'cmd' : cmd,
|
'cmd' : cmd,
|
||||||
|
@ -218,6 +223,7 @@ class Posterize:
|
||||||
def preview (self) :
|
def preview (self) :
|
||||||
composite = create_colored_image(self.w, self.h, [255, 255, 255])
|
composite = create_colored_image(self.w, self.h, [255, 255, 255])
|
||||||
for layer in self.previews :
|
for layer in self.previews :
|
||||||
|
print(f'Compositing {layer["layer"]}')
|
||||||
l = cv2.imread(layer['layer'], 0)
|
l = cv2.imread(layer['layer'], 0)
|
||||||
mask = cv2.bitwise_not(l)
|
mask = cv2.bitwise_not(l)
|
||||||
composite[mask > 0] = np.array(convert_color(layer['color'], self.pallete_space, 'BGR'))
|
composite[mask > 0] = np.array(convert_color(layer['color'], self.pallete_space, 'BGR'))
|
||||||
|
|
|
@ -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('output', type=str, help='Output dir to write to')
|
||||||
parser.add_argument('--headless', type=bool, default=False, help='Run script headless')
|
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('-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 :
|
class Separate :
|
||||||
input = ''
|
input = ''
|
||||||
|
@ -30,7 +31,7 @@ class Separate :
|
||||||
print(f'File {args.pallete} does not exist')
|
print(f'File {args.pallete} does not exist')
|
||||||
exit(2)
|
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__" :
|
if __name__ == "__main__" :
|
||||||
|
|
Loading…
Reference in New Issue