def image_pyramid( impl_params: bool = True, hyper_parameters: Optional[HyperParameters] = None, **image_pyramid_kwargs: Any, ) -> pyramid.OctaveImagePyramid: r"""Image pyramid from :cite:`LW2016`. Args: impl_params: Switch the behavior and hyper-parameters between the reference implementation of the original authors and what is described in the paper. For details see :ref:`here <li_wand_2016-impl_params>`. hyper_parameters: If omitted, :func:`~pystiche_papers.li_wand_2016.hyper_parameters` is used. image_pyramid_kwargs: Additional options. See :class:`~pystiche.pyramid.ImagePyramid` for details. .. seealso:: - :class:`pystiche.pyramid.OctaveImagePyramid` """ if hyper_parameters is None: hyper_parameters = _hyper_parameters(impl_params=impl_params) return pyramid.OctaveImagePyramid( hyper_parameters.image_pyramid.max_edge_size, hyper_parameters.image_pyramid.num_steps, num_levels=hyper_parameters.image_pyramid.num_levels, min_edge_size=hyper_parameters.image_pyramid.min_edge_size, edge=hyper_parameters.image_pyramid.edge, **image_pyramid_kwargs, )
def test_OctaveImagePyramid(): max_edge_size = 16 min_edge_size = 2 image_pyramid = pyramid.OctaveImagePyramid(max_edge_size, 1, min_edge_size=min_edge_size) assert len(image_pyramid) == 4 for idx in range(len(image_pyramid)): actual = image_pyramid[idx].edge_size desired = 2**(idx + 1) assert actual == desired
def test_OctaveImagePyramid(self): max_edge_size = 16 min_edge_size = 2 image_pyramid = pyramid.OctaveImagePyramid( max_edge_size, 1, min_edge_size=min_edge_size ) self.assertEqual(len(image_pyramid), 4) for idx in range(len(image_pyramid)): actual = image_pyramid[idx].edge_size desired = 2 ** (idx + 1) self.assertEqual(actual, desired)
def test_OctaveImagePyramid_num_levels(self): max_edge_size = 16 num_levels = 3 min_edge_size = 2 image_pyramid = pyramid.OctaveImagePyramid( max_edge_size, 1, num_levels=num_levels, min_edge_size=min_edge_size ) self.assertEqual(len(image_pyramid), 3) for idx in range(len(image_pyramid)): actual = image_pyramid[idx].edge_size desired = 2 ** (idx + 2) self.assertEqual(actual, desired)
def test_num_levels(self): max_edge_size = 16 num_levels = 3 min_edge_size = 2 image_pyramid = pyramid.OctaveImagePyramid( max_edge_size, 1, num_levels=num_levels, min_edge_size=min_edge_size ) assert len(image_pyramid) == 3 for idx in range(len(image_pyramid)): actual = image_pyramid[idx].edge_size desired = 2 ** (idx + 2) assert actual == desired