Skip to content

window function normalization #6

Closed
@renerichter

Description

Hiho,
thank you for this awesome project. I played a bit around with it and tried all tiling and windowing options, but it seems to me that in the stitched image the windowing functions do not sum up to 1 (=100%), but to 0. I tested it with the following code:

import numpy as np
from tiler import Tiler, Merger
import matplotlib.pyplot as plt
imsize = 64
im = np.reshape(np.arange(imsize*imsize),[imsize,imsize])
batch_size = 10
overlap = 5
tiler_mode = 'wrap'
windows_supported = ['boxcar', 'triang', 'blackman', 'hamming', 'hann', 'bartlett', 'flattop', 'parzen', 'bohman', 'blackmanharris', 'nuttall', 'barthann', 'overlap-tile']
tiler = Tiler(data_shape=im.shape,
                tile_shape=(16,16),
                channel_dimension=None,overlap=overlap,mode=tiler_mode,constant_value=1.0)
#Tiler.TILING_MODES == ['constant', 'drop', 'irregular', 'reflect', 'edge', 'wrap']
tiles_in_batches = [batch for _, batch in tiler(im, batch_size=batch_size)]
merged_images = []

for mwin in windows_supported:
    merger = Merger(tiler,window=mwin)
    #Merger.SUPPORTED_WINDOWS == ['boxcar', 'triang', 'blackman', 'hamming', 'hann', 'bartlett', 'flattop', 'parzen', 'bohman', 'blackmanharris', 'nuttall', 'barthann', 'overlap-tile']
    
    for batch_id, batch in enumerate(tiles_in_batches):
        merger.add_batch(batch_id, batch_size, batch)

    imf = merger.merge(unpad=True,argmax=False)
    merged_images.append(imf)
merged_images = np.array(merged_images)
fig,ax = plt.subplots(nrows=4,ncols=4,figsize=[14,14])
axm = ax.flatten()
for m,mim in enumerate(merged_images): 
    ima = axm[m].imshow(mim)
axm[m+1].imshow(im)
plt.show() 

which results in

tiling_test

where the last image is the original (to-be-tiled and merged) image and the others are the different merges from all possible merging options.

What am I doing wrong here?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions