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
8728ba30
Commit
8728ba30
authored
10 years ago
by
Eric Wait
Browse files
Options
Downloads
Patches
Plain Diff
Contrast enhancement now works faster by not using biggest overlap for each kernel
parent
88ccef47
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/CudaContrastEnhancement.cuh
+111
-49
111 additions, 49 deletions
src/c/Common/CudaContrastEnhancement.cuh
with
111 additions
and
49 deletions
src/c/Common/CudaContrastEnhancement.cuh
+
111
−
49
View file @
8728ba30
...
...
@@ -14,53 +14,115 @@ template <class PixelType>
PixelType
*
contrastEnhancement
(
const
PixelType
*
imageIn
,
Vec
<
size_t
>
dims
,
Vec
<
float
>
sigmas
,
Vec
<
size_t
>
neighborhood
,
PixelType
**
imageOut
=
NULL
,
int
device
=
0
)
{
PixelType
*
imOut
=
setUpOutIm
(
dims
,
imageOut
);
PixelType
minVal
=
std
::
numeric_limits
<
PixelType
>::
lowest
();
PixelType
maxVal
=
std
::
numeric_limits
<
PixelType
>::
max
();
neighborhood
=
neighborhood
.
clamp
(
Vec
<
size_t
>
(
1
,
1
,
1
),
dims
);
float
*
hostKernel
;
Vec
<
int
>
gaussIterations
(
0
,
0
,
0
);
Vec
<
size_t
>
sizeconstKernelDims
=
createGaussianKernel
(
sigmas
,
&
hostKernel
,
gaussIterations
);
HANDLE_ERROR
(
cudaMemcpyToSymbol
(
cudaConstKernel
,
hostKernel
,
sizeof
(
float
)
*
(
sizeconstKernelDims
.
x
+
sizeconstKernelDims
.
y
+
sizeconstKernelDims
.
z
)));
cudaDeviceProp
props
;
cudaGetDeviceProperties
(
&
props
,
device
);
size_t
availMem
,
total
;
cudaMemGetInfo
(
&
availMem
,
&
total
);
std
::
vector
<
ImageChunk
>
chunks
=
calculateBuffers
<
double
>
(
dims
,
3
,(
size_t
)(
availMem
*
MAX_MEM_AVAIL
),
props
,
sizeconstKernelDims
);
Vec
<
size_t
>
maxDeviceDims
;
setMaxDeviceDims
(
chunks
,
maxDeviceDims
);
CudaDeviceImages
<
double
>
deviceImages
(
3
,
maxDeviceDims
,
device
);
for
(
std
::
vector
<
ImageChunk
>::
iterator
curChunk
=
chunks
.
begin
();
curChunk
!=
chunks
.
end
();
++
curChunk
)
{
deviceImages
.
setAllDims
(
curChunk
->
getFullChunkSize
());
curChunk
->
sendROI
(
imageIn
,
dims
,
deviceImages
.
getCurBuffer
());
runGaussIterations
(
gaussIterations
,
curChunk
,
deviceImages
,
sizeconstKernelDims
,
device
);
curChunk
->
sendROI
(
imageIn
,
dims
,
deviceImages
.
getNextBuffer
());
cudaAddTwoImagesWithFactor
<
double
><<<
curChunk
->
blocks
,
curChunk
->
threads
>>>
(
*
(
deviceImages
.
getNextBuffer
()),
*
(
deviceImages
.
getCurBuffer
()),
*
(
deviceImages
.
getThirdBuffer
()),
-
1.0
,
minVal
,
maxVal
);
DEBUG_KERNEL_CHECK
();
deviceImages
.
setNthBuffCurent
(
3
);
runMedianFilter
(
props
,
curChunk
,
neighborhood
,
deviceImages
);
curChunk
->
retriveROI
(
imOut
,
dims
,
deviceImages
.
getCurBuffer
());
}
return
imOut
;
PixelType
*
imGauss
=
gaussianFilter
<
PixelType
>
(
imageIn
,
dims
,
sigmas
,
NULL
,
device
);
PixelType
*
imSub
=
addImageWith
<
PixelType
>
(
imageIn
,
imGauss
,
dims
,
-
1.0
,
NULL
,
device
);
delete
[]
imGauss
;
return
medianFilter
(
imSub
,
dims
,
neighborhood
,
imageOut
,
device
);
// PixelType* imOut = setUpOutIm(dims, imageOut);
//
// PixelType minVal = std::numeric_limits<PixelType>::lowest();
// PixelType maxVal = std::numeric_limits<PixelType>::max();
//
// neighborhood = neighborhood.clamp(Vec<size_t>(1,1,1),dims);
//
// float* hostKernel;
//
// Vec<int> gaussIterations(0,0,0);
// Vec<size_t> sizeconstKernelDims = createGaussianKernel(sigmas,&hostKernel,gaussIterations);
// HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, hostKernel, sizeof(float)*
// (sizeconstKernelDims.x+sizeconstKernelDims.y+sizeconstKernelDims.z)));
//
// cudaDeviceProp props;
// cudaGetDeviceProperties(&props,device);
//
// size_t availMem, total;
// cudaMemGetInfo(&availMem,&total);
//
// std::vector<ImageChunk> chunks = calculateBuffers<float>(dims,3,(size_t)(availMem*MAX_MEM_AVAIL),props,sizeconstKernelDims);
//
// Vec<size_t> maxDeviceDims;
// setMaxDeviceDims(chunks, maxDeviceDims);
//
// CudaDeviceImages<float> deviceImages(3,maxDeviceDims,device);
//
// for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk)
// {
// deviceImages.setAllDims(curChunk->getFullChunkSize());
//
// curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer());
//
// runGaussIterations(gaussIterations, curChunk, deviceImages, sizeconstKernelDims,device);
//
// curChunk->sendROI(imageIn,dims,deviceImages.getNextBuffer());
//
// cudaAddTwoImagesWithFactor<float><<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getNextBuffer()),*(deviceImages.getCurBuffer()),
// *(deviceImages.getThirdBuffer()),-1.0,(float)minVal,(float)maxVal);
// DEBUG_KERNEL_CHECK();
//
// deviceImages.setNthBuffCurent(3);
//
// runMedianFilter<float>(props, curChunk, neighborhood, deviceImages);
//
// curChunk->retriveROI<float,PixelType>(imOut,dims,deviceImages.getCurBuffer());
// }
//return imOut;
}
//double* contrastEnhancement(const double* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood,
// double** imageOut=NULL, int device=0)
//{
// double* imOut = setUpOutIm(dims, imageOut);
//
// double minVal = std::numeric_limits<double>::lowest();
// double maxVal = std::numeric_limits<double>::max();
//
// neighborhood = neighborhood.clamp(Vec<size_t>(1,1,1),dims);
//
// float* hostKernel;
//
// Vec<int> gaussIterations(0,0,0);
// Vec<size_t> sizeconstKernelDims = createGaussianKernel(sigmas,&hostKernel,gaussIterations);
// HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, hostKernel, sizeof(float)*
// (sizeconstKernelDims.x+sizeconstKernelDims.y+sizeconstKernelDims.z)));
//
// cudaDeviceProp props;
// cudaGetDeviceProperties(&props,device);
//
// size_t availMem, total;
// cudaMemGetInfo(&availMem,&total);
//
// std::vector<ImageChunk> chunks = calculateBuffers<double>(dims,3,(size_t)(availMem*MAX_MEM_AVAIL),props,sizeconstKernelDims);
//
// Vec<size_t> maxDeviceDims;
// setMaxDeviceDims(chunks, maxDeviceDims);
//
// CudaDeviceImages<double> deviceImages(3,maxDeviceDims,device);
//
// for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk)
// {
// deviceImages.setAllDims(curChunk->getFullChunkSize());
//
// curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer());
//
// runGaussIterations(gaussIterations, curChunk, deviceImages, sizeconstKernelDims,device);
//
// curChunk->sendROI(imageIn,dims,deviceImages.getNextBuffer());
//
// cudaAddTwoImagesWithFactor<double><<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getNextBuffer()),*(deviceImages.getCurBuffer()),
// *(deviceImages.getThirdBuffer()),-1.0,minVal,maxVal);
// DEBUG_KERNEL_CHECK();
//
// deviceImages.setNthBuffCurent(3);
//
// runMedianFilter(props, curChunk, neighborhood, deviceImages);
//
// curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer());
// }
//
// return imOut;
//}
\ No newline at end of file
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