#include <stdio.h>
#include <cstdlib>
 
 
    static float h1[] = {1, 1, 1};
    static float h2[] = {-1, 0, 1};
    static array colf(3, 1, h1);
 
    static array rowf(3, 1, h2);
 
 
    
 
    
}
 
    
}
 
    return (in - mn) / (mx - mn);
}
 
    int w = 5;
    if (in.
dims(0) < 512) w = 3;
 
    if (in.
dims(0) > 2048) w = 7;
 
 
    int h = 5;
    if (in.
dims(0) < 512) h = 3;
 
    if (in.
dims(0) > 2048) h = 7;
 
 
 
    switch (method) {
        case 1: prewitt(mag, dir, smooth); break;
        case 2: sobelFilter(mag, dir, smooth); break;
        case 3:
            break;
    }
 
    return normalize(mag);
}
 
void edge() {
 
    array in = 
loadImage(ASSETS_DIR 
"/examples/images/trees_ctm.jpg", 
false);
 
 
    array prewitt     = edge(in, 1);
 
    array sobelFilter = edge(in, 2);
 
 
    myWindow2.setAxesTitles("Bins", "Frequency");
 
    while (!myWindow.close() && !myWindow2.close()) {
        
        myWindow.grid(2, 2);
 
        myWindow(0, 0).image(in / 255, "Input Image");
        myWindow(0, 1).image(prewitt, "Prewitt");
        myWindow(1, 0).image(sobelFilter, "Sobel");
        myWindow(1, 1).image(cny, "Canny");
 
        myWindow.show();
 
        
        myWindow2.hist(hst, 0, 255);
    }
}
 
int main(int argc, char *argv[]) {
    int device = argc > 1 ? atoi(argv[1]) : 0;
 
    try {
 
        printf("** ArrayFire Edge Detection Demo **\n");
        edge();
 
        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.
@ f32
32-bit floating point values
@ AF_CANNY_THRESHOLD_AUTO_OTSU
Determine canny algorithm thresholds using Otsu algorithm.
array atan2(const array &lhs, const array &rhs)
C++ Interface to evaluate the inverse tangent of two arrays.
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 canny(const array &in, const cannyThreshold thresholdType, const float lowThresholdRatio, const float highThresholdRatio, const unsigned sobelWindow=3, const bool isFast=false)
C++ Interface for canny edge detector.
array gaussianKernel(const int rows, const int cols, const double sig_r=0, const double sig_c=0)
C++ Interface for generating gausian kernels.
array histogram(const array &in, const unsigned nbins, const double minval, const double maxval)
C++ Interface for histogram.
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.