Skip to content
Snippets Groups Projects
Commit 48cfc18d authored by Eric Wait's avatar Eric Wait
Browse files

Added a clamp and saturate to Vec

parent e37ca2b9
No related branches found
No related tags found
No related merge requests found
......@@ -397,6 +397,8 @@ DevicePixelType* CudaProcessBuffer::contrastEnhancement(const DevicePixelType* i
DevicePixelType minVal = std::numeric_limits<DevicePixelType>::lowest();
DevicePixelType maxVal = std::numeric_limits<DevicePixelType>::max();
neighborhood = neighborhood.clamp(Vec<size_t>(1,1,1),dims);
Vec<int> gaussIterations(0,0,0);
Vec<size_t> sizeconstKernelDims = createGaussianKernel(sigmas,hostKernel,gaussIterations);
HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, hostKernel, sizeof(float)*
......@@ -538,6 +540,8 @@ DevicePixelType* CudaProcessBuffer::meanFilter(const DevicePixelType* imageIn, V
{
DevicePixelType* imOut = setUpOutIm(dims, imageOut);
neighborhood = neighborhood.clamp(Vec<size_t>(1,1,1),dims);
std::vector<ImageChunk> chunks = calculateBuffers(dims,2,(size_t)(deviceProp.totalGlobalMem*MAX_MEM_AVAIL),deviceProp,neighborhood);
setMaxDeviceDims(chunks, maxDeviceDims);
......@@ -565,6 +569,8 @@ DevicePixelType* CudaProcessBuffer::medianFilter(const DevicePixelType* imageIn,
{
DevicePixelType* imOut = setUpOutIm(dims, imageOut);
neighborhood = neighborhood.clamp(Vec<size_t>(1,1,1),dims);
std::vector<ImageChunk> chunks = calculateBuffers(dims,2,(size_t)(deviceProp.totalGlobalMem*MAX_MEM_AVAIL),deviceProp,neighborhood);
setMaxDeviceDims(chunks, maxDeviceDims);
......@@ -851,6 +857,7 @@ double CudaProcessBuffer::sumArray(const DevicePixelType* imageIn, size_t n)
DevicePixelType* CudaProcessBuffer::reduceImage(const DevicePixelType* imageIn, Vec<size_t> dims, Vec<size_t> reductions,
Vec<size_t>& reducedDims, DevicePixelType** imageOut/*=NULL*/)
{
reductions = reductions.clamp(Vec<size_t>(1,1,1),dims);
orgImageDims = dims;
reducedDims = orgImageDims / reductions;
DevicePixelType* reducedImage;
......@@ -967,5 +974,6 @@ DevicePixelType* CudaProcessBuffer::thresholdFilter(const DevicePixelType* image
void CudaProcessBuffer::unmix(const DevicePixelType* image, Vec<size_t> neighborhood)
{
//neighborhood = neighborhood.clamp(Vec<size_t>(1,1,1),dims);
throw std::logic_error("The method or operation is not implemented.");
}
......@@ -153,6 +153,26 @@ public:
return outVec;
}
DEVICE_PREFIX VEC_THIS_CLASS<T> saturate(VEC_THIS_CLASS<T> maxVal)
{
VEC_THIS_CLASS<T> outVec;
outVec.x = (x<maxVal.x) ? (x) : (maxVal.x);
outVec.y = (y<maxVal.y) ? (y) : (maxVal.y);
outVec.z = (z<maxVal.z) ? (z) : (maxVal.z);
return outVec;
}
DEVICE_PREFIX VEC_THIS_CLASS<T> clamp(VEC_THIS_CLASS<T> minVal, VEC_THIS_CLASS<T> maxVal)
{
VEC_THIS_CLASS<T> outVec;
outVec.x = (x<maxVal.x) ? ((x>minVal.x) ? (x) : (minVal.x)) : (maxVal.x);
outVec.y = (y<maxVal.y) ? ((x>minVal.y) ? (y) : (minVal.y)) : (maxVal.y);
outVec.z = (z<maxVal.z) ? ((x>minVal.z) ? (z) : (minVal.z)) : (maxVal.z);
return outVec;
}
#define EXTERN_TYPE VEC_THIS_CLASS
#include "VecFuncs.h"
#undef EXTERN_TYPE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment