#include <stdio.h>
#include <cstdlib>
 
 
static const unsigned ITERS = 64;
 
    return (p_in - mn) / (mx - mn);
}
 
    int w = 5;
    if (p_in.
dims(0) < 512) w = 3;
 
    if (p_in.
dims(0) > 2048) w = 7;
 
 
    int h = 5;
    if (p_in.
dims(0) < 512) h = 3;
 
    if (p_in.
dims(0) > 2048) h = 7;
 
 
 
    for (
unsigned i = 1; i < ITERS; ++i) smooth = 
convolve(smooth, ker);
 
 
    sobel(Gx, Gy, smooth, 3);
 
 
    return normalize(
hypot(Gx, Gy));
 
}
 
array in, edges, smoothed;
 
 
void anisotropicSmoothing() {
}
 
int main(int argc, char *argv[]) {
    int device = argc > 1 ? atoi(argv[1]) : 0;
 
    try {
 
        printf("** ArrayFire Gradient Anisotropic Smoothing Demo **\n");
 
        Window myWindow(
"Gradient Anisotropic Smoothing");
 
 
        in = 
loadImage(ASSETS_DIR 
"/examples/images/man.jpg", 
false);
 
        array sEdges = sobelFilter(in);
 
 
        anisotropicSmoothing();
 
        sobel(Gx, Gy, smoothed, 3);
 
 
        edges = normalize(
hypot(Gx, Gy));
 
        while (!myWindow.close()) {
            myWindow.grid(2, 2);
 
            myWindow(0, 0).image(in / 255.0f, "Input Image");
            myWindow(0, 1).image(normalize(smoothed),
                                 "Anisotropically smooted Input");
            myWindow(1, 0).image(normalize(sEdges),
                                 "Gradient Magnitude after gaussian blur t=64");
            myWindow(1, 1).image(normalize(edges),
                                 "Gradient Magnitude after diffusion t=64");
 
            myWindow.show();
        }
 
        printf(
            "\nAnisotropic Diffusion avg runtime for current image in Seconds: "
            "%g\n",
            timeit(anisotropicSmoothing));
 
 
        fprintf(stderr, 
"%s\n", e.
what());
        throw;
    }
 
    return 0;
}
Window object to render af::arrays.
A multi dimensional data container.
dim4 dims() const
Get dimensions of the array.
An ArrayFire exception class.
virtual const char * what() const
Returns an error message for the exception in a string format.
array hypot(const array &lhs, const array &rhs)
C++ Interface to calculate the length of the hypotenuse of two inputs.
void setDevice(const int device)
Sets the current device.
array anisotropicDiffusion(const af::array &in, const float timestep, const float conductance, const unsigned iterations, const fluxFunction fftype=AF_FLUX_EXPONENTIAL, const diffusionEq diffusionKind=AF_DIFFUSION_GRAD)
C++ Interface for gradient anisotropic(non-linear diffusion) smoothing.
array gaussianKernel(const int rows, const int cols, const double sig_r=0, const double sig_c=0)
C++ Interface for generating gausian kernels.
void sobel(array &dx, array &dy, const array &img, const unsigned ker_size=3)
C++ Interface for extracting sobel gradients.
array loadImage(const char *filename, const bool is_color=false)
C++ Interface for loading an image.
array max(const array &in, const int dim=-1)
C++ Interface to return the maximum along a given dimension.
array min(const array &in, const int dim=-1)
C++ Interface to return the minimum along a given dimension.
array convolve(const array &signal, const array &filter, const convMode mode=AF_CONV_DEFAULT, const convDomain domain=AF_CONV_AUTO)
C++ Interface for convolution any(one through three) dimensional signals.
double timeit(void(*fn)())