diff --git a/fun_mPb_theta.cpp b/fun_mPb_theta.cpp index 91ec90d..532e74c 100644 --- a/fun_mPb_theta.cpp +++ b/fun_mPb_theta.cpp @@ -1,36 +1,45 @@ #include #include -#include +//#include #include #include void array_multiply(float* lhs, float rhs, unsigned int N); void array_add(float* ptr1, float* ptr2, float* sum, unsigned int N); +/// This function evaluates the theta-dependent gradient image given an input image + +/// @param lab is the 3-channel image in the LAB color space +/// @param theta is the angle used for computing the gradient + stim::image func_mPb_theta(stim::image lab, float theta, unsigned int w, unsigned int h){ + //allocate space for the gradient image stim::image mPb_theta(w, h, 1); + //allocate space for each individual channel stim::image pic_light, pic_colora, pic_colorb; pic_light = lab.channel(0); pic_colora = lab.channel(1); pic_colorb = lab.channel(2); - unsigned int N = w * h; - float sigma = 2; - unsigned int sigma_n = 3; - unsigned r1 = 3; + unsigned int N = w * h; //calculate the number of pixels in the image + float sigma = 2; //set the sigma value to \sigma = 2 + unsigned int sigma_n = 3; //set the number of standard deviations used to define the kernel size + unsigned r1 = 3; //disk radii unsigned r2 = 5; unsigned r3 = 10; unsigned r4 = 20; - float alpha[9] = {1,1,1,1,1,1,1,1,1}; + float alpha[9] = {1,1,1,1,1,1,1,1,1}; //weighting for each channel stim::image l1,l2,l3,a1,a2,a3,b1,b2,b3; l1 = gaussian_derivative_filter_odd(pic_light, sigma, sigma_n, r3 * 2, theta, w, h); stim::cpu2image(l1.data(), "data_output/testl_tex5.bmp", w, h, stim::cmBrewer); - l2 = gaussian_derivative_filter_odd(pic_light, sigma, sigma_n, r2 * 2, theta, w, h); + + exit(0); + /*l2 = gaussian_derivative_filter_odd(pic_light, sigma, sigma_n, r2 * 2, theta, w, h); stim::cpu2image(l2.data(), "data_output/l2_tex.bmp", w, h, stim::cmBrewer); l3 = gaussian_derivative_filter_odd(pic_light, sigma, sigma_n, r3 * 2, theta, w, h); stim::cpu2image(l3.data(), "data_output/l3_tex.bmp", w, h, stim::cmBrewer); @@ -45,7 +54,7 @@ stim::image func_mPb_theta(stim::image lab, float theta, unsigned b2 = gaussian_derivative_filter_odd(pic_colorb, sigma, sigma_n, r3 * 2, theta, w, h); stim::cpu2image(b2.data(), "data_output/b2_tex.bmp", w, h, stim::cmBrewer); b3 = gaussian_derivative_filter_odd(pic_colorb, sigma, sigma_n, r4 * 2, theta, w, h); - stim::cpu2image(b3.data(), "data_output/b3_tex.bmp", w, h, stim::cmBrewer); + stim::cpu2image(b3.data(), "data_output/b3_tex.bmp", w, h, stim::cmBrewer);*/ /*for (unsigned i = 0; i func_mPb_theta(stim::image lab, float theta, unsigned //getch(); return mPb_theta; -} \ No newline at end of file +} diff --git a/func_mPb.cpp b/func_mPb.cpp index 43860fd..33af26b 100644 --- a/func_mPb.cpp +++ b/func_mPb.cpp @@ -1,6 +1,6 @@ #include #include -#include +//#include #include #include #include @@ -62,7 +62,7 @@ stim::image func_mPb(stim::image lab, unsigned int theta_n, unsign double duration2 = ( std::clock() - start ) / (double) CLOCKS_PER_SEC; std::cout<<"total time:"<< duration2 <<"s"<<'\n'; - getch(); + //getch(); return mPb; @@ -132,4 +132,4 @@ stim::image func_mPb(stim::image lab, unsigned int theta_n, unsign -} \ No newline at end of file +} diff --git a/gauss_derivative_odd.cpp b/gauss_derivative_odd.cpp index 1eec4f4..6fe8de7 100644 --- a/gauss_derivative_odd.cpp +++ b/gauss_derivative_odd.cpp @@ -12,13 +12,14 @@ void array_multiply(float* lhs, float rhs, unsigned int N); // winsize = 2 * r, side of mask = winsize + 1 stim::image gaussian_derivative_filter_odd(stim::image image, float sigma, unsigned int sigma_n, unsigned int winsize, float theta, unsigned int w, unsigned int h){ - stim::image mask_x(winsize+1, winsize+1), mask_y(winsize+1, winsize+1), mask_theta(winsize+1, winsize+1), mask_test(winsize+1, winsize+1, 1), derivative_x, derivative_y, derivative_theta(w, h); + stim::image mask_x(winsize+1, winsize+1), mask_y(winsize+1, winsize+1), mask_theta(winsize+1, winsize+1), mask_delta(winsize+1, winsize+1, 1), derivative_x, derivative_y, derivative_theta(w, h); //float* ptr = mask_x.data(); - memset ( mask_test.data(), 0, mask_test.size() * sizeof(float)); - mask_test.data()[winsize*(winsize+2)/2] = 1; - stim::cpu2image(mask_test.data(), "data_output/mask_test.bmp", winsize+1, winsize+1, stim::cmBrewer); + //DEBUG calculate a Dirac delta function kernel + memset ( mask_delta.data(), 0, mask_delta.size() * sizeof(float)); + mask_delta.data()[winsize*(winsize+2)/2] = 1; + stim::cpu2image(mask_delta.data(), "data_output/mask_test.bmp", winsize+1, winsize+1, stim::cmBrewer); // set parameters @@ -53,9 +54,9 @@ stim::image gaussian_derivative_filter_odd(stim::image image, floa // 2D convolution //derivative_theta = image.convolve2(mask_theta); //stim::cpu2image(derivative_theta.data(), "data_output/derivative_theta1.bmp", w, h, stim::cmBrewer); - //conv2(image.data(), mask_test.data(), derivative_theta.data(), w, h, winsize+1); - conv2(image.data(), mask_theta.data(), derivative_theta.data(), w, h, winsize+1); - //stim::cpu2image(derivative_theta.data(), "data_output/derivative_theta_tex1.bmp", w, h, stim::cmBrewer); + conv2(image.data(), mask_delta.data(), derivative_theta.data(), w, h, winsize+1); + //conv2(image.data(), mask_theta.data(), derivative_theta.data(), w, h, winsize+1); + stim::cpu2image(derivative_theta.data(), "data_output/derivative_theta_tex1.bmp", w, h, stim::cmBrewer); //array_abs(derivative_theta.data(), N); @@ -85,4 +86,4 @@ stim::image gaussian_derivative_filter_odd(stim::image image, floa return derivative_theta; -} \ No newline at end of file +} diff --git a/test_main.cpp b/test_main.cpp index d40e81c..a8451ac 100644 --- a/test_main.cpp +++ b/test_main.cpp @@ -5,7 +5,7 @@ #include -void main() +int main() { stim::image rgb,gaussgradient; //generate an image object @@ -51,6 +51,6 @@ void main() stim::image mPb; mPb = func_mPb(lab, theta_n, w, h); - + return 0; -} \ No newline at end of file +} -- libgit2 0.21.4