1
0
Fork 0
This commit is contained in:
HoopyFreud 2023-07-08 21:30:54 -04:00
parent 80e124554d
commit 3fbf9baae6
1 changed files with 16 additions and 21 deletions

View File

@ -232,18 +232,18 @@ def process_tile_spiral(
**kwargs,
) -> Image.Image:
width, height = kwargs.get("size", source.size if source else None)
tiles: List[Tuple[int, int, Image.Image]] = []
# tile tuples is source, multiply by scale for dest
counter = 0
tile_coords = generate_tile_spiral(width, height, tile, overlap=overlap)
if len(tile_coords) == 1:
single_tile = True
else:
single_tile = False
for left, top in tile_coords:
counter += 1
logger.info(
@ -268,26 +268,24 @@ def process_tile_spiral(
if bottom > height:
needs_margin = True
bottom_margin = height - bottom
#if no source given, we don't have a source image
# if no source given, we don't have a source image
if not source:
tile_image = None
elif needs_margin:
#in the special case where the image is smaller than the specified tile size, just use the image
# in the special case where the image is smaller than the specified tile size, just use the image
if single_tile:
logger.debug("creating and processing single-tile subtile")
tile_image = source
#otherwise use add histogram noise outside of the image border
# otherwise use add histogram noise outside of the image border
else:
logger.debug("tiling and adding margin")
base_image = (
source.crop(
(
left + left_margin,
top + top_margin,
right - right_margin,
bottom - bottom_margin,
)
base_image = source.crop(
(
left + left_margin,
top + top_margin,
right - right_margin,
bottom - bottom_margin,
)
)
tile_image = noise_source_histogram(base_image, (tile, tile), (0, 0))
@ -300,7 +298,7 @@ def process_tile_spiral(
tile_image = image_filter(tile_image, (left, top, tile))
tiles.append((left, top, tile_image))
if single_tile:
return tile_image
else:
@ -354,11 +352,8 @@ def generate_tile_spiral(
# calculate the start position of the tiling
span_x = tile + (width_tile_target - 1) * tile_increment
span_y = tile + (height_tile_target - 1) * tile_increment
logger.debug(
"tiled image overlap: %s. Span: %s x %s",
overlap,span_x,span_y
)
logger.debug("tiled image overlap: %s. Span: %s x %s", overlap, span_x, span_y)
tile_left = (
width - span_x