Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int no_iteration = 20;
- const float rho = 0.15;
- const float lambda = 0.1;
- float Conductance(int y, int x, int ty, int tx);
- for (int i = 0; i < no_iteration; i++)
- {
- for(int y = 1; y < src->rows - 1; y++)
- {
- for(int x = 1; x < src->cols - 1; x++)
- {
- float a, b, c, d, e;
- a = AnisotropicDiffusion::Conductance(y, x, -1, 0);
- b = AnisotropicDiffusion::Conductance(y, x, 1, 0);
- c = AnisotropicDiffusion::Conductance(y, x, 0, -1);
- d = AnisotropicDiffusion::Conductance(y, x, 0, 1);
- e = a + b + c + d;
- output.at<float>(y,x) = output.at<float>(y,x) + lambda *(e);
- }
- }
- }
- float AnisotropicDiffusion::Conductance(int y, int x, int ty, int tx)
- {
- float a = output.at<float>(y + ty, x + tx);
- float b = output.at<float>(y, x);
- float c = abs(a - b);
- float d = powf(c,2) / powf(rho, 2);
- float e = exp(-d);
- float f = e*(output.at<float>(y+ty, x+tx) - output.at<float>(y,x));
- return f;
- }
Advertisement
Add Comment
Please, Sign In to add comment