laplacian_conv2.cuh 1.7 KB

#include <stim/image/image.h>
#include <cmath>
#include <stim/visualization/colormap.h>
//#include <stim/image/image_contour_detection.h>

#define PI 3.1415926
#define SIGMA_N 3

//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<float> laplacian_conv2(stim::image<float> image, int sigma){

	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 * SIGMA_N * sigma + 1;           // set the winsdow size of filter

	stim::image<float> I(w, h, 1, 2);       // allocate space for return image of dG2_conv2
	stim::image<float> Ixx(w, h);       // allocate space for Ixx
	stim::image<float> Iyy(w, h);       // allocate space for Iyy
	stim::image<float> laplacian(w, h);       // allocate space for Pb

	I = dG2_conv2(image, sigma);  // calculate the Ixx, Iyy
	Ixx =;
	Iyy =;

	array_add(,,, N);				//laplacian = Ixx + Iyy;
	array_abs(, N);

	//stim::cpu2image(, "data_output/laplacian_0919.bmp", w, h, stim::cmBrewer); 

	return laplacian;