#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);
 
    
    
}
{
    
}
{
    float mx = max<float>(in);
    float mn = min<float>(in);
    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;
    }
    return normalize(mag);
}
void edge(bool console)
{
    array in = 
loadImage(ASSETS_DIR 
"/examples/images/trees_ctm.jpg", 
false);
 
    array prewitt = edge(in, 1);
 
    array sobelFilter   = edge(in, 2);
 
    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.show();
        
        myWindow2.hist(hst, 0, 255);
    }
}
int main(int argc, char* argv[])
{
    int device = argc > 1 ? atoi(argv[1]) : 0;
    bool console = argc > 2 ? argv[2][0] == '-' : false;
    try {
        printf("** ArrayFire Edge Detection Demo **\n");
        edge(console);
        fprintf(stderr, 
"%s\n", e.
what());
        throw;
    }
    return 0;
}