### Blame view

stim/cuda/bsds500/laplacian_conv2.cpp 1.58 KB
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 #include #include #include #include #define PI 3.1415926 void array_multiply(float* lhs, float rhs, unsigned int N); void array_add(float* ptr1, float* ptr2, float* sum, unsigned int N); void array_abs(float* img, unsigned int N); /// This function evaluates the center-surround(Laplacian of Gaussian) gaussian derivative gradient of an one-channel image /// @param img is the one-channel image /// @param r is an array of radii for different scaled discs(filters) /// @param sigma_n is the number of standard deviations used to define the sigma stim::image Gd_center(stim::image image, int r, unsigned int sigma_n){ unsigned int w = image.width(); // get the width of picture unsigned int h = image.height(); // get the height of picture unsigned N = w * h; // get the number of pixels of picture int winsize = 2 * r + 1; // set the winsdow size of disc(filter) stim::image I(w, h, 1, 2); // allocate space for return image of Gd2 stim::image Ixx(w, h); // allocate space for Ixx stim::image Iyy(w, h); // allocate space for Iyy stim::image Gd_center(w, h); // allocate space for Pb I = Gd2(image, r, sigma_n); // calculate the Ixx, Iyy Ixx = I.channel(0); Iyy = I.channel(1); array_add(Ixx.data(), Iyy.data(), Gd_center.data(), N); //Gd_center = Ixx + Iyy; array_abs(Gd_center.data(), N); //stim::cpu2image(Gd_center.data(), "data_output/Gd_center_0919.bmp", w, h, stim::cmBrewer); return Gd_center; }