Skip to content

Commit

Permalink
Add classic version
Browse files Browse the repository at this point in the history
  • Loading branch information
simmplecoder committed Jul 6, 2020
1 parent fcc7e4a commit 2c26fb5
Showing 1 changed file with 52 additions and 16 deletions.
68 changes: 52 additions & 16 deletions include/boost/gil/image_processing/diffusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,37 +219,73 @@ struct identity

} // namespace brightness_function

enum class matlab_connectivity {
enum class matlab_connectivity
{
minimal,
maximal
};

enum class matlab_conduction_method {
enum class matlab_conduction_method
{
exponential,
quadratic
};

template <typename InputView, typename OutputView>
void classic_anisotropic_diffusion(const InputView& input, const OutputView& output,
unsigned int num_iter, double kappa)
{
anisotropic_diffusion(input, output, num_iter, laplace_function::stencil_4points{},
brightness_function::identity{},
diffusion::perona_malik_diffusivity{kappa});
}

template <typename InputView, typename OutputView>
void matlab_anisotropic_diffusion(const InputView& input, const OutputView& output,
unsigned int num_iter, double kappa, matlab_connectivity connectivity, matlab_conduction_method conduction_method)
unsigned int num_iter, double kappa,
matlab_connectivity connectivity,
matlab_conduction_method conduction_method)
{
if (connectivity == matlab_connectivity::minimal) {
if (conduction_method == matlab_conduction_method::exponential) {
anisotropic_diffusion(input, output, num_iter, laplace_function::stencil_4points{}, brightness_function::identity{}, diffusion::gaussian_diffusivity{kappa});
} else if (conduction_method == matlab_conduction_method::quadratic) {
anisotropic_diffusion(input, output, num_iter, laplace_function::stencil_4points{}, brightness_function::identity{}, diffusion::gaussian_diffusivity{kappa});
} else {
if (connectivity == matlab_connectivity::minimal)
{
if (conduction_method == matlab_conduction_method::exponential)
{
anisotropic_diffusion(input, output, num_iter, laplace_function::stencil_4points{},
brightness_function::identity{},
diffusion::gaussian_diffusivity{kappa});
}
else if (conduction_method == matlab_conduction_method::quadratic)
{
anisotropic_diffusion(input, output, num_iter, laplace_function::stencil_4points{},
brightness_function::identity{},
diffusion::gaussian_diffusivity{kappa});
}
else
{
throw std::logic_error("unhandled conduction method found");
}
} else if (connectivity == matlab_connectivity::maximal) {
if (conduction_method == matlab_conduction_method::exponential) {
anisotropic_diffusion(input, output, num_iter, laplace_function::stencil_4points{}, brightness_function::identity{}, diffusion::gaussian_diffusivity{kappa});
} else if (conduction_method == matlab_conduction_method::quadratic) {
anisotropic_diffusion(input, output, num_iter, laplace_function::stencil_4points{}, brightness_function::identity{}, diffusion::gaussian_diffusivity{kappa});
} else {
}
else if (connectivity == matlab_connectivity::maximal)
{
if (conduction_method == matlab_conduction_method::exponential)
{
anisotropic_diffusion(input, output, num_iter, laplace_function::stencil_4points{},
brightness_function::identity{},
diffusion::gaussian_diffusivity{kappa});
}
else if (conduction_method == matlab_conduction_method::quadratic)
{
anisotropic_diffusion(input, output, num_iter, laplace_function::stencil_4points{},
brightness_function::identity{},
diffusion::gaussian_diffusivity{kappa});
}
else
{
throw std::logic_error("unhandled conduction method found");
}
} else {
}
else
{
throw std::logic_error("unhandled connectivity found");
}
}
Expand Down

0 comments on commit 2c26fb5

Please sign in to comment.