91d8912e
David Mayerich
moved bsds500 fil...
|
1
2
3
4
5
6
|
#include <stim/image/image.h>
#include <cmath>
#include <stim/visualization/colormap.h>
#include <stim/image/image_contour_detection.h>
#define PI 3.1415926
|
afb1883d
Tianshu Cheng
fixed problem abo...
|
7
|
#define SIGMA_N 3
|
91d8912e
David Mayerich
moved bsds500 fil...
|
8
9
10
11
12
13
14
15
16
17
18
|
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
|
afb1883d
Tianshu Cheng
fixed problem abo...
|
19
|
stim::image<float> laplacian_conv2(stim::image<float> image, int sigma){
|
91d8912e
David Mayerich
moved bsds500 fil...
|
20
21
22
23
|
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
|
afb1883d
Tianshu Cheng
fixed problem abo...
|
24
25
|
int winsize = 2 * SIGMA_N * sigma + 1; // set the winsdow size of filter
|
91d8912e
David Mayerich
moved bsds500 fil...
|
26
|
|
afb1883d
Tianshu Cheng
fixed problem abo...
|
27
|
stim::image<float> I(w, h, 1, 2); // allocate space for return image of dG2_conv2
|
91d8912e
David Mayerich
moved bsds500 fil...
|
28
29
|
stim::image<float> Ixx(w, h); // allocate space for Ixx
stim::image<float> Iyy(w, h); // allocate space for Iyy
|
afb1883d
Tianshu Cheng
fixed problem abo...
|
30
|
stim::image<float> laplacian(w, h); // allocate space for Pb
|
91d8912e
David Mayerich
moved bsds500 fil...
|
31
|
|
afb1883d
Tianshu Cheng
fixed problem abo...
|
32
|
I = dG2_conv2(image, sigma); // calculate the Ixx, Iyy
|
91d8912e
David Mayerich
moved bsds500 fil...
|
33
34
35
|
Ixx = I.channel(0);
Iyy = I.channel(1);
|
afb1883d
Tianshu Cheng
fixed problem abo...
|
36
37
|
array_add(Ixx.data(), Iyy.data(), laplacian.data(), N); //laplacian = Ixx + Iyy;
array_abs(laplacian.data(), N);
|
91d8912e
David Mayerich
moved bsds500 fil...
|
38
|
|
afb1883d
Tianshu Cheng
fixed problem abo...
|
39
|
//stim::cpu2image(laplacian.data(), "data_output/laplacian_0919.bmp", w, h, stim::cmBrewer);
|
91d8912e
David Mayerich
moved bsds500 fil...
|
40
|
|
afb1883d
Tianshu Cheng
fixed problem abo...
|
41
|
return laplacian;
|
91d8912e
David Mayerich
moved bsds500 fil...
|
42
43
|
}
|