Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hydra-image-processor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
hydra-image-processor
Commits
c8635e34
Commit
c8635e34
authored
11 years ago
by
Eric Wait
Browse files
Options
Downloads
Patches
Plain Diff
Created normalizedCovariance method
parent
0167ae1d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/c/Common/CudaImageBuffer.cuh
+69
-0
69 additions, 0 deletions
src/c/Common/CudaImageBuffer.cuh
with
69 additions
and
0 deletions
src/c/Common/CudaImageBuffer.cuh
+
69
−
0
View file @
c8635e34
...
...
@@ -422,6 +422,75 @@ public:
incrementBufferNumber
();
}
/*
* This will calculate the normalized covariance between the two images A and B
* returns (sum over all{(A-mu(A)) X (B-mu(B))}) / (sigma(A)Xsigma(B)
* The images buffers will not change the original data
*/
double
normalizedCovariance
(
CudaImageBuffer
*
otherImage
)
{
ImagePixelType
*
aOrg
=
this
->
retrieveImage
();
ImagePixelType
*
bOrg
=
otherImage
->
retrieveImage
();
double
aSum1
=
0.0
;
double
bSum1
=
0.0
;
this
->
sumArray
(
aSum1
);
otherImage
->
sumArray
(
bSum1
);
double
aMean
=
aSum1
/
this
->
imageDims
.
product
();
double
bMean
=
bSum1
/
otherImage
->
getDimension
().
product
();
this
->
addConstant
(
-
aMean
);
otherImage
->
addConstant
(
-
bMean
);
double
aMidSum
;
double
bMidSum
;
if
(
imageDims
.
z
>
1
)
{
this
->
sumArray
(
aMidSum
);
otherImage
->
sumArray
(
bMidSum
);
}
this
->
reserveCurrentBuffer
();
otherImage
->
reserveCurrentBuffer
();
this
->
imagePow
(
2
);
otherImage
->
imagePow
(
2
);
double
aSum2
=
0.0
;
double
bSum2
=
0.0
;
this
->
sumArray
(
aSum2
);
otherImage
->
sumArray
(
bSum2
);
double
aSigma
=
sqrt
(
aSum2
/
this
->
getDimension
().
product
());
double
bSigma
=
sqrt
(
bSum2
/
otherImage
->
getDimension
().
product
());
this
->
currentBuffer
=
this
->
reservedBuffer
;
otherImage
->
currentBuffer
=
otherImage
->
reservedBuffer
;
this
->
releaseReservedBuffer
();
otherImage
->
releaseReservedBuffer
();
cudaMultiplyTwoImages
<<<
blocks
,
threads
>>>
(
this
->
getCurrentBuffer
(),
otherImage
->
getCurrentBuffer
(),
this
->
getNextBuffer
(),
this
->
imageDims
,
this
->
isColumnMajor
);
this
->
incrementBufferNumber
();
double
multSum
=
0.0
;
this
->
sumArray
(
multSum
);
this
->
loadImage
(
aOrg
,
this
->
getDimension
());
otherImage
->
loadImage
(
bOrg
,
otherImage
->
getDimension
());
delete
[]
aOrg
;
delete
[]
bOrg
;
double
rtn
=
multSum
/
(
aSigma
*
bSigma
)
/
this
->
getDimension
().
product
();
return
rtn
;
}
/*
* Takes a histogram that is on the card and normalizes it
* Will generate the original histogram if one doesn't already exist
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment