Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
f0598993
Commit
f0598993
authored
Sep 24, 2012
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug in nln (out of border access)
parent
dffba485
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
19 deletions
+46
-19
nlm.cu
modules/gpu/src/cuda/nlm.cu
+46
-19
No files found.
modules/gpu/src/cuda/nlm.cu
View file @
f0598993
...
...
@@ -53,7 +53,7 @@ typedef unsigned char uchar;
typedef unsigned short ushort;
//////////////////////////////////////////////////////////////////////////////////
///
Non local means denosings
///
/ Non Local Means Denosing
namespace cv { namespace gpu { namespace device
{
...
...
@@ -80,24 +80,51 @@ namespace cv { namespace gpu { namespace device
value_type sum1 = VecTraits<value_type>::all(0);
float sum2 = 0.f;
for(float cy = -search_radius; cy <= search_radius; ++cy)
for(float cx = -search_radius; cx <= search_radius; ++cx)
{
float color2 = 0;
for(float by = -block_radius; by <= block_radius; ++by)
for(float bx = -block_radius; bx <= block_radius; ++bx)
{
value_type v1 = saturate_cast<value_type>(src(y + by, x + bx));
value_type v2 = saturate_cast<value_type>(src(y + cy + by, x + cx + bx));
color2 += norm2(v1 - v2);
}
float dist2 = cx * cx + cy * cy;
float w = __expf(color2 * h2_inv_half + dist2 * block_radius2_inv);
sum1 = sum1 + saturate_cast<value_type>(src(y + cy, x + cy)) * w;
sum2 += w;
}
if (x - search_radius - block_radius >=0 && y - search_radius - block_radius >=0 &&
x + search_radius + block_radius < src.cols && y + search_radius + block_radius < src.rows)
{
for(float cy = -search_radius; cy <= search_radius; ++cy)
for(float cx = -search_radius; cx <= search_radius; ++cx)
{
float color2 = 0;
for(float by = -block_radius; by <= block_radius; ++by)
for(float bx = -block_radius; bx <= block_radius; ++bx)
{
value_type v1 = saturate_cast<value_type>(src(y + by, x + bx));
value_type v2 = saturate_cast<value_type>(src(y + cy + by, x + cx + bx));
color2 += norm2(v1 - v2);
}
float dist2 = cx * cx + cy * cy;
float w = __expf(color2 * h2_inv_half + dist2 * block_radius2_inv);
sum1 = sum1 + saturate_cast<value_type>(src(y + cy, x + cy)) * w;
sum2 += w;
}
}
else
{
for(float cy = -search_radius; cy <= search_radius; ++cy)
for(float cx = -search_radius; cx <= search_radius; ++cx)
{
float color2 = 0;
for(float by = -block_radius; by <= block_radius; ++by)
for(float bx = -block_radius; bx <= block_radius; ++bx)
{
value_type v1 = saturate_cast<value_type>(b.at(y + by, x + bx, src.data, src.step));
value_type v2 = saturate_cast<value_type>(b.at(y + cy + by, x + cx + bx, src.data, src.step));
color2 += norm2(v1 - v2);
}
float dist2 = cx * cx + cy * cy;
float w = __expf(color2 * h2_inv_half + dist2 * block_radius2_inv);
sum1 = sum1 + saturate_cast<value_type>(b.at(y + cy, x + cy, src.data, src.step)) * w;
sum2 += w;
}
}
dst(y, x) = saturate_cast<T>(sum1 / sum2);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment