def _get_window_size(offset, step_size, image_size):
    """
    Calculate window width or height.
    Usually same as block size, except when at the end of image and only a
    fracture of block size remains
    :param offset: start columns/ row
    :param step_size: block width/ height
    :param image_size: image width/ height
    :return: window width/ height
    """
    if offset + step_size > image_size:
        return image_size - offset
    else:
        return step_size
