Image Builder
Image Builder Objects
image builders follow the Named parameter Idiom and provides additional init parameters. Note that it may fail to fulfill the requirements, so a status code may be queried to check if everything succeeded.
-
struct image_build_params
Structure holding build parameters It is composed of two fields, a border value and an initialization value.
-
template<class I, class From>
class image_builder : protected mln::details::image_builder_base Provides advanced image initialization facilities.
An image builder objects is created when calling the
concretize()
orch_value<T>()
method of images (or the corresponding free functions mln::imconcretize and mln::imchvalue() ).Public Functions
-
image_builder(const From &from, const image_build_params ¶ms)
Create a builder initializing from
from
, overrided byparams
.
-
inline image_builder &set_params(const image_build_params ¶ms)
Override the initialization parameters with those from
params
.
-
inline image_builder &set_border(int border)
Override the initialization border parameter with
border
.
-
template<class SE>
inline image_builder &adjust(const SE &nbh) Override the initialization border parameter to be at least the radial extent of
nbh
. If the radial extent is less than the current border initialization parameter, it has no effet.
-
inline image_builder &set_init_value(image_value_t<I> v)
Override the initialization value parameter with
v
.
-
inline image_builder &get_status(image_build_error_code *err)
Retrieve the error code in the variable pointed by
err
. Ifbuild()
encounters an error, it will be set according to the error type.
-
image_builder(const From &from, const image_build_params ¶ms)
-
template<class To, class From>
class image_resizer : protected mln::details::image_builder_base Provides advanced image resizing facilities.
See image_builder.
Public Functions
-
image_resizer(To &to, const From &from, const image_build_params ¶ms)
Create a builder initializing
to
fromfrom
, overrided byparams
.
-
inline image_resizer &set_params(const image_build_params ¶ms)
Override the initialization parameters with those from
params
.
-
inline image_resizer &set_border(int border)
Override the initialization border parameter with
border
.
-
template<class SE>
inline image_resizer &adjust(const SE &nbh) Override the initialization border parameter to be at least the radial extent of
nbh
. If the radial extent is less than the current border initialization parameter, it has no effet.
-
inline image_resizer &set_init_value(image_value_t<To> v)
Override the initialization value parameter with
v
.
-
inline image_resizer &get_status(image_build_error_code *err)
Retrieve the error code in the variable pointed by
err
. Ifbuild()
encounters an error, it will be set according to the error type.
-
void resize() const
Resize the image.
-
image_resizer(To &to, const From &from, const image_build_params ¶ms)
-
enum mln::image_build_error_code
Error code returned by image_builder or image_resizer.
Values:
-
enumerator IMAGE_BUILD_OK
-
enumerator IMAGE_BUILD_NO_BORDER
-
enumerator IMAGE_BUILD_UNSUPPORTED_SE
-
enumerator IMAGE_BUILD_OK
Free functions
-
template<class I>
auto mln::imconcretize(const I &ref) Return an image builder for a concrete version of
ref
. This is an alias forref.concretize()
.
Usage
This example shows how to create a temporary image with sufficient border to perform a stencil pattern (accessing the neighbors of a point).
auto myfunction(I f)
{
// Try to adjust the border of the image to hold `nbh`
// and initialize this image with the value `42`
mln::image_build_error_code st;
mln::concrete_t<I> g = imconcretize(f).adjust(nbh).set_init_value(42).get_status(st);
if (st == mln::IMAGE_BUILD_OK)
{
mln_foreach(auto p, g.pixels())
for (auto nx : nbh(px))
// Process safely nx
}
else
{
// `g` has not a border large enough to hold the neighborhood.
// You have to check that the access is valid when accessing the neighbors
// of a point.
}
}