diff --git a/src/MATLAB/+ImProc/@Cuda/AddConstant.m b/src/MATLAB/+ImProc/@Cuda/AddConstant.m deleted file mode 100644 index 0e4071e56212ad06b97a92e7de3f66d3241eec70..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/AddConstant.m +++ /dev/null @@ -1,9 +0,0 @@ -% AddConstant - This will add a constant value at every voxel location. -% imageOut = ImProc.Cuda.AddConstant(imageIn,additive,device) -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Additive -- must be a double and will be floored if input is an integer type. -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function imageOut = AddConstant(imageIn,additive,device) - [imageOut] = ImProc.Cuda.Mex('AddConstant',imageIn,additive,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/AddImageWith.m b/src/MATLAB/+ImProc/@Cuda/AddImageWith.m deleted file mode 100644 index c05f173f712b931404ec743db4ed634d6f8366e5..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/AddImageWith.m +++ /dev/null @@ -1,10 +0,0 @@ -% AddImageWith - This takes two images and adds them together. -% imageOut = ImProc.Cuda.AddImageWith(imageIn1,imageIn2,factor,device) -% ImageIn1 -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% ImageIn2 -- can be an image up to three dimensions and of the same type as imageIn1. -% Factor -- this is a multiplier to the second image in the form imageOut = imageIn1 + factor*imageIn2. -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% imageOut -- this is the result of imageIn1 + factor*imageIn2 and will be of the same type as imageIn1. -function imageOut = AddImageWith(imageIn1,imageIn2,factor,device) - [imageOut] = ImProc.Cuda.Mex('AddImageWith',imageIn1,imageIn2,factor,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/ApplyPolyTransformation.m b/src/MATLAB/+ImProc/@Cuda/ApplyPolyTransformation.m deleted file mode 100644 index 9fa1ccb69672106b5325eb35945ae7e6340201d8..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/ApplyPolyTransformation.m +++ /dev/null @@ -1,12 +0,0 @@ -% ApplyPolyTransformation - This returns an image with the quadradic function applied. ImageOut = a*ImageIn^2 + b*ImageIn + c -% imageOut = ImProc.Cuda.ApplyPolyTransformation(imageIn,a,b,c,min,max,device) -% A -- this multiplier is applied to the square of the image. -% B -- this multiplier is applied to the image. -% C -- is the constant additive. -% Min -- this is an optional parameter to clamp the output to and is useful for signed or floating point to remove negative values. -% Max -- this is an optional parameter to clamp the output to. -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% ImageOut -- this is the result of ImageOut = a*ImageIn^2 + b*ImageIn + c and is the same dimension and type as imageIn. -function imageOut = ApplyPolyTransformation(imageIn,a,b,c,min,max,device) - [imageOut] = ImProc.Cuda.Mex('ApplyPolyTransformation',imageIn,a,b,c,min,max,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/ContrastEnhancement.m b/src/MATLAB/+ImProc/@Cuda/ContrastEnhancement.m deleted file mode 100644 index c418651763eae835fe929de4a348898ea6b12f02..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/ContrastEnhancement.m +++ /dev/null @@ -1,12 +0,0 @@ -% ContrastEnhancement - This attempts to increase contrast by removing noise as proposed by Michel et al. This starts with subtracting off a highly smoothed version of imageIn followed by median filter. -% imageOut = ImProc.Cuda.ContrastEnhancement(imageIn,sigma,MedianNeighborhood,device) -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Sigma -- these values will create a n-dimensional Gaussian kernel to get a smoothed image that will be subtracted of the original. -% N is the number of dimensions of imageIn -% The larger the sigma the more object preserving the high pass filter will be (e.g. sigma > 35) -% MedianNeighborhood -- this is the neighborhood size in each dimension that will be evaluated for the median neighborhood filter. -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% ImageOut -- will have the same dimensions and type as imageIn. -function imageOut = ContrastEnhancement(imageIn,sigma,MedianNeighborhood,device) - [imageOut] = ImProc.Cuda.Mex('ContrastEnhancement',imageIn,sigma,MedianNeighborhood,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/EntropyFilter.m b/src/MATLAB/+ImProc/@Cuda/EntropyFilter.m deleted file mode 100644 index 2c5fd74d16ed1d9f6a78151231fb80b93ec07244..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/EntropyFilter.m +++ /dev/null @@ -1,4 +0,0 @@ -% EntropyFilter - imageOut = EntropyFilter(imageIn,kernel,device) -function imageOut = EntropyFilter(imageIn,kernel,device) - [imageOut] = ImProc.Cuda.Mex('EntropyFilter',imageIn,kernel,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/GaussianFilter.m b/src/MATLAB/+ImProc/@Cuda/GaussianFilter.m deleted file mode 100644 index 6f3a1f0775d88f9358171239157224421686dd1b..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/GaussianFilter.m +++ /dev/null @@ -1,9 +0,0 @@ -% GaussianFilter - Smooths image using a Gaussian kernel. -% imageOut = ImProc.Cuda.GaussianFilter(imageIn,sigma,device) -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Sigma -- these values will create a n-dimensional Gaussian kernel to get a smoothed image that will be subtracted of the original. -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function imageOut = GaussianFilter(imageIn,sigma,device) - [imageOut] = ImProc.Cuda.Mex('GaussianFilter',imageIn,sigma,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/Histogram.m b/src/MATLAB/+ImProc/@Cuda/Histogram.m deleted file mode 100644 index dc46c7ea2b07311d440a3e427883b6152eb2508e..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/Histogram.m +++ /dev/null @@ -1,13 +0,0 @@ -% Histogram - Creates a histogram array with numBins bins between min/max values. -% histogram = ImProc.Cuda.Histogram(imageIn,numBins,min,max,device) -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% NumBins -- number of bins that the histogram should partition the signal into. -% Min -- this is the minimum value for the histogram. -% If min is not provided, the min of the image type is used. -% Max -- this is the maximum value for the histogram. -% If min is not provided, the min of the image type is used. -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function histogram = Histogram(imageIn,numBins,min,max,device) - [histogram] = ImProc.Cuda.Mex('Histogram',imageIn,numBins,min,max,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/ImagePow.m b/src/MATLAB/+ImProc/@Cuda/ImagePow.m deleted file mode 100644 index 7a69226e9b335fd90a583ae3c3ff76b9f6bc892c..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/ImagePow.m +++ /dev/null @@ -1,9 +0,0 @@ -% ImagePow - This will raise each voxel value to the power provided. -% imageOut = ImProc.Cuda.ImagePow(imageIn,power,device) -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Power -- must be a double. -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function imageOut = ImagePow(imageIn,power,device) - [imageOut] = ImProc.Cuda.Mex('ImagePow',imageIn,power,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/LinearUnmixing.m b/src/MATLAB/+ImProc/@Cuda/LinearUnmixing.m deleted file mode 100644 index 4fbf35cd2c2fb213a92a9d27e230631b719f36d9..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/LinearUnmixing.m +++ /dev/null @@ -1,4 +0,0 @@ -% LinearUnmixing - imageOut = LinearUnmixing(mixedImages,unmixMatrix,device) -function imageOut = LinearUnmixing(mixedImages,unmixMatrix,device) - [imageOut] = ImProc.Cuda.Mex('LinearUnmixing',mixedImages,unmixMatrix,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/LoG.m b/src/MATLAB/+ImProc/@Cuda/LoG.m deleted file mode 100644 index ffae8a10045350c5871e4150950b4a66b0fda5bd..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/LoG.m +++ /dev/null @@ -1,9 +0,0 @@ -% LoG - Smooths image using a Gaussian kernel. -% imageOut = ImProc.Cuda.LoG(imageIn,sigma,device) -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Sigma -- these values will create a n-dimensional Gaussian kernel to get a smoothed image that will be subtracted of the original. -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function imageOut = LoG(imageIn,sigma,device) - [imageOut] = ImProc.Cuda.Mex('LoG',imageIn,sigma,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MarkovRandomFieldDenoiser.m b/src/MATLAB/+ImProc/@Cuda/MarkovRandomFieldDenoiser.m deleted file mode 100644 index 76ec66aa1deb9b00dac64a44eb6338903cb5bf7b..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MarkovRandomFieldDenoiser.m +++ /dev/null @@ -1,4 +0,0 @@ -% MarkovRandomFieldDenoiser - imageOut = MarkovRandomFieldDenoiser(imageIn,maxIterations,device) -function imageOut = MarkovRandomFieldDenoiser(imageIn,maxIterations,device) - [imageOut] = ImProc.Cuda.Mex('MarkovRandomFieldDenoiser',imageIn,maxIterations,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MaxFilterEllipsoid.m b/src/MATLAB/+ImProc/@Cuda/MaxFilterEllipsoid.m deleted file mode 100644 index 686388cda055d52f4b09ef7940e1107aa9ef535a..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MaxFilterEllipsoid.m +++ /dev/null @@ -1,4 +0,0 @@ -% MaxFilterEllipsoid - imageOut = MaxFilterEllipsoid(imageIn,radius,device) -function imageOut = MaxFilterEllipsoid(imageIn,radius,device) - [imageOut] = ImProc.Cuda.Mex('MaxFilterEllipsoid',imageIn,radius,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MaxFilterKernel.m b/src/MATLAB/+ImProc/@Cuda/MaxFilterKernel.m deleted file mode 100644 index c3288d918d99d8ea848c9a2b23d5b2e6fa275a1d..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MaxFilterKernel.m +++ /dev/null @@ -1,4 +0,0 @@ -% MaxFilterKernel - imageOut = MaxFilterKernel(imageIn,kernel,device) -function imageOut = MaxFilterKernel(imageIn,kernel,device) - [imageOut] = ImProc.Cuda.Mex('MaxFilterKernel',imageIn,kernel,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MaxFilterNeighborhood.m b/src/MATLAB/+ImProc/@Cuda/MaxFilterNeighborhood.m deleted file mode 100644 index 371b0f55b6b1fbf8ba19894f821c8dfbf5dff116..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MaxFilterNeighborhood.m +++ /dev/null @@ -1,4 +0,0 @@ -% MaxFilterNeighborhood - imageOut = MaxFilterNeighborhood(imageIn,Neighborhood,device) -function imageOut = MaxFilterNeighborhood(imageIn,Neighborhood,device) - [imageOut] = ImProc.Cuda.Mex('MaxFilterNeighborhood',imageIn,Neighborhood,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MeanFilter.m b/src/MATLAB/+ImProc/@Cuda/MeanFilter.m deleted file mode 100644 index 65d6282325357e0493818a9858aa86719a2d3f78..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MeanFilter.m +++ /dev/null @@ -1,4 +0,0 @@ -% MeanFilter - imageOut = MeanFilter(imageIn,Neighborhood,device) -function imageOut = MeanFilter(imageIn,Neighborhood,device) - [imageOut] = ImProc.Cuda.Mex('MeanFilter',imageIn,Neighborhood,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MedianFilter.m b/src/MATLAB/+ImProc/@Cuda/MedianFilter.m deleted file mode 100644 index 921fdb79c8efa9ab53d5652da5a6e13a885cdc53..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MedianFilter.m +++ /dev/null @@ -1,4 +0,0 @@ -% MedianFilter - imageOut = MedianFilter(imageIn,Neighborhood,device) -function imageOut = MedianFilter(imageIn,Neighborhood,device) - [imageOut] = ImProc.Cuda.Mex('MedianFilter',imageIn,Neighborhood,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MinFilterEllipsoid.m b/src/MATLAB/+ImProc/@Cuda/MinFilterEllipsoid.m deleted file mode 100644 index 1546f8c03b5df09980116fd699fd32dc6946bccb..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MinFilterEllipsoid.m +++ /dev/null @@ -1,4 +0,0 @@ -% MinFilterEllipsoid - imageOut = MinFilterEllipsoid(imageIn,radius,device) -function imageOut = MinFilterEllipsoid(imageIn,radius,device) - [imageOut] = ImProc.Cuda.Mex('MinFilterEllipsoid',imageIn,radius,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MinFilterKernel.m b/src/MATLAB/+ImProc/@Cuda/MinFilterKernel.m deleted file mode 100644 index c1743dd222dde2e64416c3bdc2f087ca054ea7bc..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MinFilterKernel.m +++ /dev/null @@ -1,4 +0,0 @@ -% MinFilterKernel - imageOut = MinFilterKernel(imageIn,kernel,device) -function imageOut = MinFilterKernel(imageIn,kernel,device) - [imageOut] = ImProc.Cuda.Mex('MinFilterKernel',imageIn,kernel,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MinFilterNeighborhood.m b/src/MATLAB/+ImProc/@Cuda/MinFilterNeighborhood.m deleted file mode 100644 index 7da00c6a91d252ef680086795ff31dfe02ef29b8..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MinFilterNeighborhood.m +++ /dev/null @@ -1,4 +0,0 @@ -% MinFilterNeighborhood - imageOut = MinFilterNeighborhood(imageIn,Neighborhood,device) -function imageOut = MinFilterNeighborhood(imageIn,Neighborhood,device) - [imageOut] = ImProc.Cuda.Mex('MinFilterNeighborhood',imageIn,Neighborhood,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MinMax.m b/src/MATLAB/+ImProc/@Cuda/MinMax.m deleted file mode 100644 index 4fb17bdc2438ba73344f83c6abee93840f8179f6..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MinMax.m +++ /dev/null @@ -1,4 +0,0 @@ -% MinMax - [min,max] = MinMax(imageIn,device) -function [min,max] = MinMax(imageIn,device) - [min,max] = ImProc.Cuda.Mex('MinMax',imageIn,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MorphologicalClosure.m b/src/MATLAB/+ImProc/@Cuda/MorphologicalClosure.m deleted file mode 100644 index 86946b5e41b2e3b27fb934b41a0a05667c22da93..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MorphologicalClosure.m +++ /dev/null @@ -1,4 +0,0 @@ -% MorphologicalClosure - imageOut = MorphologicalClosure(imageIn,kernel,device) -function imageOut = MorphologicalClosure(imageIn,kernel,device) - [imageOut] = ImProc.Cuda.Mex('MorphologicalClosure',imageIn,kernel,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MorphologicalOpening.m b/src/MATLAB/+ImProc/@Cuda/MorphologicalOpening.m deleted file mode 100644 index 785cd50ff52b35df0b8bfde62db8cdfb18126d05..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MorphologicalOpening.m +++ /dev/null @@ -1,4 +0,0 @@ -% MorphologicalOpening - imageOut = MorphologicalOpening(imageIn,kernel,device) -function imageOut = MorphologicalOpening(imageIn,kernel,device) - [imageOut] = ImProc.Cuda.Mex('MorphologicalOpening',imageIn,kernel,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MultiplyImage.m b/src/MATLAB/+ImProc/@Cuda/MultiplyImage.m deleted file mode 100644 index 433bd38bbdc70e5be318d9d69f2b427618731d75..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MultiplyImage.m +++ /dev/null @@ -1,4 +0,0 @@ -% MultiplyImage - imageOut = MultiplyImage(imageIn,multiplier,device) -function imageOut = MultiplyImage(imageIn,multiplier,device) - [imageOut] = ImProc.Cuda.Mex('MultiplyImage',imageIn,multiplier,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/MultiplyTwoImages.m b/src/MATLAB/+ImProc/@Cuda/MultiplyTwoImages.m deleted file mode 100644 index 5144313b5dedad6219bf9ef20ede2f5a93e95220..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/MultiplyTwoImages.m +++ /dev/null @@ -1,4 +0,0 @@ -% MultiplyTwoImages - imageOut = MultiplyTwoImages(imageIn1,imageIn2,factor,device) -function imageOut = MultiplyTwoImages(imageIn1,imageIn2,factor,device) - [imageOut] = ImProc.Cuda.Mex('MultiplyTwoImages',imageIn1,imageIn2,factor,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/NeighborhoodSum.m b/src/MATLAB/+ImProc/@Cuda/NeighborhoodSum.m deleted file mode 100644 index bc3f3dee3e62730266409bc248c28895cc82891d..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/NeighborhoodSum.m +++ /dev/null @@ -1,4 +0,0 @@ -% NeighborhoodSum - imageOut = NeighborhoodSum(imageIn,Neighborhood,device) -function imageOut = NeighborhoodSum(imageIn,Neighborhood,device) - [imageOut] = ImProc.Cuda.Mex('NeighborhoodSum',imageIn,Neighborhood,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/NormalizedCovariance.m b/src/MATLAB/+ImProc/@Cuda/NormalizedCovariance.m deleted file mode 100644 index 1f649848d3c6f3e337c218a772589278a240fc23..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/NormalizedCovariance.m +++ /dev/null @@ -1,4 +0,0 @@ -% NormalizedCovariance - normalizedCovariance = NormalizedCovariance(imageIn1,imageIn2,device) -function normalizedCovariance = NormalizedCovariance(imageIn1,imageIn2,device) - [normalizedCovariance] = ImProc.Cuda.Mex('NormalizedCovariance',imageIn1,imageIn2,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/NormalizedHistogram.m b/src/MATLAB/+ImProc/@Cuda/NormalizedHistogram.m deleted file mode 100644 index b4312fff3c152956a7fc9ca0943082b14cf53235..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/NormalizedHistogram.m +++ /dev/null @@ -1,4 +0,0 @@ -% NormalizedHistogram - histogram = NormalizedHistogram(imageIn,numBins,min,max,device) -function histogram = NormalizedHistogram(imageIn,numBins,min,max,device) - [histogram] = ImProc.Cuda.Mex('NormalizedHistogram',imageIn,numBins,min,max,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/OtsuThresholdFilter.m b/src/MATLAB/+ImProc/@Cuda/OtsuThresholdFilter.m deleted file mode 100644 index c21aff025ec8d7067836d7a7ff8bbf4863b06029..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/OtsuThresholdFilter.m +++ /dev/null @@ -1,4 +0,0 @@ -% OtsuThresholdFilter - imageOut = OtsuThresholdFilter(imageIn,alpha,device) -function imageOut = OtsuThresholdFilter(imageIn,alpha,device) - [imageOut] = ImProc.Cuda.Mex('OtsuThresholdFilter',imageIn,alpha,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/OtsuThresholdValue.m b/src/MATLAB/+ImProc/@Cuda/OtsuThresholdValue.m deleted file mode 100644 index bc6c6c5dbaa8982c9f6d547667eaaff921fa9c29..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/OtsuThresholdValue.m +++ /dev/null @@ -1,4 +0,0 @@ -% OtsuThresholdValue - threshold = OtsuThresholdValue(imageIn,device) -function threshold = OtsuThresholdValue(imageIn,device) - [threshold] = ImProc.Cuda.Mex('OtsuThresholdValue',imageIn,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/RegionGrowing.m b/src/MATLAB/+ImProc/@Cuda/RegionGrowing.m deleted file mode 100644 index b4ad866072d46e4201804688755a91d36ca62caf..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/RegionGrowing.m +++ /dev/null @@ -1,8 +0,0 @@ -% RegionGrowing - This will create a mask that grows by a delta value. If a neighboring voxel is masked and the current voxel intensity is +/- delta from the masked intensity, then the current voxel is added to the mask. -% maskOut = ImProc.Cuda.RegionGrowing(imageIn,kernel,mask,threshold,allowConnections,device) -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Kernel -- this -% -function maskOut = RegionGrowing(imageIn,kernel,mask,threshold,allowConnections,device) - [maskOut] = ImProc.Cuda.Mex('RegionGrowing',imageIn,kernel,mask,threshold,allowConnections,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/Resize.m b/src/MATLAB/+ImProc/@Cuda/Resize.m deleted file mode 100644 index 33404c034ea84e1e79a7b34e812639017c5e64cf..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/Resize.m +++ /dev/null @@ -1,14 +0,0 @@ -% Resize - Resizes image using various methods. -% imageOut = ImProc.Cuda.Resize(imageIn,resizeFactor,explicitSize,method,device) -% ImageIn -- can be an image up to three dimensions and of type (logical,uint8,int8,uint16,int16,uint32,int32,single,double). -% ResizeFactor_rcz -- This represents the output size relative to input (r,c,z). Values less than one but greater than zero will reduce the image. -% Values greater than one will enlarge the image. If this is an empty array, it will be calculated from the explicit resize. -% If both resizeFactor and explicitSize are both set, the explicitSize will be used. -% ExplicitSize_rcz -- This is the size that the output should be (r,c,z). If this is an empty array, then the resize factor is used. -% If both resizeFactor and explicitSize are both set, the explicitSize will be used. -% Method -- This is the neighborhood operation to apply when resizing (mean, median, min, max, gaussian). -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% ImageOut -- This will be a resize image the same type as the input image. -function imageOut = Resize(imageIn,resizeFactor,explicitSize,method,device) - [imageOut] = ImProc.Cuda.Mex('Resize',imageIn,resizeFactor,explicitSize,method,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/Segment.m b/src/MATLAB/+ImProc/@Cuda/Segment.m deleted file mode 100644 index e8189b1c0072b936de6c7620c437f38b07b75112..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/Segment.m +++ /dev/null @@ -1,4 +0,0 @@ -% Segment - imageOut = Segment(imageIn,alpha,MorphClosure,device) -function imageOut = Segment(imageIn,alpha,MorphClosure,device) - [imageOut] = ImProc.Cuda.Mex('Segment',imageIn,alpha,MorphClosure,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/StdFilter.m b/src/MATLAB/+ImProc/@Cuda/StdFilter.m deleted file mode 100644 index 7c46748a32f3c7591031ee9f2a7ae84910fa822a..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/StdFilter.m +++ /dev/null @@ -1,4 +0,0 @@ -% StdFilter - imageOut = StdFilter(imageIn,Neighborhood,device) -function imageOut = StdFilter(imageIn,Neighborhood,device) - [imageOut] = ImProc.Cuda.Mex('StdFilter',imageIn,Neighborhood,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/SumArray.m b/src/MATLAB/+ImProc/@Cuda/SumArray.m deleted file mode 100644 index 6fc5cbebeaac37a1b10cbbf9dea64678272e91c4..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/SumArray.m +++ /dev/null @@ -1,4 +0,0 @@ -% SumArray - sum = SumArray(imageIn,device) -function sum = SumArray(imageIn,device) - [sum] = ImProc.Cuda.Mex('SumArray',imageIn,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/ThresholdFilter.m b/src/MATLAB/+ImProc/@Cuda/ThresholdFilter.m deleted file mode 100644 index 3780a965d00a32c0fc81764fae54d67ded39419e..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/ThresholdFilter.m +++ /dev/null @@ -1,4 +0,0 @@ -% ThresholdFilter - imageOut = ThresholdFilter(imageIn,threshold,device) -function imageOut = ThresholdFilter(imageIn,threshold,device) - [imageOut] = ImProc.Cuda.Mex('ThresholdFilter',imageIn,threshold,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/TileImage.m b/src/MATLAB/+ImProc/@Cuda/TileImage.m deleted file mode 100644 index a7801885ac545b9e3692a86cceec9e4da8cf7423..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/TileImage.m +++ /dev/null @@ -1,10 +0,0 @@ -% TileImage - This will output an image that only consists of the region of interest indicated. -% imageOut = ImProc.Cuda.TileImage(imageIn,roiStart,roiSize,device) -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% RoiStart -- this is the location of the first voxel in the region of interest (starting from the origin). Must be the same dimension as imageIn. -% RoiSize -- this is how many voxels to include starting from roiStart. Must be the same dimension as imageIn. -% Device -- this is an optional parameter that indicates which Cuda capable device to use. -% ImageOut -- this will be an image that only contains the region of interest indicated. -function imageOut = TileImage(imageIn,roiStart,roiSize,device) - [imageOut] = ImProc.Cuda.Mex('TileImage',imageIn,roiStart,roiSize,device); -end diff --git a/src/MATLAB/+ImProc/@Cuda/Variance.m b/src/MATLAB/+ImProc/@Cuda/Variance.m deleted file mode 100644 index 20db29e48c88ec84c74fb0f24b2e6c2972267ca6..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/@Cuda/Variance.m +++ /dev/null @@ -1,4 +0,0 @@ -% Variance - variance = Variance(imageIn,device) This will return the variance of an image. -function variance = Variance(imageIn,device) - [variance] = ImProc.Cuda.Mex('Variance',imageIn,device); -end diff --git a/src/MATLAB/+ImProc/AddConstant.m b/src/MATLAB/+ImProc/AddConstant.m deleted file mode 100644 index 5f4b952e5996b3675666816cc066b86f008bef2e..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/AddConstant.m +++ /dev/null @@ -1,32 +0,0 @@ -% AddConstant - This will add a constant value at every voxel location. -% imageOut = ImProc.AddConstant(imageIn,additive); -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Additive -- must be a double and will be floored if input is an integer type. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function imageOut = AddConstant(imageIn,additive,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.AddConstant(imageIn,additive,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclAddConstant(imageIn,additive); - end -end - -function imageOut = lclAddConstant(imageIn,additive) - imageOut = imageIn +additive; -end - diff --git a/src/MATLAB/+ImProc/AddImageWith.m b/src/MATLAB/+ImProc/AddImageWith.m deleted file mode 100644 index 90b0f97ffe6c70403e58c220bd52fdc1e558dc6e..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/AddImageWith.m +++ /dev/null @@ -1,33 +0,0 @@ -% AddImageWith - This takes two images and adds them together. -% imageOut = ImProc.AddImageWith(imageIn1,imageIn2,factor); -% ImageIn1 -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% ImageIn2 -- can be an image up to three dimensions and of the same type as imageIn1. -% Factor -- this is a multiplier to the second image in the form imageOut = imageIn1 + factor*imageIn2. -% imageOut -- this is the result of imageIn1 + factor*imageIn2 and will be of the same type as imageIn1. -function imageOut = AddImageWith(imageIn1,imageIn2,factor,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.AddImageWith(imageIn1,imageIn2,factor,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclAddImageWith(imageIn1,imageIn2,factor); - end -end - -function imageOut = lclAddImageWith(imageIn1,imageIn2,factor) - imageOut = imageIn1 + imageIn2.*factor; -end - diff --git a/src/MATLAB/+ImProc/ApplyPolyTransformation.m b/src/MATLAB/+ImProc/ApplyPolyTransformation.m deleted file mode 100644 index 55f00401d1412f106614f26826586d8376a0151e..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/ApplyPolyTransformation.m +++ /dev/null @@ -1,35 +0,0 @@ -% ApplyPolyTransformation - This returns an image with the quadradic function applied. ImageOut = a*ImageIn^2 + b*ImageIn + c -% imageOut = ImProc.ApplyPolyTransformation(imageIn,a,b,c,min,max); -% A -- this multiplier is applied to the square of the image. -% B -- this multiplier is applied to the image. -% C -- is the constant additive. -% Min -- this is an optional parameter to clamp the output to and is useful for signed or floating point to remove negative values. -% Max -- this is an optional parameter to clamp the output to. -% ImageOut -- this is the result of ImageOut = a*ImageIn^2 + b*ImageIn + c and is the same dimension and type as imageIn. -function imageOut = ApplyPolyTransformation(imageIn,a,b,c,min,max,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.ApplyPolyTransformation(imageIn,a,b,c,min,max,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclApplyPolyTransformation(imageIn,a,b,c,min,max); - end -end - -function imageOut = lclApplyPolyTransformation(imageIn,a,b,c,min,max) - -end - diff --git a/src/MATLAB/+ImProc/ContrastEnhancement.m b/src/MATLAB/+ImProc/ContrastEnhancement.m deleted file mode 100644 index 5ccdec2860eb191872d695f0f648541923ba69f1..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/ContrastEnhancement.m +++ /dev/null @@ -1,49 +0,0 @@ -% ContrastEnhancement - This attempts to increase contrast by removing noise as proposed by Michel et al. This starts with subtracting off a highly smoothed version of imageIn followed by median filter. -% imageOut = ImProc.ContrastEnhancement(imageIn,sigma,MedianNeighborhood); -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Sigma -- these values will create a n-dimensional Gaussian kernel to get a smoothed image that will be subtracted of the original. -% N is the number of dimensions of imageIn -% The larger the sigma the more object preserving the high pass filter will be (e.g. sigma > 35) -% MedianNeighborhood -- this is the neighborhood size in each dimension that will be evaluated for the median neighborhood filter. -% ImageOut -- will have the same dimensions and type as imageIn. -function imageOut = ContrastEnhancement(imageIn,sigma,MedianNeighborhood,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.ContrastEnhancement(imageIn,sigma,MedianNeighborhood,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclContrastEnhancement(imageIn,sigma,MedianNeighborhood); - end -end - -function imageOut = lclContrastEnhancement(imageIn,sigma,MedianNeighborhood) - if (ismatrix(imageIn)) - imGauss = imgaussfilt(imageIn,sigma); - else - imGauss = imgaussfilt3(imageIn,sigma); - end - - imageOut = imageIn - imGauss; - - if (ismatrix(imageIn)) - imageOut = medfilt2(imageOut,MedianNeighborhood([1,2])); - else - imageOut = medfilt3(imageOut,MedianNeighborhood); - end - - imageOut(imageOut<0) = 0; -end - diff --git a/src/MATLAB/+ImProc/EntropyFilter.m b/src/MATLAB/+ImProc/EntropyFilter.m deleted file mode 100644 index 6e13de108de8faa229e598ab7d0700edc778eeab..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/EntropyFilter.m +++ /dev/null @@ -1,29 +0,0 @@ -% EntropyFilter - imageOut = EntropyFilter(imageIn,kernel,device) -function imageOut = EntropyFilter(imageIn,kernel,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.EntropyFilter(imageIn,kernel,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclEntropyFilter(imageIn,kernel); - end -end - -function imageOut = lclEntropyFilter(imageIn,kernel) - imageOut = entropyfilt(imageIn,ones(size(kernel))); - %warning('Falling back to MATLAB version which uses a square nhood and not the kernel passed in.'); -end - diff --git a/src/MATLAB/+ImProc/GaussianFilter.m b/src/MATLAB/+ImProc/GaussianFilter.m deleted file mode 100644 index c3e5556025b50f180b7fc0418f0664275e643bac..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/GaussianFilter.m +++ /dev/null @@ -1,36 +0,0 @@ -% GaussianFilter - Smooths image using a Gaussian kernel. -% imageOut = ImProc.GaussianFilter(imageIn,sigma); -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Sigma -- these values will create a n-dimensional Gaussian kernel to get a smoothed image that will be subtracted of the original. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function imageOut = GaussianFilter(imageIn,sigma,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.GaussianFilter(imageIn,sigma,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclGaussianFilter(imageIn,sigma); - end -end - -function imageOut = lclGaussianFilter(imageIn,sigma) - if (ismatrix(imageIn)) - imageOut = imgaussfilt(imageIn,sigma); - else - imageOut = imgaussfilt3(imageIn,sigma); - end -end - diff --git a/src/MATLAB/+ImProc/Histogram.m b/src/MATLAB/+ImProc/Histogram.m deleted file mode 100644 index 0264b30d204c9d518f6fac39bce75e9f15c00e46..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/Histogram.m +++ /dev/null @@ -1,36 +0,0 @@ -% Histogram - Creates a histogram array with numBins bins between min/max values. -% histogram = ImProc.Histogram(imageIn,numBins,min,max); -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% NumBins -- number of bins that the histogram should partition the signal into. -% Min -- this is the minimum value for the histogram. -% If min is not provided, the min of the image type is used. -% Max -- this is the maximum value for the histogram. -% If min is not provided, the min of the image type is used. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function histogram = Histogram(imageIn,numBins,min,max,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - histogram = ImProc.Cuda.Histogram(imageIn,numBins,min,max,I); - catch errMsg - throw(errMsg); - end - - else - histogram = lclHistogram(imageIn,numBins,min,max); - end -end - -function histogram = lclHistogram(imageIn,numBins,min,max) - -end - diff --git a/src/MATLAB/+ImProc/ImagePow.m b/src/MATLAB/+ImProc/ImagePow.m deleted file mode 100644 index 2fda2b54ede103d66f7b2b6deec1384369298bc2..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/ImagePow.m +++ /dev/null @@ -1,32 +0,0 @@ -% ImagePow - This will raise each voxel value to the power provided. -% imageOut = ImProc.ImagePow(imageIn,power); -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Power -- must be a double. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function imageOut = ImagePow(imageIn,power,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.ImagePow(imageIn,power,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclImagePow(imageIn,power); - end -end - -function imageOut = lclImagePow(imageIn,power) - imageOut = imageIn .^power; -end - diff --git a/src/MATLAB/+ImProc/LinearUnmixing.m b/src/MATLAB/+ImProc/LinearUnmixing.m deleted file mode 100644 index d5d816274b6e155b581d15e2b36e88368c349850..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/LinearUnmixing.m +++ /dev/null @@ -1,28 +0,0 @@ -% LinearUnmixing - imageOut = LinearUnmixing(mixedImages,unmixMatrix,device) -function imageOut = LinearUnmixing(mixedImages,unmixMatrix,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.LinearUnmixing(mixedImages,unmixMatrix,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclLinearUnmixing(mixedImages,unmixMatrix); - end -end - -function imageOut = lclLinearUnmixing(mixedImages,unmixMatrix) - -end - diff --git a/src/MATLAB/+ImProc/LoG.m b/src/MATLAB/+ImProc/LoG.m deleted file mode 100644 index 9656ae8a2957aed6753f74ae589bf3c6f52e645c..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/LoG.m +++ /dev/null @@ -1,38 +0,0 @@ -% LoG - Smooths image using a Gaussian kernel. -% imageOut = ImProc.LoG(imageIn,sigma); -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Sigma -- these values will create a n-dimensional Gaussian kernel to get a smoothed image that will be subtracted of the original. -% ImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space. -function imageOut = LoG(imageIn,sigma,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.LoG(imageIn,sigma,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclLoG(imageIn,sigma); - end -end - -function imageOut = lclLoG(imageIn,sigma) - if (ismatrix(imageIn)) - sz = sigma.*10; - h = fspecial('log',sz([1,2]),sigma([1,2])); - imageOut = imfilter(imageIn,h); - else - - end -end - diff --git a/src/MATLAB/+ImProc/MarkovRandomFieldDenoiser.m b/src/MATLAB/+ImProc/MarkovRandomFieldDenoiser.m deleted file mode 100644 index 4daffabebbd1a2f1298352905199cc78504839c8..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MarkovRandomFieldDenoiser.m +++ /dev/null @@ -1,28 +0,0 @@ -% MarkovRandomFieldDenoiser - imageOut = MarkovRandomFieldDenoiser(imageIn,maxIterations,device) -function imageOut = MarkovRandomFieldDenoiser(imageIn,maxIterations,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MarkovRandomFieldDenoiser(imageIn,maxIterations,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMarkovRandomFieldDenoiser(imageIn,maxIterations); - end -end - -function imageOut = lclMarkovRandomFieldDenoiser(imageIn,maxIterations) - -end - diff --git a/src/MATLAB/+ImProc/MaxFilterEllipsoid.m b/src/MATLAB/+ImProc/MaxFilterEllipsoid.m deleted file mode 100644 index 7f363dcccc99c81b6e19b21493a514a1484dc4e4..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MaxFilterEllipsoid.m +++ /dev/null @@ -1,32 +0,0 @@ -% MaxFilterEllipsoid - imageOut = MaxFilterEllipsoid(imageIn,radius,device) -function imageOut = MaxFilterEllipsoid(imageIn,radius,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MaxFilterEllipsoid(imageIn,radius,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMaxFilterEllipsoid(imageIn,radius); - end -end - -function imageOut = lclMaxFilterEllipsoid(imageIn,radius) - se = ImProc.MakeEllipsoidMask(radius); - if (ismatrix(imageIn)) - se = se(:,:,round(size(se,3)/2)); - end - -end - diff --git a/src/MATLAB/+ImProc/MaxFilterKernel.m b/src/MATLAB/+ImProc/MaxFilterKernel.m deleted file mode 100644 index 168a8753e8b1855196b54d9423ff8ae767d88610..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MaxFilterKernel.m +++ /dev/null @@ -1,28 +0,0 @@ -% MaxFilterKernel - imageOut = MaxFilterKernel(imageIn,kernel,device) -function imageOut = MaxFilterKernel(imageIn,kernel,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MaxFilterKernel(imageIn,kernel,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMaxFilterKernel(imageIn,kernel); - end -end - -function imageOut = lclMaxFilterKernel(imageIn,kernel) - -end - diff --git a/src/MATLAB/+ImProc/MaxFilterNeighborhood.m b/src/MATLAB/+ImProc/MaxFilterNeighborhood.m deleted file mode 100644 index d3f1820700be20d8f1da8aa684a199e2951c5ee6..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MaxFilterNeighborhood.m +++ /dev/null @@ -1,28 +0,0 @@ -% MaxFilterNeighborhood - imageOut = MaxFilterNeighborhood(imageIn,Neighborhood,device) -function imageOut = MaxFilterNeighborhood(imageIn,Neighborhood,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MaxFilterNeighborhood(imageIn,Neighborhood,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMaxFilterNeighborhood(imageIn,Neighborhood); - end -end - -function imageOut = lclMaxFilterNeighborhood(imageIn,Neighborhood) - -end - diff --git a/src/MATLAB/+ImProc/MeanFilter.m b/src/MATLAB/+ImProc/MeanFilter.m deleted file mode 100644 index 5ebbbea65773c95441350dd26d0f7c0f1653b012..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MeanFilter.m +++ /dev/null @@ -1,28 +0,0 @@ -% MeanFilter - imageOut = MeanFilter(imageIn,Neighborhood,device) -function imageOut = MeanFilter(imageIn,Neighborhood,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MeanFilter(imageIn,Neighborhood,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMeanFilter(imageIn,Neighborhood); - end -end - -function imageOut = lclMeanFilter(imageIn,Neighborhood) - -end - diff --git a/src/MATLAB/+ImProc/MedianFilter.m b/src/MATLAB/+ImProc/MedianFilter.m deleted file mode 100644 index e5c171e8a00da5a855c50f35a4cd877bf9b9b631..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MedianFilter.m +++ /dev/null @@ -1,32 +0,0 @@ -% MedianFilter - imageOut = MedianFilter(imageIn,Neighborhood,device) -function imageOut = MedianFilter(imageIn,Neighborhood,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MedianFilter(imageIn,Neighborhood,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMedianFilter(imageIn,Neighborhood); - end -end - -function imageOut = lclMedianFilter(imageIn,Neighborhood) - if (ismatrix(imageIn)) - imageOut = medfilt2(imageIn, Neighborhood([1,2])); - else - imageOut = medfilt3(imageIn,Neighborhood); - end -end - diff --git a/src/MATLAB/+ImProc/MinFilterEllipsoid.m b/src/MATLAB/+ImProc/MinFilterEllipsoid.m deleted file mode 100644 index 04fa0537659b2b47df3ee7c171a3d61c53bb8a38..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MinFilterEllipsoid.m +++ /dev/null @@ -1,28 +0,0 @@ -% MinFilterEllipsoid - imageOut = MinFilterEllipsoid(imageIn,radius,device) -function imageOut = MinFilterEllipsoid(imageIn,radius,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MinFilterEllipsoid(imageIn,radius,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMinFilterEllipsoid(imageIn,radius); - end -end - -function imageOut = lclMinFilterEllipsoid(imageIn,radius) - -end - diff --git a/src/MATLAB/+ImProc/MinFilterKernel.m b/src/MATLAB/+ImProc/MinFilterKernel.m deleted file mode 100644 index 9552f2d3034e9d75c1b4939afaac3c6079f7dd7d..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MinFilterKernel.m +++ /dev/null @@ -1,28 +0,0 @@ -% MinFilterKernel - imageOut = MinFilterKernel(imageIn,kernel,device) -function imageOut = MinFilterKernel(imageIn,kernel,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MinFilterKernel(imageIn,kernel,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMinFilterKernel(imageIn,kernel); - end -end - -function imageOut = lclMinFilterKernel(imageIn,kernel) - -end - diff --git a/src/MATLAB/+ImProc/MinFilterNeighborhood.m b/src/MATLAB/+ImProc/MinFilterNeighborhood.m deleted file mode 100644 index 57f54cdcec1e97eef0a495786e7dc6e13bc13b22..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MinFilterNeighborhood.m +++ /dev/null @@ -1,28 +0,0 @@ -% MinFilterNeighborhood - imageOut = MinFilterNeighborhood(imageIn,Neighborhood,device) -function imageOut = MinFilterNeighborhood(imageIn,Neighborhood,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MinFilterNeighborhood(imageIn,Neighborhood,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMinFilterNeighborhood(imageIn,Neighborhood); - end -end - -function imageOut = lclMinFilterNeighborhood(imageIn,Neighborhood) - -end - diff --git a/src/MATLAB/+ImProc/MinMax.m b/src/MATLAB/+ImProc/MinMax.m deleted file mode 100644 index 12e5315fed66a727b0ed4afb6b35c1110e97947a..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MinMax.m +++ /dev/null @@ -1,29 +0,0 @@ -% MinMax - [min,max] = MinMax(imageIn,device) -function [minVal,maxVal] = MinMax(imageIn,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - [minVal,maxVal] = ImProc.Cuda.MinMax(imageIn,I); - catch errMsg - throw(errMsg); - end - - else - [minVal,maxVal] = lclMinMax(imageIn); - end -end - -function [minVal,maxVal] = lclMinMax(imageIn) - minVal = min(imageIn(:)); - maxVal = max(imageIn(:)); -end - diff --git a/src/MATLAB/+ImProc/MorphologicalClosure.m b/src/MATLAB/+ImProc/MorphologicalClosure.m deleted file mode 100644 index 6d8a13f34e0904764a6764bd9365323e74386614..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MorphologicalClosure.m +++ /dev/null @@ -1,28 +0,0 @@ -% MorphologicalClosure - imageOut = MorphologicalClosure(imageIn,kernel,device) -function imageOut = MorphologicalClosure(imageIn,kernel,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MorphologicalClosure(imageIn,kernel,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMorphologicalClosure(imageIn,kernel); - end -end - -function imageOut = lclMorphologicalClosure(imageIn,kernel) - -end - diff --git a/src/MATLAB/+ImProc/MorphologicalOpening.m b/src/MATLAB/+ImProc/MorphologicalOpening.m deleted file mode 100644 index ea8f6a12b2670cbc8fdaca1ca9bc90bd36b1d93d..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MorphologicalOpening.m +++ /dev/null @@ -1,28 +0,0 @@ -% MorphologicalOpening - imageOut = MorphologicalOpening(imageIn,kernel,device) -function imageOut = MorphologicalOpening(imageIn,kernel,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MorphologicalOpening(imageIn,kernel,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMorphologicalOpening(imageIn,kernel); - end -end - -function imageOut = lclMorphologicalOpening(imageIn,kernel) - -end - diff --git a/src/MATLAB/+ImProc/MultiplyImage.m b/src/MATLAB/+ImProc/MultiplyImage.m deleted file mode 100644 index 3f3f09526637c5ba41f857d935357f5be8157fd2..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MultiplyImage.m +++ /dev/null @@ -1,28 +0,0 @@ -% MultiplyImage - imageOut = MultiplyImage(imageIn,multiplier,device) -function imageOut = MultiplyImage(imageIn,multiplier,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MultiplyImage(imageIn,multiplier,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMultiplyImage(imageIn,multiplier); - end -end - -function imageOut = lclMultiplyImage(imageIn,multiplier) - imageOut = imageIn .*multiplier; -end - diff --git a/src/MATLAB/+ImProc/MultiplyTwoImages.m b/src/MATLAB/+ImProc/MultiplyTwoImages.m deleted file mode 100644 index 021529768be17be733195f8f595ac74c793ea65a..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/MultiplyTwoImages.m +++ /dev/null @@ -1,28 +0,0 @@ -% MultiplyTwoImages - imageOut = MultiplyTwoImages(imageIn1,imageIn2,factor,device) -function imageOut = MultiplyTwoImages(imageIn1,imageIn2,factor,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.MultiplyTwoImages(imageIn1,imageIn2,factor,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclMultiplyTwoImages(imageIn1,imageIn2,factor); - end -end - -function imageOut = lclMultiplyTwoImages(imageIn1,imageIn2,factor) - imageOut = imageIn1 .* imageIn2 .* factor; -end - diff --git a/src/MATLAB/+ImProc/NeighborhoodSum.m b/src/MATLAB/+ImProc/NeighborhoodSum.m deleted file mode 100644 index 0cc77a1dc3b3359a07c126ec9046c8ad3ef15baf..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/NeighborhoodSum.m +++ /dev/null @@ -1,28 +0,0 @@ -% NeighborhoodSum - imageOut = NeighborhoodSum(imageIn,Neighborhood,device) -function imageOut = NeighborhoodSum(imageIn,Neighborhood,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.NeighborhoodSum(imageIn,Neighborhood,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclNeighborhoodSum(imageIn,Neighborhood); - end -end - -function imageOut = lclNeighborhoodSum(imageIn,Neighborhood) - -end - diff --git a/src/MATLAB/+ImProc/NormalizedCovariance.m b/src/MATLAB/+ImProc/NormalizedCovariance.m deleted file mode 100644 index 517c9403167872a38932ae59a1d536548d137ba5..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/NormalizedCovariance.m +++ /dev/null @@ -1,28 +0,0 @@ -% NormalizedCovariance - normalizedCovariance = NormalizedCovariance(imageIn1,imageIn2,device) -function normalizedCovariance = NormalizedCovariance(imageIn1,imageIn2,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - normalizedCovariance = ImProc.Cuda.NormalizedCovariance(imageIn1,imageIn2,I); - catch errMsg - throw(errMsg); - end - - else - normalizedCovariance = lclNormalizedCovariance(imageIn1,imageIn2); - end -end - -function normalizedCovariance = lclNormalizedCovariance(imageIn1,imageIn2) - -end - diff --git a/src/MATLAB/+ImProc/NormalizedHistogram.m b/src/MATLAB/+ImProc/NormalizedHistogram.m deleted file mode 100644 index c2cb4cf53a6dc5ce3b0f011830b8cfb87ea96f7e..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/NormalizedHistogram.m +++ /dev/null @@ -1,28 +0,0 @@ -% NormalizedHistogram - histogram = NormalizedHistogram(imageIn,numBins,min,max,device) -function histogram = NormalizedHistogram(imageIn,numBins,min,max,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - histogram = ImProc.Cuda.NormalizedHistogram(imageIn,numBins,min,max,I); - catch errMsg - throw(errMsg); - end - - else - histogram = lclNormalizedHistogram(imageIn,numBins,min,max); - end -end - -function histogram = lclNormalizedHistogram(imageIn,numBins,min,max) - -end - diff --git a/src/MATLAB/+ImProc/OtsuThresholdFilter.m b/src/MATLAB/+ImProc/OtsuThresholdFilter.m deleted file mode 100644 index f53f1b919a7bd8afb7fea84cb86959411be1b428..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/OtsuThresholdFilter.m +++ /dev/null @@ -1,28 +0,0 @@ -% OtsuThresholdFilter - imageOut = OtsuThresholdFilter(imageIn,alpha,device) -function imageOut = OtsuThresholdFilter(imageIn,alpha,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.OtsuThresholdFilter(imageIn,alpha,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclOtsuThresholdFilter(imageIn,alpha); - end -end - -function imageOut = lclOtsuThresholdFilter(imageIn,alpha) - -end - diff --git a/src/MATLAB/+ImProc/OtsuThresholdValue.m b/src/MATLAB/+ImProc/OtsuThresholdValue.m deleted file mode 100644 index c0d043e804fc7e51b6d70d65477637810b8d315a..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/OtsuThresholdValue.m +++ /dev/null @@ -1,28 +0,0 @@ -% OtsuThresholdValue - threshold = OtsuThresholdValue(imageIn,device) -function threshold = OtsuThresholdValue(imageIn,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - threshold = ImProc.Cuda.OtsuThresholdValue(imageIn,I); - catch errMsg - throw(errMsg); - end - - else - threshold = lclOtsuThresholdValue(imageIn); - end -end - -function threshold = lclOtsuThresholdValue(imageIn) - -end - diff --git a/src/MATLAB/+ImProc/RegionGrowing.m b/src/MATLAB/+ImProc/RegionGrowing.m deleted file mode 100644 index 3145b5cc2a111c66b11b74cbbdeeb89d7df36151..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/RegionGrowing.m +++ /dev/null @@ -1,32 +0,0 @@ -% RegionGrowing - This will create a mask that grows by a delta value. If a neighboring voxel is masked and the current voxel intensity is +/- delta from the masked intensity, then the current voxel is added to the mask. -% maskOut = ImProc.RegionGrowing(imageIn,kernel,mask,threshold,allowConnections); -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% Kernel -- this -% -function maskOut = RegionGrowing(imageIn,kernel,mask,threshold,allowConnections,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - maskOut = ImProc.Cuda.RegionGrowing(imageIn,kernel,mask,threshold,allowConnections,I); - catch errMsg - throw(errMsg); - end - - else - maskOut = lclRegionGrowing(imageIn,kernel,mask,threshold,allowConnections); - end -end - -function maskOut = lclRegionGrowing(imageIn,kernel,mask,threshold,allowConnections) - -end - diff --git a/src/MATLAB/+ImProc/Resize.m b/src/MATLAB/+ImProc/Resize.m deleted file mode 100644 index 065076ef6c53442082ed6c7d3045832e28d79cf7..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/Resize.m +++ /dev/null @@ -1,47 +0,0 @@ -% Resize - Resizes image using various methods. -% imageOut = ImProc.Resize(imageIn,resizeFactor,explicitSize,method); -% ImageIn -- can be an image up to three dimensions and of type (logical,uint8,int8,uint16,int16,uint32,int32,single,double). -% ResizeFactor_rcz -- This represents the output size relative to input (r,c,z). Values less than one but greater than zero will reduce the image. -% Values greater than one will enlarge the image. If this is an empty array, it will be calculated from the explicit resize. -% If both resizeFactor and explicitSize are both set, the explicitSize will be used. -% ExplicitSize_rcz -- This is the size that the output should be (r,c,z). If this is an empty array, then the resize factor is used. -% If both resizeFactor and explicitSize are both set, the explicitSize will be used. -% Method -- This is the neighborhood operation to apply when resizing (mean, median, min, max, gaussian). -% ImageOut -- This will be a resize image the same type as the input image. -function imageOut = Resize(imageIn,resizeFactor,explicitSize,method,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.Resize(imageIn,resizeFactor,explicitSize,method,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclResize(imageIn,resizeFactor,explicitSize); - end -end - -function imageOut = lclResize(imageIn,resizeFactor,explicitSize) - if (ismatrix(imageIn)) - if (isempty(explicitSize)) - explicitSize = round(size(imageIn).*resizeFactor([1,2])); - end - imageOut = imresize(imageIn,explicitSize,'bilinear'); - else - if (isempty(explicitSize)) - explicitSize = round(size(imageIn).*resizeFactor); - end - imageOut = imresize3(imageIn,explicitSize,'linear'); - end -end - diff --git a/src/MATLAB/+ImProc/Segment.m b/src/MATLAB/+ImProc/Segment.m deleted file mode 100644 index 4e6e780c69732c92667885f1c22adb74025bf63e..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/Segment.m +++ /dev/null @@ -1,28 +0,0 @@ -% Segment - imageOut = Segment(imageIn,alpha,MorphClosure,device) -function imageOut = Segment(imageIn,alpha,MorphClosure,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.Segment(imageIn,alpha,MorphClosure,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclSegment(imageIn,alpha,MorphClosure); - end -end - -function imageOut = lclSegment(imageIn,alpha,MorphClosure) - -end - diff --git a/src/MATLAB/+ImProc/StdFilter.m b/src/MATLAB/+ImProc/StdFilter.m deleted file mode 100644 index 2d36c9ea580126e175820c9ef02754b521c6aca5..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/StdFilter.m +++ /dev/null @@ -1,28 +0,0 @@ -% StdFilter - imageOut = StdFilter(imageIn,Neighborhood,device) -function imageOut = StdFilter(imageIn,Neighborhood,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.StdFilter(imageIn,Neighborhood,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclStdFilter(imageIn,Neighborhood); - end -end - -function imageOut = lclStdFilter(imageIn,Neighborhood) - imageOut = stdfilt(imageIn,ones(Neighborhood)); -end - diff --git a/src/MATLAB/+ImProc/SumArray.m b/src/MATLAB/+ImProc/SumArray.m deleted file mode 100644 index 0417bd017b1cd89dfc0167bf036eafea548184b8..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/SumArray.m +++ /dev/null @@ -1,28 +0,0 @@ -% SumArray - sum = SumArray(imageIn,device) -function sumVal = SumArray(imageIn,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - sumVal = ImProc.Cuda.SumArray(imageIn,I); - catch errMsg - throw(errMsg); - end - - else - sumVal = lclSumArray(imageIn); - end -end - -function sumVal = lclSumArray(imageIn) - sumVal = sum(imageIn(:)); -end - diff --git a/src/MATLAB/+ImProc/ThresholdFilter.m b/src/MATLAB/+ImProc/ThresholdFilter.m deleted file mode 100644 index a8e92f3a9dff58308327552d463f7d646297cfac..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/ThresholdFilter.m +++ /dev/null @@ -1,28 +0,0 @@ -% ThresholdFilter - imageOut = ThresholdFilter(imageIn,threshold,device) -function imageOut = ThresholdFilter(imageIn,threshold,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.ThresholdFilter(imageIn,threshold,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclThresholdFilter(imageIn,threshold); - end -end - -function imageOut = lclThresholdFilter(imageIn,threshold) - -end - diff --git a/src/MATLAB/+ImProc/TileImage.m b/src/MATLAB/+ImProc/TileImage.m deleted file mode 100644 index 3d7a999d617340c9383935ed0d0ea277f97ea8cb..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/TileImage.m +++ /dev/null @@ -1,33 +0,0 @@ -% TileImage - This will output an image that only consists of the region of interest indicated. -% imageOut = ImProc.TileImage(imageIn,roiStart,roiSize); -% ImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double). -% RoiStart -- this is the location of the first voxel in the region of interest (starting from the origin). Must be the same dimension as imageIn. -% RoiSize -- this is how many voxels to include starting from roiStart. Must be the same dimension as imageIn. -% ImageOut -- this will be an image that only contains the region of interest indicated. -function imageOut = TileImage(imageIn,roiStart,roiSize,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - imageOut = ImProc.Cuda.TileImage(imageIn,roiStart,roiSize,I); - catch errMsg - throw(errMsg); - end - - else - imageOut = lclTileImage(imageIn,roiStart,roiSize); - end -end - -function imageOut = lclTileImage(imageIn,roiStart,roiSize) - -end - diff --git a/src/MATLAB/+ImProc/Variance.m b/src/MATLAB/+ImProc/Variance.m deleted file mode 100644 index e4bd4467abb9f635965c0dfa6187824d6f6275d8..0000000000000000000000000000000000000000 --- a/src/MATLAB/+ImProc/Variance.m +++ /dev/null @@ -1,28 +0,0 @@ -% Variance - variance = Variance(imageIn,device) This will return the variance of an image. -function variance = Variance(imageIn,forceMATLAB) - if (~exist('forceMATLAB','var') || isempty(forceMATLAB)) - forceMATLAB = false; - end - - % check for Cuda capable devices - [devCount,m] = ImProc.Cuda.DeviceCount(); - n = length(devCount); - - % if there are devices find the availble one and grab the mutex - if (n>0 && ~forceMATLAB) - [~,I] = max([m.available]); - try - variance = ImProc.Cuda.Variance(imageIn,I); - catch errMsg - throw(errMsg); - end - - else - variance = lclVariance(imageIn); - end -end - -function variance = lclVariance(imageIn) - -end - diff --git a/src/c/Cuda/CWrappers.cu b/src/c/Cuda/CWrappers.cu index 2e6cd94dd165a3a340cc6dea3959e04ea7932c5a..a41541b4bbf38f4b4742bdbefbc49f0009a78233 100644 --- a/src/c/Cuda/CWrappers.cu +++ b/src/c/Cuda/CWrappers.cu @@ -1,1225 +1,26 @@ #include "CWrappers.h" -#include "CudaAdd.cuh" -#include "CudaContrastEnhancement.cuh" +#include "ImageContainer.h" #include "CudaDeviceCount.cuh" #include "CudaDeviceStats.h" -#include "CudaEntropyFilter.cuh" -#include "CudaHistogram.cuh" -#include "CudaImageCopy.cuh" -#include "CudaGaussianFilter.cuh" -#include "CudaGetMinMax.cuh" -#include "CudaLinearUnmixing.cuh" -#include "CudaLoG.cuh" -#include "CudaMarkovRandomFieldDenoiser.cuh" -#include "CudaMaxFilter.cuh" -#include "CudaMeanFilter.cuh" -#include "CudaMedianFilter.cuh" #include "CudaMemoryStats.cuh" -#include "CudaMinFilter.cuh" -#include "CudaMorphologicalOperations.cuh" -#include "CudaMultiplyImage.cuh" -#include "CudaNeighborhoodSum.cuh" -#include "CudaNormalizedCovariance.cuh" -#include "CudaPolyTransferFunc.cuh" -#include "CudaPow.cuh" -#include "CudaRegionGrowing.cuh" -#include "CudaResize.cuh" -#include "CudaSegment.cuh" -#include "CudaStdFilter.cuh" -#include "CudaSum.cuh" -#include "CudaThreshold.cuh" -#include "CudaVariance.cuh" + void clearDevice() { cudaDeviceReset(); } - unsigned char* addConstant(const unsigned char* imageIn, Vec<size_t> dims, double additive, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddConstant(imageIn,dims,additive,imageOut,device); -} - - unsigned short* addConstant(const unsigned short* imageIn, Vec<size_t> dims, double additive, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddConstant(imageIn,dims,additive,imageOut,device); -} - - short* addConstant(const short* imageIn, Vec<size_t> dims, double additive, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddConstant(imageIn,dims,additive,imageOut,device); -} - - unsigned int* addConstant(const unsigned int* imageIn, Vec<size_t> dims, double additive, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddConstant(imageIn,dims,additive,imageOut,device); -} - - int* addConstant(const int* imageIn, Vec<size_t> dims, double additive, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddConstant(imageIn,dims,additive,imageOut,device); -} - - float* addConstant(const float* imageIn, Vec<size_t> dims, double additive, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddConstant(imageIn,dims,additive,imageOut,device); -} - - double* addConstant(const double* imageIn, Vec<size_t> dims, double additive, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddConstant(imageIn,dims,additive,imageOut,device); -} - - - unsigned char* applyPolyTransferFunction(const unsigned char* imageIn, Vec<size_t> dims, double a, double b, double c, unsigned char minValue/*=std::numeric_limits<PixelType>::lowest()*/, unsigned char maxValue/*=std::numeric_limits<PixelType>::max()*/, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cApplyPolyTransferFunction(imageIn,dims,a,b,c,minValue,maxValue,imageOut,device); -} - - unsigned short* applyPolyTransferFunction(const unsigned short* imageIn, Vec<size_t> dims, double a, double b, double c, unsigned short minValue/*=std::numeric_limits<PixelType>::lowest()*/, unsigned short maxValue/*=std::numeric_limits<PixelType>::max()*/, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cApplyPolyTransferFunction(imageIn,dims,a,b,c,minValue,maxValue,imageOut,device); -} - - short* applyPolyTransferFunction(const short* imageIn, Vec<size_t> dims, double a, double b, double c, short minValue/*=std::numeric_limits<PixelType>::lowest()*/, short maxValue/*=std::numeric_limits<PixelType>::max()*/, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cApplyPolyTransferFunction(imageIn,dims,a,b,c,minValue,maxValue,imageOut,device); -} - - unsigned int* applyPolyTransferFunction(const unsigned int* imageIn, Vec<size_t> dims, double a, double b, double c, unsigned int minValue/*=std::numeric_limits<PixelType>::lowest()*/, unsigned int maxValue/*=std::numeric_limits<PixelType>::max()*/, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cApplyPolyTransferFunction(imageIn,dims,a,b,c,minValue,maxValue,imageOut,device); -} - - int* applyPolyTransferFunction(const int* imageIn, Vec<size_t> dims, double a, double b, double c, int minValue/*=std::numeric_limits<PixelType>::lowest()*/, int maxValue/*=std::numeric_limits<PixelType>::max()*/, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cApplyPolyTransferFunction(imageIn,dims,a,b,c,minValue,maxValue,imageOut,device); -} - - float* applyPolyTransferFunction(const float* imageIn, Vec<size_t> dims, double a, double b, double c, float minValue/*=std::numeric_limits<PixelType>::lowest()*/, float maxValue/*=std::numeric_limits<PixelType>::max()*/, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cApplyPolyTransferFunction(imageIn,dims,a,b,c,minValue,maxValue,imageOut,device); -} - - double* applyPolyTransferFunction(const double* imageIn, Vec<size_t> dims, double a, double b, double c, double minValue/*=std::numeric_limits<PixelType>::lowest()*/, double maxValue/*=std::numeric_limits<PixelType>::max()*/,double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cApplyPolyTransferFunction(imageIn,dims,a,b,c,minValue,maxValue,imageOut,device); -} - - - unsigned char* addImageWith(const unsigned char* imageIn1, const unsigned char* imageIn2, Vec<size_t> dims, double additive, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddImageWith(imageIn1,imageIn2,dims,additive,imageOut,device); -} - - unsigned short* addImageWith(const unsigned short* imageIn1, const unsigned short* imageIn2, Vec<size_t> dims, double additive, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddImageWith(imageIn1,imageIn2,dims,additive,imageOut,device); -} - - short* addImageWith(const short* imageIn1, const short* imageIn2, Vec<size_t> dims, double additive, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddImageWith(imageIn1,imageIn2,dims,additive,imageOut,device); -} - - unsigned int* addImageWith(const unsigned int* imageIn1, const unsigned int* imageIn2, Vec<size_t> dims, double additive, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddImageWith(imageIn1,imageIn2,dims,additive,imageOut,device); -} - - int* addImageWith(const int* imageIn1, const int* imageIn2, Vec<size_t> dims, double additive, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddImageWith(imageIn1,imageIn2,dims,additive,imageOut,device); -} - - float* addImageWith(const float* imageIn1, const float* imageIn2, Vec<size_t> dims, double additive, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddImageWith(imageIn1,imageIn2,dims,additive,imageOut,device); -} - - double* addImageWith(const double* imageIn1, const double* imageIn2, Vec<size_t> dims, double additive, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddImageWith(imageIn1,imageIn2,dims,additive,imageOut,device); -} - - - unsigned char* contrastEnhancement(const unsigned char* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cContrastEnhancement(imageIn,dims,sigmas,neighborhood,imageOut,device); -} - - unsigned short* contrastEnhancement(const unsigned short* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cContrastEnhancement(imageIn,dims,sigmas,neighborhood,imageOut,device); -} - - short* contrastEnhancement(const short* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cContrastEnhancement(imageIn,dims,sigmas,neighborhood,imageOut,device); -} - - unsigned int* contrastEnhancement(const unsigned int* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cContrastEnhancement(imageIn,dims,sigmas,neighborhood,imageOut,device); -} - - int* contrastEnhancement(const int* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cContrastEnhancement(imageIn,dims,sigmas,neighborhood,imageOut,device); -} - - float* contrastEnhancement(const float* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cContrastEnhancement(imageIn,dims,sigmas,neighborhood,imageOut,device); -} - - double* contrastEnhancement(const double* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cContrastEnhancement(imageIn,dims,sigmas,neighborhood,imageOut,device); -} - - int deviceCount() { return cDeviceCount(); } - int deviceStats(DevStats** stats) { return cDeviceStats(stats); } - double* entropyFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cEntropyFilter(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* entropyFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cEntropyFilter(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* entropyFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cEntropyFilter(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* entropyFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cEntropyFilter(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* entropyFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cEntropyFilter(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* entropyFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cEntropyFilter(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* entropyFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cEntropyFilter(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - size_t* histogram(const unsigned char* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned char minVal/*=std::numeric_limits<unsigned char>::lowest()*/, unsigned char maxVal/*=std::numeric_limits<unsigned char>::max()*/, int device/*=0*/) -{ - return cCalculateHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - size_t* histogram(const unsigned short* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned short minVal/*=std::numeric_limits<unsigned short>::lowest()*/, unsigned short maxVal/*=std::numeric_limits<unsigned short>::max()*/, int device/*=0*/) -{ - return cCalculateHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - size_t* histogram(const short* imageIn, Vec<size_t> dims, unsigned int arraySize, short minVal/*=std::numeric_limits<short>::lowest()*/,short maxVal/*=std::numeric_limits<short>::max()*/, int device/*=0*/) -{ - return cCalculateHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - size_t* histogram(const unsigned int* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned int minVal/*=std::numeric_limits<unsigned short>::lowest()*/, unsigned int maxVal/*=std::numeric_limits<unsigned int>::max()*/, int device/*=0*/) -{ - return cCalculateHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - size_t* histogram(const int* imageIn, Vec<size_t> dims, unsigned int arraySize, int minVal/*=std::numeric_limits<int>::lowest()*/, int maxVal/*=std::numeric_limits<int>::max()*/, int device/*=0*/) -{ - return cCalculateHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - size_t* histogram(const float* imageIn, Vec<size_t> dims, unsigned int arraySize, float minVal/*=std::numeric_limits<float>::lowest()*/, float maxVal/*=std::numeric_limits<float>::max()*/, int device/*=0*/) -{ - return cCalculateHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - size_t* histogram(const double* imageIn, Vec<size_t> dims, unsigned int arraySize, double minVal/*=std::numeric_limits<double>::lowest()*/, double maxVal/*=std::numeric_limits<double>::max()*/, int device/*=0*/) -{ - return cCalculateHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - - unsigned char* gaussianFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<float> sigmas, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cGaussianFilter(imageIn,dims,sigmas,imageOut,device); -} - - unsigned short* gaussianFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<float> sigmas, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cGaussianFilter(imageIn,dims,sigmas,imageOut,device); -} - - short* gaussianFilter(const short* imageIn, Vec<size_t> dims, Vec<float> sigmas, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cGaussianFilter(imageIn,dims,sigmas,imageOut,device); -} - - unsigned int* gaussianFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<float> sigmas, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cGaussianFilter(imageIn,dims,sigmas,imageOut,device); -} - - int* gaussianFilter(const int* imageIn, Vec<size_t> dims, Vec<float> sigmas, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cGaussianFilter(imageIn,dims,sigmas,imageOut,device); -} - - float* gaussianFilter(const float* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cGaussianFilter(imageIn,dims,sigmas,imageOut,device); -} - - double* gaussianFilter(const double* imageIn, Vec<size_t> dims, Vec<float> sigmas, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cGaussianFilter(imageIn,dims,sigmas,imageOut,device); -} - - - void getMinMax(const unsigned char* imageIn, Vec<size_t> dims, unsigned char& minVal, unsigned char& maxVal, int device/*=0*/) -{ - cGetMinMax(imageIn,dims,minVal,maxVal,device); -} - - void getMinMax(const unsigned short* imageIn, Vec<size_t> dims, unsigned short& minVal, unsigned short& maxVal, int device/*=0*/) -{ - cGetMinMax(imageIn,dims,minVal,maxVal,device); -} - - void getMinMax(const short* imageIn, Vec<size_t> dims, short& minVal, short& maxVal, int device/*=0*/) -{ - cGetMinMax(imageIn,dims,minVal,maxVal,device); -} - - void getMinMax(const unsigned int* imageIn, Vec<size_t> dims, unsigned int& minVal, unsigned int& maxVal, int device/*=0*/) -{ - cGetMinMax(imageIn,dims,minVal,maxVal,device); -} - - void getMinMax(const int* imageIn, Vec<size_t> dims, int& minVal, int& maxVal, int device/*=0*/) -{ - cGetMinMax(imageIn,dims,minVal,maxVal,device); -} - - void getMinMax(const float* imageIn, Vec<size_t> dims, float& minVal, float& maxVal, int device/*=0*/) -{ - cGetMinMax(imageIn,dims,minVal,maxVal,device); -} - - void getMinMax(const double* imageIn, Vec<size_t> dims, double& minVal, double& maxVal, int device/*=0*/) -{ - cGetMinMax(imageIn,dims,minVal,maxVal,device); -} - - - unsigned char* imagePow(const unsigned char* imageIn, Vec<size_t> dims, double additive, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cAddConstant(imageIn,dims,additive,imageOut,device); -} - - unsigned short* imagePow(const unsigned short* imageIn, Vec<size_t> dims, double power, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cImagePow(imageIn,dims,power,imageOut,device); -} - - short* imagePow(const short* imageIn, Vec<size_t> dims, double power, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cImagePow(imageIn,dims,power,imageOut,device); -} - - unsigned int* imagePow(const unsigned int* imageIn, Vec<size_t> dims, double power, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cImagePow(imageIn,dims,power,imageOut,device); -} - - int* imagePow(const int* imageIn, Vec<size_t> dims, double power, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cImagePow(imageIn,dims,power,imageOut,device); -} - - float* imagePow(const float* imageIn, Vec<size_t> dims, double power, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cImagePow(imageIn,dims,power,imageOut,device); -} - - double* imagePow(const double* imageIn, Vec<size_t> dims, double power, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cImagePow(imageIn,dims,power,imageOut,device); -} - - - unsigned char* linearUnmixing(const unsigned char* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, unsigned char** imageOut, int device) - { - return cLinearUnmixing(imageIn, imageDims, numImages, unmixing, umixingDims, imageOut, device); - } - - unsigned short* linearUnmixing(const unsigned short* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, unsigned short** imageOut, int device) - { - return cLinearUnmixing(imageIn, imageDims, numImages, unmixing, umixingDims, imageOut, device); - } - - short* linearUnmixing(const short* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, short** imageOut, int device) - { - return cLinearUnmixing(imageIn, imageDims, numImages, unmixing, umixingDims, imageOut, device); - } - - unsigned int* linearUnmixing(const unsigned int* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, unsigned int** imageOut, int device) - { - return cLinearUnmixing(imageIn, imageDims, numImages, unmixing, umixingDims, imageOut, device); - } - - int* linearUnmixing(const int* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, int** imageOut, int device) - { - return cLinearUnmixing(imageIn, imageDims, numImages, unmixing, umixingDims, imageOut, device); - } - - float* linearUnmixing(const float* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, float** imageOut, int device) - { - return cLinearUnmixing(imageIn, imageDims, numImages, unmixing, umixingDims, imageOut, device); - } - - double* linearUnmixing(const double* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, double** imageOut, int device) - { - return cLinearUnmixing(imageIn, imageDims, numImages, unmixing, umixingDims, imageOut, device); - } - - - float* loG(const unsigned char* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut /*= NULL*/, int device /*= 0*/) - { - return cLoGFilter(imageIn, dims, sigmas, imageOut, device); - } - - float* loG(const unsigned short* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut /*= NULL*/, int device /*= 0*/) - { - return cLoGFilter(imageIn, dims, sigmas, imageOut, device); - } - - float* loG(const short* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut /*= NULL*/, int device /*= 0*/) - { - return cLoGFilter(imageIn, dims, sigmas, imageOut, device); - } - - float* loG(const unsigned int* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut /*= NULL*/, int device /*= 0*/) - { - return cLoGFilter(imageIn, dims, sigmas, imageOut, device); - } - - float* loG(const int* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut /*= NULL*/, int device /*= 0*/) - { - return cLoGFilter(imageIn, dims, sigmas, imageOut, device); - } - - float* loG(const float* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut /*= NULL*/, int device /*= 0*/) - { - return cLoGFilter(imageIn, dims, sigmas, imageOut, device); - } - - float* loG(const double* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut /*= NULL*/, int device /*= 0*/) - { - return cLoGFilter(imageIn, dims, sigmas, imageOut, device); - } - - -float* markovRandomFieldDenoiser(const float* imageIn, Vec<size_t> dims, int maxIterations, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMarkovRandomFieldDenoiser(imageIn,dims,maxIterations,imageOut,device); -} - - unsigned char* maxFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMaxFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - unsigned short* maxFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMaxFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - short* maxFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMaxFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - unsigned int* maxFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMaxFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - int* maxFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMaxFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - float* maxFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMaxFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - double* maxFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMaxFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - - unsigned char* meanFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMeanFilter(imageIn,dims,neighborhood,imageOut,device); -} - - unsigned short* meanFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMeanFilter(imageIn,dims,neighborhood,imageOut,device); -} - - short* meanFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMeanFilter(imageIn,dims,neighborhood,imageOut,device); -} - - unsigned int* meanFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMeanFilter(imageIn,dims,neighborhood,imageOut,device); -} - - int* meanFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMeanFilter(imageIn,dims,neighborhood,imageOut,device); -} - - float* meanFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMeanFilter(imageIn,dims,neighborhood,imageOut,device); -} - - double* meanFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMeanFilter(imageIn,dims,neighborhood,imageOut,device); -} - - - unsigned char* medianFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMedianFilter(imageIn,dims,neighborhood,imageOut,device); -} - - unsigned short* medianFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMedianFilter(imageIn,dims,neighborhood,imageOut,device); -} - - short* medianFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMedianFilter(imageIn,dims,neighborhood,imageOut,device); -} - - unsigned int* medianFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMedianFilter(imageIn,dims,neighborhood,imageOut,device); -} - - int* medianFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMedianFilter(imageIn,dims,neighborhood,imageOut,device); -} - - float* medianFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMedianFilter(imageIn,dims,neighborhood,imageOut,device); -} - - double* medianFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMedianFilter(imageIn,dims,neighborhood,imageOut,device); -} - - - int memoryStats(size_t** stats) + int memoryStats(size_t** stats) { return cMemoryStats(stats); } - - unsigned char* minFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMinFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - unsigned short* minFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMinFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - short* minFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMinFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - unsigned int* minFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMinFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - int* minFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMinFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - float* minFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMinFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - double* minFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMinFilter(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - - bool* morphologicalClosure(const bool* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, bool** imageOut /*= NULL*/, int device /*= 0*/) - { - return cMorphologicalClosure(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - unsigned char* morphologicalClosure(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalClosure(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - unsigned short* morphologicalClosure(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalClosure(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - short* morphologicalClosure(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalClosure(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - unsigned int* morphologicalClosure(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalClosure(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - int* morphologicalClosure(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalClosure(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - float* morphologicalClosure(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalClosure(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - double* morphologicalClosure(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalClosure(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - - bool* morphologicalOpening(const bool* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, bool** imageOut/*=NULL*/, int device/*=0*/) - { - return cMorphologicalOpening(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - unsigned char* morphologicalOpening(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalOpening(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - unsigned short* morphologicalOpening(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalOpening(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - short* morphologicalOpening(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalOpening(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - unsigned int* morphologicalOpening(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalOpening(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - int* morphologicalOpening(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalOpening(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - float* morphologicalOpening(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalOpening(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - double* morphologicalOpening(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel/*=NULL*/, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMorphologicalOpening(imageIn,dims,kernelDims,kernel,imageOut,device); -} - - - unsigned char* multiplyImage(const unsigned char* imageIn, Vec<size_t> dims, double multiplier, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImage(imageIn,dims,multiplier,imageOut,device); -} - - unsigned short* multiplyImage(const unsigned short* imageIn, Vec<size_t> dims, double multiplier, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImage(imageIn,dims,multiplier,imageOut,device); -} - - short* multiplyImage(const short* imageIn, Vec<size_t> dims, double multiplier, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImage(imageIn,dims,multiplier,imageOut,device); -} - - unsigned int* multiplyImage(const unsigned int* imageIn, Vec<size_t> dims, double multiplier, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImage(imageIn,dims,multiplier,imageOut,device); -} - - int* multiplyImage(const int* imageIn, Vec<size_t> dims, double multiplier, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImage(imageIn,dims,multiplier,imageOut,device); -} - - float* multiplyImage(const float* imageIn, Vec<size_t> dims, double multiplier, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImage(imageIn,dims,multiplier,imageOut,device); -} - - double* multiplyImage(const double* imageIn, Vec<size_t> dims, double multiplier, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImage(imageIn,dims,multiplier,imageOut,device); -} - - - unsigned char* multiplyImageWith(const unsigned char* imageIn1, const unsigned char* imageIn2, Vec<size_t> dims, double factor, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImageWith(imageIn1,imageIn2,dims,factor,imageOut,device); -} - - unsigned short* multiplyImageWith(const unsigned short* imageIn1, const unsigned short* imageIn2, Vec<size_t> dims, double factor, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImageWith(imageIn1,imageIn2,dims,factor,imageOut,device); -} - - short* multiplyImageWith(const short* imageIn1, const short* imageIn2, Vec<size_t> dims, double factor, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImageWith(imageIn1,imageIn2,dims,factor,imageOut,device); -} - - unsigned int* multiplyImageWith(const unsigned int* imageIn1, const unsigned int* imageIn2, Vec<size_t> dims, double factor, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImageWith(imageIn1,imageIn2,dims,factor,imageOut,device); -} - - int* multiplyImageWith(const int* imageIn1, const int* imageIn2, Vec<size_t> dims, double factor, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImageWith(imageIn1,imageIn2,dims,factor,imageOut,device); -} - - float* multiplyImageWith(const float* imageIn1, const float* imageIn2, Vec<size_t> dims, double factor, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImageWith(imageIn1,imageIn2,dims,factor,imageOut,device); -} - - double* multiplyImageWith(const double* imageIn1, const double* imageIn2, Vec<size_t> dims, double factor, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cMultiplyImageWith(imageIn1,imageIn2,dims,factor,imageOut,device); -} - - unsigned char* neighborhoodSum(const bool* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, unsigned char** imageOut /*= NULL*/, int device /*= 0*/) - { - return cNeighborhoodSum(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - unsigned short* neighborhoodSum(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, unsigned short** imageOut /*= NULL*/, int device /*= 0*/) - { - return cNeighborhoodSum(imageIn,dims,kernelDims,kernel,imageOut,device); - } - - unsigned int* neighborhoodSum(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, unsigned int** imageOut /*= NULL*/, int device /*= 0*/) - { - return cNeighborhoodSum(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - int* neighborhoodSum(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, int** imageOut /*= NULL*/, int device /*= 0*/) - { - return cNeighborhoodSum(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* neighborhoodSum(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cNeighborhoodSum(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* neighborhoodSum(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cNeighborhoodSum(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* neighborhoodSum(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cNeighborhoodSum(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - double* neighborhoodSum(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel /*= NULL*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cNeighborhoodSum(imageIn, dims, kernelDims, kernel, imageOut, device); - } - - - double normalizedCovariance(const unsigned char* imageIn1, const unsigned char* imageIn2, Vec<size_t> dims, int device/*=0*/) -{ - return cNormalizedCovariance(imageIn1,imageIn2,dims,device); -} - - double normalizedCovariance(const unsigned short* imageIn1, const unsigned short* imageIn2, Vec<size_t> dims, int device/*=0*/) -{ - return cNormalizedCovariance(imageIn1,imageIn2,dims,device); -} - - double normalizedCovariance(const short* imageIn1, const short* imageIn2, Vec<size_t> dims, int device/*=0*/) -{ - return cNormalizedCovariance(imageIn1,imageIn2,dims,device); -} - - double normalizedCovariance(const unsigned int* imageIn1, const unsigned int* imageIn2, Vec<size_t> dims, int device/*=0*/) -{ - return cNormalizedCovariance(imageIn1,imageIn2,dims,device); -} - - double normalizedCovariance(const int* imageIn1, const int* imageIn2, Vec<size_t> dims, int device/*=0*/) -{ - return cNormalizedCovariance(imageIn1,imageIn2,dims,device); -} - - double normalizedCovariance(const float* imageIn1, const float* imageIn2, Vec<size_t> dims, int device/*=0*/) -{ - return cNormalizedCovariance(imageIn1,imageIn2,dims,device); -} - - double normalizedCovariance(const double* imageIn1, const double* imageIn2, Vec<size_t> dims, int device/*=0*/) -{ - return cNormalizedCovariance(imageIn1,imageIn2,dims,device); -} - - - double* normalizeHistogram(const unsigned char* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned char minVal/*=std::numeric_limits<unsigned char>::lowest()*/, unsigned char maxVal/*=std::numeric_limits<unsigned char>::max()*/, int device/*=0*/) -{ - return cNormalizeHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - double* normalizeHistogram(const unsigned short* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned short minVal/*=std::numeric_limits<unsigned short>::lowest()*/, unsigned short maxVal/*=std::numeric_limits<unsigned short>::max()*/, int device/*=0*/) -{ - return cNormalizeHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - double* normalizeHistogram(const short* imageIn, Vec<size_t> dims, unsigned int arraySize, short minVal/*=std::numeric_limits<short>::lowest()*/, short maxVal/*=std::numeric_limits<short>::max()*/, int device/*=0*/) -{ - return cNormalizeHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - double* normalizeHistogram(const unsigned int* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned int minVal/*=std::numeric_limits<unsigned int>::lowest()*/, unsigned int maxVal/*=std::numeric_limits<unsigned int>::max()*/, int device/*=0*/) -{ - return cNormalizeHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - double* normalizeHistogram(const int* imageIn, Vec<size_t> dims, unsigned int arraySize, int minVal/*=std::numeric_limits<int>::lowest()*/, int maxVal/*=std::numeric_limits<int>::max()*/, int device/*=0*/) -{ - return cNormalizeHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - double* normalizeHistogram(const float* imageIn, Vec<size_t> dims, unsigned int arraySize, float minVal/*=std::numeric_limits<float>::lowest()*/, float maxVal/*=std::numeric_limits<float>::max()*/, int device/*=0*/) -{ - return cNormalizeHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - double* normalizeHistogram(const double* imageIn, Vec<size_t> dims, unsigned int arraySize, double minVal/*=std::numeric_limits<double>::lowest()*/, double maxVal/*=std::numeric_limits<double>::max()*/, int device/*=0*/) -{ - return cNormalizeHistogram(imageIn,dims,arraySize,minVal,maxVal,device); -} - - - unsigned char* otsuThresholdFilter(const unsigned char* imageIn, Vec<size_t> dims, double alpha/*=1.0*/, unsigned char** imageOut/*=NULL*/, int device/*=0*/) -{ - return cOtsuThresholdFilter(imageIn,dims,alpha,imageOut,device); -} - - unsigned short* otsuThresholdFilter(const unsigned short* imageIn, Vec<size_t> dims, double alpha/*=1.0*/, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cOtsuThresholdFilter(imageIn,dims,alpha,imageOut,device); -} - - short* otsuThresholdFilter(const short* imageIn, Vec<size_t> dims, double alpha/*=1.0*/, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cOtsuThresholdFilter(imageIn,dims,alpha,imageOut,device); -} - - unsigned int* otsuThresholdFilter(const unsigned int* imageIn, Vec<size_t> dims, double alpha/*=1.0*/, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cOtsuThresholdFilter(imageIn,dims,alpha,imageOut,device); -} - - int* otsuThresholdFilter(const int* imageIn, Vec<size_t> dims, double alpha/*=1.0*/, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cOtsuThresholdFilter(imageIn,dims,alpha,imageOut,device); -} - - float* otsuThresholdFilter(const float* imageIn, Vec<size_t> dims, double alpha/*=1.0*/, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cOtsuThresholdFilter(imageIn,dims,alpha,imageOut,device); -} - - double* otsuThresholdFilter(const double* imageIn, Vec<size_t> dims, double alpha/*=1.0*/, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cOtsuThresholdFilter(imageIn,dims,alpha,imageOut,device); -} - - - unsigned char otsuThresholdValue(const unsigned char* imageIn, Vec<size_t> dims, int device/*=0*/) -{ - return cOtsuThresholdValue(imageIn,dims,device); -} - - unsigned short otsuThresholdValue(const unsigned short* imageIn, Vec<size_t> dims, int device/*=0*/) -{ - return cOtsuThresholdValue(imageIn,dims,device); -} - - short otsuThresholdValue(const short* imageIn, Vec<size_t> dims, int device/*=0*/) -{ - return cOtsuThresholdValue(imageIn,dims,device); -} - - unsigned int otsuThresholdValue(const unsigned int* imageIn, Vec<size_t> dims, int device/*=0*/) -{ - return cOtsuThresholdValue(imageIn,dims,device); -} - - int otsuThresholdValue(const int* imageIn, Vec<size_t> dims, int device/*=0*/) -{ - return cOtsuThresholdValue(imageIn,dims,device); -} - - float otsuThresholdValue(const float* imageIn, Vec<size_t> dims, int device/*=0*/) -{ - return cOtsuThresholdValue(imageIn,dims,device); -} - - double otsuThresholdValue(const double* imageIn, Vec<size_t> dims, int device/*=0*/) -{ - return cOtsuThresholdValue(imageIn,dims,device); -} - - - void regionGrowing(const unsigned char* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection/*=true*/,int device/*=0*/) - { - return cRegionGrowing(imageIn,dims,kernelDims,kernel,imageMask,threshold,allowConnection,device); - } - - void regionGrowing(const unsigned short* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection/*=true*/,int device/*=0*/) - { - return cRegionGrowing(imageIn,dims,kernelDims,kernel,imageMask,threshold,allowConnection,device); - } - - void regionGrowing(const short* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection/*=true*/,int device/*=0*/) - { - return cRegionGrowing(imageIn,dims,kernelDims,kernel,imageMask,threshold,allowConnection,device); - } - - void regionGrowing(const unsigned int* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection/*=true*/,int device/*=0*/) - { - return cRegionGrowing(imageIn,dims,kernelDims,kernel,imageMask,threshold,allowConnection,device); - } - - void regionGrowing(const int* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection/*=true*/,int device/*=0*/) - { - return cRegionGrowing(imageIn,dims,kernelDims,kernel,imageMask,threshold,allowConnection,device); - } - - void regionGrowing(const float* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection/*=true*/,int device/*=0*/) - { - return cRegionGrowing(imageIn,dims,kernelDims,kernel,imageMask,threshold,allowConnection,device); - } - - void regionGrowing(const double* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection/*=true*/,int device/*=0*/) - { - return cRegionGrowing(imageIn,dims,kernelDims,kernel,imageMask,threshold,allowConnection,device); - } - - - bool* resize(const bool* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method /*= REDUC_MEAN*/, bool** imageOut /*= NULL*/, int device /*= 0*/) - { - return cResize(imageIn, dimsIn, resizeFactors, dimsOut, method, imageOut, device); - } - - unsigned char* resize(const unsigned char* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method /*= REDUC_MEAN*/, unsigned char** imageOut /*= NULL*/, int device /*= 0*/) - { - return cResize(imageIn, dimsIn, resizeFactors, dimsOut, method, imageOut, device); - } - - unsigned short* resize(const unsigned short* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method /*= REDUC_MEAN*/, unsigned short** imageOut /*= NULL*/, int device /*= 0*/) - { - return cResize(imageIn, dimsIn, resizeFactors, dimsOut, method, imageOut, device); - } - - short* resize(const short* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method /*= REDUC_MEAN*/, short** imageOut /*= NULL*/, int device /*= 0*/) - { - return cResize(imageIn, dimsIn, resizeFactors, dimsOut, method, imageOut, device); - } - - unsigned int* resize(const unsigned int* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method /*= REDUC_MEAN*/, unsigned int** imageOut /*= NULL*/, int device /*= 0*/) - { - return cResize(imageIn, dimsIn, resizeFactors, dimsOut, method, imageOut, device); - } - - int* resize(const int* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method /*= REDUC_MEAN*/, int** imageOut /*= NULL*/, int device /*= 0*/) - { - return cResize(imageIn, dimsIn, resizeFactors, dimsOut, method, imageOut, device); - } - - float* resize(const float* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method /*= REDUC_MEAN*/, float** imageOut /*= NULL*/, int device /*= 0*/) - { - return cResize(imageIn, dimsIn, resizeFactors, dimsOut, method, imageOut, device); - } - - double* resize(const double* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method /*= REDUC_MEAN*/, double** imageOut /*= NULL*/, int device /*= 0*/) - { - return cResize(imageIn, dimsIn, resizeFactors, dimsOut, method, imageOut, device); - } - - size_t sumArray(const unsigned char* imageIn, size_t n, int device/*=0*/) -{ - return cSumArray<size_t>(imageIn,n,device); -} - - size_t sumArray(const unsigned short* imageIn, size_t n, int device/*=0*/) -{ - return cSumArray<size_t>(imageIn,n,device); -} - - size_t sumArray(const short* imageIn, size_t n, int device/*=0*/) -{ - return cSumArray<size_t>(imageIn,n,device); -} - - size_t sumArray(const unsigned int* imageIn, size_t n, int device/*=0*/) -{ - return cSumArray<size_t>(imageIn,n,device); -} - - size_t sumArray(const int* imageIn, size_t n, int device/*=0*/) -{ - return cSumArray<size_t>(imageIn,n,device); -} - - double sumArray(const float* imageIn, size_t n, int device/*=0*/) -{ - return cSumArray<double>(imageIn,n,device); -} - - double sumArray(const double* imageIn, size_t n, int device/*=0*/) -{ - return cSumArray<double>(imageIn,n,device); -} - - -unsigned char* segment(const unsigned char* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned char** imageOut/*=NULL*/, int device/*=0*/) - { - return cSegment(imageIn,dims,alpha,kernelDims,kernel,imageOut,device); - } - -unsigned short* segment(const unsigned short* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned short** imageOut/*=NULL*/, int device/*=0*/) - { - return cSegment(imageIn,dims,alpha,kernelDims,kernel,imageOut,device); - } - -short* segment(const short* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel/*=NULL*/, short** imageOut/*=NULL*/, int device/*=0*/) - { - return cSegment(imageIn,dims,alpha,kernelDims,kernel,imageOut,device); - } - -unsigned int* segment(const unsigned int* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel/*=NULL*/, unsigned int** imageOut/*=NULL*/, int device/*=0*/) - { - return cSegment(imageIn,dims,alpha,kernelDims,kernel,imageOut,device); - } - -int* segment(const int* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel/*=NULL*/, int** imageOut/*=NULL*/, int device/*=0*/) - { - return cSegment(imageIn,dims,alpha,kernelDims,kernel,imageOut,device); - } - -float* segment(const float* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel/*=NULL*/, float** imageOut/*=NULL*/, int device/*=0*/) - { - return cSegment(imageIn,dims,alpha,kernelDims,kernel,imageOut,device); - } - -double* segment(const double* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel/*=NULL*/, double** imageOut/*=NULL*/, int device/*=0*/) - { - return cSegment(imageIn,dims,alpha,kernelDims,kernel,imageOut,device); - } - - -unsigned char* stdFilter(const unsigned char* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,unsigned char** imageOut /*= NULL*/,int device /*= 0*/) -{ - return cStdFilter(imageIn,dims,neighborhood,imageOut,device); -} - -unsigned short* stdFilter(const unsigned short* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,unsigned short** imageOut /*= NULL*/,int device /*= 0*/) -{ - return cStdFilter(imageIn,dims,neighborhood,imageOut,device); -} - -short* stdFilter(const short* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,short** imageOut /*= NULL*/,int device /*= 0*/) -{ - return cStdFilter(imageIn,dims,neighborhood,imageOut,device); -} - -unsigned int* stdFilter(const unsigned int* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,unsigned int** imageOut /*= NULL*/,int device /*= 0*/) -{ - return cStdFilter(imageIn,dims,neighborhood,imageOut,device); -} - -int* stdFilter(const int* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,int** imageOut /*= NULL*/,int device /*= 0*/) -{ - return cStdFilter(imageIn,dims,neighborhood,imageOut,device); -} - -float* stdFilter(const float* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,float** imageOut /*= NULL*/,int device /*= 0*/) -{ - return cStdFilter(imageIn,dims,neighborhood,imageOut,device); -} - -double* stdFilter(const double* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,double** imageOut /*= NULL*/,int device /*= 0*/) -{ - return cStdFilter(imageIn,dims,neighborhood,imageOut,device); -} - - -unsigned char* thresholdFilter(const unsigned char* imageIn,Vec<size_t> dims,unsigned char thresh,unsigned char** imageOut/*=NULL*/,int device/*=0*/) -{ - return cThresholdFilter(imageIn,dims,thresh,imageOut,device); -} - - unsigned short* thresholdFilter(const unsigned short* imageIn, Vec<size_t> dims, unsigned short thresh, unsigned short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cThresholdFilter(imageIn,dims,thresh,imageOut,device); -} - - short* thresholdFilter(const short* imageIn, Vec<size_t> dims, short thresh, short** imageOut/*=NULL*/, int device/*=0*/) -{ - return cThresholdFilter(imageIn,dims,thresh,imageOut,device); -} - - unsigned int* thresholdFilter(const unsigned int* imageIn, Vec<size_t> dims, unsigned int thresh, unsigned int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cThresholdFilter(imageIn,dims,thresh,imageOut,device); -} - - int* thresholdFilter(const int* imageIn, Vec<size_t> dims, int thresh, int** imageOut/*=NULL*/, int device/*=0*/) -{ - return cThresholdFilter(imageIn,dims,thresh,imageOut,device); -} - - float* thresholdFilter(const float* imageIn, Vec<size_t> dims, float thresh, float** imageOut/*=NULL*/, int device/*=0*/) -{ - return cThresholdFilter(imageIn,dims,thresh,imageOut,device); -} - - double* thresholdFilter(const double* imageIn, Vec<size_t> dims, double thresh, double** imageOut/*=NULL*/, int device/*=0*/) -{ - return cThresholdFilter(imageIn,dims,thresh,imageOut,device); -} - - - unsigned char* tileImage(const unsigned char* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,unsigned char** imageOut/*=NULL*/,int device/*=0*/) - { - return cTileImage(imageIn,dims,roiStart,roiSize,imageOut,device); - } - - unsigned short* tileImage(const unsigned short* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,unsigned short** imageOut/*=NULL*/,int device/*=0*/) - { - return cTileImage(imageIn,dims,roiStart,roiSize,imageOut,device); - } - - short* tileImage(const short* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,short** imageOut/*=NULL*/,int device/*=0*/) - { - return cTileImage(imageIn,dims,roiStart,roiSize,imageOut,device); - } - - unsigned int* tileImage(const unsigned int* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,unsigned int** imageOut/*=NULL*/,int device/*=0*/) - { - return cTileImage(imageIn,dims,roiStart,roiSize,imageOut,device); - } - - int* tileImage(const int* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,int** imageOut/*=NULL*/,int device/*=0*/) - { - return cTileImage(imageIn,dims,roiStart,roiSize,imageOut,device); - } - - float* tileImage(const float* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,float** imageOut/*=NULL*/,int device/*=0*/) - { - return cTileImage(imageIn,dims,roiStart,roiSize,imageOut,device); - } - - double* tileImage(const double* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,double** imageOut/*=NULL*/,int device/*=0*/) - { - return cTileImage(imageIn,dims,roiStart,roiSize,imageOut,device); - } - - - double variance(const unsigned char* imageIn, Vec<size_t> dims, int device/*=0*/) - { - return cVariance(imageIn,dims,device,(float*)NULL); - } - - double variance(const unsigned short* imageIn, Vec<size_t> dims, int device/*=0*/) - { - return cVariance(imageIn,dims,device,(float*)NULL); - } - - double variance(const short* imageIn, Vec<size_t> dims, int device/*=0*/) - { - return cVariance(imageIn,dims,device,(float*)NULL); - } - - double variance(const unsigned int* imageIn, Vec<size_t> dims, int device/*=0*/) - { - return cVariance(imageIn,dims,device,(float*)NULL); - } - - double variance(const int* imageIn, Vec<size_t> dims, int device/*=0*/) - { - return cVariance(imageIn,dims,device,(float*)NULL); - } - - double variance(const float* imageIn, Vec<size_t> dims, int device/*=0*/) - { - return cVariance(imageIn,dims,device,(float*)NULL); - } - - double variance(const double* imageIn, Vec<size_t> dims, int device/*=0*/) - { - return cVariance(imageIn,dims,device,(double*)NULL); - } diff --git a/src/c/Cuda/CWrappers.h b/src/c/Cuda/CWrappers.h index d131908a6b44e94e2d8ab0abea12b875235c8e88..e1e3c79d79d5184739fe5f85de66f613328a96f3 100644 --- a/src/c/Cuda/CWrappers.h +++ b/src/c/Cuda/CWrappers.h @@ -15,270 +15,6 @@ IMAGE_PROCESSOR_API void clearDevice(); -IMAGE_PROCESSOR_API unsigned char* addConstant(const unsigned char* imageIn, Vec<size_t> dims, double additive, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* addConstant(const unsigned short* imageIn, Vec<size_t> dims, double additive, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* addConstant(const short* imageIn, Vec<size_t> dims, double additive, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* addConstant(const unsigned int* imageIn, Vec<size_t> dims, double additive, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* addConstant(const int* imageIn, Vec<size_t> dims, double additive, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* addConstant(const float* imageIn, Vec<size_t> dims, double additive, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* addConstant(const double* imageIn, Vec<size_t> dims, double additive, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* addImageWith(const unsigned char* imageIn1, const unsigned char* imageIn2, Vec<size_t> dims, double additive, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* addImageWith(const unsigned short* imageIn1, const unsigned short* imageIn2, Vec<size_t> dims, double additive, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* addImageWith(const short* imageIn1, const short* imageIn2, Vec<size_t> dims, double additive, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* addImageWith(const unsigned int* imageIn1, const unsigned int* imageIn2, Vec<size_t> dims, double additive, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* addImageWith(const int* imageIn1, const int* imageIn2, Vec<size_t> dims, double additive, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* addImageWith(const float* imageIn1, const float* imageIn2, Vec<size_t> dims, double additive, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* addImageWith(const double* imageIn1, const double* imageIn2, Vec<size_t> dims, double additive, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* applyPolyTransferFunction(const unsigned char* imageIn, Vec<size_t> dims, double a, double b, double c, unsigned char minValue = std::numeric_limits<unsigned char>::lowest(), unsigned char maxValue = std::numeric_limits<unsigned char>::max(), unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* applyPolyTransferFunction(const unsigned short* imageIn, Vec<size_t> dims, double a, double b, double c, unsigned short minValue = std::numeric_limits<unsigned short>::lowest(), unsigned short maxValue = std::numeric_limits<unsigned short>::max(), unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* applyPolyTransferFunction(const short* imageIn, Vec<size_t> dims, double a, double b, double c, short minValue = std::numeric_limits<short>::lowest(), short maxValue = std::numeric_limits<short>::max(), short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* applyPolyTransferFunction(const unsigned int* imageIn, Vec<size_t> dims, double a, double b, double c, unsigned int minValue = std::numeric_limits<unsigned int>::lowest(), unsigned int maxValue = std::numeric_limits<unsigned int>::max(), unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* applyPolyTransferFunction(const int* imageIn, Vec<size_t> dims, double a, double b, double c, int minValue = std::numeric_limits<int>::lowest(), int maxValue = std::numeric_limits<int>::max(), int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* applyPolyTransferFunction(const float* imageIn, Vec<size_t> dims, double a, double b, double c, float minValue = std::numeric_limits<float>::lowest(), float maxValue = std::numeric_limits<float>::max(), float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* applyPolyTransferFunction(const double* imageIn, Vec<size_t> dims, double a, double b, double c, double minValue = std::numeric_limits<double>::lowest(), double maxValue = std::numeric_limits<double>::max(), double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* contrastEnhancement(const unsigned char* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* contrastEnhancement(const unsigned short* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* contrastEnhancement(const short* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* contrastEnhancement(const unsigned int* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* contrastEnhancement(const int* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* contrastEnhancement(const float* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* contrastEnhancement(const double* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, double** imageOut = NULL, int device = 0); - IMAGE_PROCESSOR_API int deviceCount(); IMAGE_PROCESSOR_API int deviceStats(DevStats** stats); - -IMAGE_PROCESSOR_API double* entropyFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* entropyFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* entropyFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* entropyFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* entropyFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* entropyFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* entropyFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); - - -IMAGE_PROCESSOR_API size_t* histogram(const unsigned char* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned char minVal = std::numeric_limits<unsigned char>::lowest(), unsigned char maxVal = std::numeric_limits<unsigned char>::max(), int device = 0); -IMAGE_PROCESSOR_API size_t* histogram(const unsigned short* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned short minVal = std::numeric_limits<unsigned short>::lowest(), unsigned short maxVal = std::numeric_limits<unsigned short>::max(), int device = 0); -IMAGE_PROCESSOR_API size_t* histogram(const short* imageIn, Vec<size_t> dims, unsigned int arraySize, short minVal = std::numeric_limits<short>::lowest(), short maxVal = std::numeric_limits<short>::max(), int device = 0); -IMAGE_PROCESSOR_API size_t* histogram(const unsigned int* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned int minVal = std::numeric_limits<unsigned int>::lowest(), unsigned int maxVal = std::numeric_limits<unsigned int>::max(), int device = 0); -IMAGE_PROCESSOR_API size_t* histogram(const int* imageIn, Vec<size_t> dims, unsigned int arraySize, int minVal = std::numeric_limits<int>::lowest(), int maxVal = std::numeric_limits<int>::max(), int device = 0); -IMAGE_PROCESSOR_API size_t* histogram(const float* imageIn, Vec<size_t> dims, unsigned int arraySize, float minVal = std::numeric_limits<float>::lowest(), float maxVal = std::numeric_limits<float>::max(), int device = 0); -IMAGE_PROCESSOR_API size_t* histogram(const double* imageIn, Vec<size_t> dims, unsigned int arraySize, double minVal = std::numeric_limits<double>::lowest(), double maxVal = std::numeric_limits<double>::max(), int device = 0); - -IMAGE_PROCESSOR_API unsigned char* gaussianFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<float> sigmas, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* gaussianFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<float> sigmas, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* gaussianFilter(const short* imageIn, Vec<size_t> dims, Vec<float> sigmas, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* gaussianFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<float> sigmas, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* gaussianFilter(const int* imageIn, Vec<size_t> dims, Vec<float> sigmas, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* gaussianFilter(const float* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* gaussianFilter(const double* imageIn, Vec<size_t> dims, Vec<float> sigmas, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API void getMinMax(const unsigned char* imageIn, Vec<size_t> dims, unsigned char& minVal, unsigned char& maxVal, int device = 0); -IMAGE_PROCESSOR_API void getMinMax(const unsigned short* imageIn, Vec<size_t> dims, unsigned short& minVal, unsigned short& maxVal, int device = 0); -IMAGE_PROCESSOR_API void getMinMax(const short* imageIn, Vec<size_t> dims, short& minVal, short& maxVal, int device = 0); -IMAGE_PROCESSOR_API void getMinMax(const unsigned int* imageIn, Vec<size_t> dims, unsigned int& minVal, unsigned int& maxVal, int device = 0); -IMAGE_PROCESSOR_API void getMinMax(const int* imageIn, Vec<size_t> dims, int& minVal, int& maxVal, int device = 0); -IMAGE_PROCESSOR_API void getMinMax(const float* imageIn, Vec<size_t> dims, float& minVal, float& maxVal, int device = 0); -IMAGE_PROCESSOR_API void getMinMax(const double* imageIn, Vec<size_t> dims, double& minVal, double& maxVal, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* imagePow(const unsigned char* imageIn, Vec<size_t> dims, double power, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* imagePow(const unsigned short* imageIn, Vec<size_t> dims, double power, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* imagePow(const short* imageIn, Vec<size_t> dims, double power, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* imagePow(const unsigned int* imageIn, Vec<size_t> dims, double power, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* imagePow(const int* imageIn, Vec<size_t> dims, double power, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* imagePow(const float* imageIn, Vec<size_t> dims, double power, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* imagePow(const double* imageIn, Vec<size_t> dims, double power, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* linearUnmixing(const unsigned char* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* linearUnmixing(const unsigned short* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* linearUnmixing(const short* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* linearUnmixing(const unsigned int* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* linearUnmixing(const int* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* linearUnmixing(const float* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* linearUnmixing(const double* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API float* loG(const unsigned char* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* loG(const unsigned short* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* loG(const short* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* loG(const unsigned int* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* loG(const int* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* loG(const float* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* loG(const double* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API float* markovRandomFieldDenoiser(const float* imageIn, Vec<size_t> dims, int maxIterations, float** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* maxFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* maxFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* maxFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* maxFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* maxFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* maxFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* maxFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* meanFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* meanFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* meanFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* meanFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* meanFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* meanFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* meanFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* medianFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* medianFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* medianFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* medianFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* medianFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* medianFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* medianFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, double** imageOut = NULL, int device = 0); - IMAGE_PROCESSOR_API int memoryStats(size_t** stats); - -IMAGE_PROCESSOR_API unsigned char* minFilter(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* minFilter(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* minFilter(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* minFilter(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* minFilter(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* minFilter(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* minFilter(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API bool* morphologicalClosure(const bool* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, bool** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned char* morphologicalClosure(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* morphologicalClosure(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* morphologicalClosure(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* morphologicalClosure(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* morphologicalClosure(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* morphologicalClosure(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* morphologicalClosure(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API bool* morphologicalOpening(const bool* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, bool** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned char* morphologicalOpening(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* morphologicalOpening(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* morphologicalOpening(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* morphologicalOpening(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* morphologicalOpening(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* morphologicalOpening(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* morphologicalOpening(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* multiplyImage(const unsigned char* imageIn, Vec<size_t> dims, double multiplier, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* multiplyImage(const unsigned short* imageIn, Vec<size_t> dims, double multiplier, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* multiplyImage(const short* imageIn, Vec<size_t> dims, double multiplier, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* multiplyImage(const unsigned int* imageIn, Vec<size_t> dims, double multiplier, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* multiplyImage(const int* imageIn, Vec<size_t> dims, double multiplier, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* multiplyImage(const float* imageIn, Vec<size_t> dims, double multiplier, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* multiplyImage(const double* imageIn, Vec<size_t> dims, double multiplier, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* multiplyImageWith(const unsigned char* imageIn1, const unsigned char* imageIn2, Vec<size_t> dims, double factor, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* multiplyImageWith(const unsigned short* imageIn1, const unsigned short* imageIn2, Vec<size_t> dims, double factor, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* multiplyImageWith(const short* imageIn1, const short* imageIn2, Vec<size_t> dims, double factor, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* multiplyImageWith(const unsigned int* imageIn1, const unsigned int* imageIn2, Vec<size_t> dims, double factor, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* multiplyImageWith(const int* imageIn1, const int* imageIn2, Vec<size_t> dims, double factor, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* multiplyImageWith(const float* imageIn1, const float* imageIn2, Vec<size_t> dims, double factor, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* multiplyImageWith(const double* imageIn1, const double* imageIn2, Vec<size_t> dims, double factor, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* neighborhoodSum(const bool* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* neighborhoodSum(const unsigned char* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* neighborhoodSum(const unsigned short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* neighborhoodSum(const short* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* neighborhoodSum(const unsigned int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* neighborhoodSum(const int* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* neighborhoodSum(const float* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* neighborhoodSum(const double* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API double normalizedCovariance(const unsigned char* imageIn1, const unsigned char* imageIn2, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double normalizedCovariance(const unsigned short* imageIn1, const unsigned short* imageIn2, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double normalizedCovariance(const short* imageIn1, const short* imageIn2, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double normalizedCovariance(const unsigned int* imageIn1, const unsigned int* imageIn2, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double normalizedCovariance(const int* imageIn1, const int* imageIn2, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double normalizedCovariance(const float* imageIn1, const float* imageIn2, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double normalizedCovariance(const double* imageIn1, const double* imageIn2, Vec<size_t> dims, int device = 0); - -IMAGE_PROCESSOR_API double* normalizeHistogram(const unsigned char* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned char minVal = std::numeric_limits<unsigned char>::lowest(), unsigned char maxVal = std::numeric_limits<unsigned char>::max(), int device = 0); -IMAGE_PROCESSOR_API double* normalizeHistogram(const unsigned short* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned short minVal = std::numeric_limits<unsigned short>::lowest(), unsigned short maxVal = std::numeric_limits<unsigned short>::max(), int device = 0); -IMAGE_PROCESSOR_API double* normalizeHistogram(const short* imageIn, Vec<size_t> dims, unsigned int arraySize, short minVal = std::numeric_limits<short>::lowest(), short maxVal = std::numeric_limits<short>::max(), int device = 0); -IMAGE_PROCESSOR_API double* normalizeHistogram(const unsigned int* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned int minVal = std::numeric_limits<unsigned int>::lowest(), unsigned int maxVal = std::numeric_limits<unsigned int>::max(), int device = 0); -IMAGE_PROCESSOR_API double* normalizeHistogram(const int* imageIn, Vec<size_t> dims, unsigned int arraySize, int minVal = std::numeric_limits<int>::lowest(), int maxVal = std::numeric_limits<int>::max(), int device = 0); -IMAGE_PROCESSOR_API double* normalizeHistogram(const float* imageIn, Vec<size_t> dims, unsigned int arraySize, float minVal = std::numeric_limits<float>::lowest(), float maxVal = std::numeric_limits<float>::max(), int device = 0); -IMAGE_PROCESSOR_API double* normalizeHistogram(const double* imageIn, Vec<size_t> dims, unsigned int arraySize, double minVal = std::numeric_limits<double>::lowest(), double maxVal = std::numeric_limits<double>::max(), int device = 0); - -IMAGE_PROCESSOR_API unsigned char* otsuThresholdFilter(const unsigned char* imageIn, Vec<size_t> dims, double alpha = 1.0, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* otsuThresholdFilter(const unsigned short* imageIn, Vec<size_t> dims, double alpha = 1.0, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* otsuThresholdFilter(const short* imageIn, Vec<size_t> dims, double alpha = 1.0, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* otsuThresholdFilter(const unsigned int* imageIn, Vec<size_t> dims, double alpha = 1.0, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* otsuThresholdFilter(const int* imageIn, Vec<size_t> dims, double alpha = 1.0, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* otsuThresholdFilter(const float* imageIn, Vec<size_t> dims, double alpha = 1.0, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* otsuThresholdFilter(const double* imageIn, Vec<size_t> dims, double alpha = 1.0, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char otsuThresholdValue(const unsigned char* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API unsigned short otsuThresholdValue(const unsigned short* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API short otsuThresholdValue(const short* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API unsigned int otsuThresholdValue(const unsigned int* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API int otsuThresholdValue(const int* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API float otsuThresholdValue(const float* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double otsuThresholdValue(const double* imageIn, Vec<size_t> dims, int device = 0); - -IMAGE_PROCESSOR_API void regionGrowing(const unsigned char* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection=true,int device=0); -IMAGE_PROCESSOR_API void regionGrowing(const unsigned short* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection=true,int device=0); -IMAGE_PROCESSOR_API void regionGrowing(const short* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection=true,int device=0); -IMAGE_PROCESSOR_API void regionGrowing(const unsigned int* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection=true,int device=0); -IMAGE_PROCESSOR_API void regionGrowing(const int* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection=true,int device=0); -IMAGE_PROCESSOR_API void regionGrowing(const float* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection=true,int device=0); -IMAGE_PROCESSOR_API void regionGrowing(const double* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection=true,int device=0); - -IMAGE_PROCESSOR_API bool* resize(const bool* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method = REDUC_MEAN, bool** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned char* resize(const unsigned char* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method = REDUC_MEAN, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* resize(const unsigned short* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method = REDUC_MEAN, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* resize(const short* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method = REDUC_MEAN, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* resize(const unsigned int* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method = REDUC_MEAN, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* resize(const int* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method = REDUC_MEAN, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* resize(const float* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method = REDUC_MEAN, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* resize(const double* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, ReductionMethods method = REDUC_MEAN, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API size_t sumArray(const unsigned char* imageIn, size_t n, int device = 0); -IMAGE_PROCESSOR_API size_t sumArray(const unsigned short* imageIn, size_t n, int device = 0); -IMAGE_PROCESSOR_API size_t sumArray(const short* imageIn, size_t n, int device = 0); -IMAGE_PROCESSOR_API size_t sumArray(const unsigned int* imageIn, size_t n, int device = 0); -IMAGE_PROCESSOR_API size_t sumArray(const int* imageIn, size_t n, int device = 0); -IMAGE_PROCESSOR_API double sumArray(const float* imageIn, size_t n, int device = 0); -IMAGE_PROCESSOR_API double sumArray(const double* imageIn, size_t n, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* segment(const unsigned char* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel = NULL, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* segment(const unsigned short* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel = NULL, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* segment(const short* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel = NULL, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* segment(const unsigned int* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel = NULL, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* segment(const int* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel = NULL, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* segment(const float* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel = NULL, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* segment(const double* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* stdFilter(const unsigned char* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,unsigned char** imageOut = NULL,int device = 0); -IMAGE_PROCESSOR_API unsigned short* stdFilter(const unsigned short* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,unsigned short** imageOut = NULL,int device = 0); -IMAGE_PROCESSOR_API short* stdFilter(const short* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,short** imageOut = NULL,int device = 0); -IMAGE_PROCESSOR_API unsigned int* stdFilter(const unsigned int* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,unsigned int** imageOut = NULL,int device = 0); -IMAGE_PROCESSOR_API int* stdFilter(const int* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,int** imageOut = NULL,int device = 0); -IMAGE_PROCESSOR_API float* stdFilter(const float* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,float** imageOut = NULL,int device = 0); -IMAGE_PROCESSOR_API double* stdFilter(const double* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,double** imageOut = NULL,int device = 0); - -IMAGE_PROCESSOR_API unsigned char* thresholdFilter(const unsigned char* imageIn, Vec<size_t> dims, unsigned char thresh, unsigned char** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned short* thresholdFilter(const unsigned short* imageIn, Vec<size_t> dims, unsigned short thresh, unsigned short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API short* thresholdFilter(const short* imageIn, Vec<size_t> dims, short thresh, short** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API unsigned int* thresholdFilter(const unsigned int* imageIn, Vec<size_t> dims, unsigned int thresh, unsigned int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API int* thresholdFilter(const int* imageIn, Vec<size_t> dims, int thresh, int** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API float* thresholdFilter(const float* imageIn, Vec<size_t> dims, float thresh, float** imageOut = NULL, int device = 0); -IMAGE_PROCESSOR_API double* thresholdFilter(const double* imageIn, Vec<size_t> dims, double thresh, double** imageOut = NULL, int device = 0); - -IMAGE_PROCESSOR_API unsigned char* tileImage(const unsigned char* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,unsigned char** imageOut=NULL,int device=0); -IMAGE_PROCESSOR_API unsigned short* tileImage(const unsigned short* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,unsigned short** imageOut=NULL,int device=0); -IMAGE_PROCESSOR_API short* tileImage(const short* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,short** imageOut=NULL,int device=0); -IMAGE_PROCESSOR_API unsigned int* tileImage(const unsigned int* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,unsigned int** imageOut=NULL,int device=0); -IMAGE_PROCESSOR_API int* tileImage(const int* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,int** imageOut=NULL,int device=0); -IMAGE_PROCESSOR_API float* tileImage(const float* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,float** imageOut=NULL,int device=0); -IMAGE_PROCESSOR_API double* tileImage(const double* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize,double** imageOut=NULL,int device=0); - -IMAGE_PROCESSOR_API double variance(const unsigned char* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double variance(const unsigned short* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double variance(const short* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double variance(const unsigned int* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double variance(const int* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double variance(const float* imageIn, Vec<size_t> dims, int device = 0); -IMAGE_PROCESSOR_API double variance(const double* imageIn, Vec<size_t> dims, int device = 0); diff --git a/src/c/Cuda/CudaAdd.cuh b/src/c/Cuda/CudaAdd.cuh deleted file mode 100644 index 6624444e5655a0a7549824753fc4b1ab8cff5cf7..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaAdd.cuh +++ /dev/null @@ -1,126 +0,0 @@ -#pragma once -#include "Vec.h" -#include "CudaImageContainer.cuh" -#include "CHelpers.h" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" -#include "ImageContainer.h" -#include "CudaUtilities.cuh" - -template <class PixelType> -__global__ void cudaAddScaler( CudaImageContainer<PixelType> imageIn1, CudaImageContainer<PixelType> imageOut, double factor, PixelType minValue, PixelType maxValue ) -{ - Vec<size_t> coordinate = GetThreadBlockCoordinate(); - - if (coordinate<imageIn1.getDims()) - { - KernelIterator kIt(coordinate, imageIn1.getDims(), Vec<size_t>(1)); - for(; !kIt.end(); ++kIt) - { - double outValue = imageIn1(kIt.getFullPos())+factor; - imageOut(kIt.getFullPos()) = (outValue>maxValue) ? (maxValue) : ((outValue<minValue) ? (minValue) : (outValue)); - } - } -} - -template <class PixelType> -__global__ void cudaAddTwoImagesWithFactor( CudaImageContainer<PixelType> imageIn1, CudaImageContainer<PixelType> imageIn2, CudaImageContainer<PixelType> imageOut, double factor, PixelType minValue, PixelType maxValue ) -{ - Vec<size_t> coordinate = GetThreadBlockCoordinate(); - - if (coordinate<imageIn1.getDims()) - { - KernelIterator kIt(coordinate, imageIn1.getDims(), Vec<size_t>(1)); - for(; !kIt.end(); ++kIt) - { - double additive = factor* double(imageIn2(kIt.getFullPos())); - double outValue = double(imageIn1(kIt.getFullPos())) + additive; - - imageOut(kIt.getFullPos()) = (outValue>(double)maxValue) ? (maxValue) : ((outValue<(double)minValue) ? (minValue) : ((PixelType)outValue)); - } - } -} - -template <class PixelTypeIn, class PixelTypeOut> -void cAddConstant(const ImageContainer<PixelTypeIn> imageIn, double additive, ImageContainer<PixelTypeOut>& imageOut, int device=-1) -{ - const int NUM_BUFF_NEEDED = 2; - setUpOutIm(imageIn.getDims(), imageOut); - - PixelTypeOut minVal = std::numeric_limits<PixelTypeOut>::lowest(); - PixelTypeOut maxVal = std::numeric_limits<PixelTypeOut>::max(); - - int* deviceIdxList; - int numDevices; - size_t maxThreadsPerBlock; - size_t availMem = getCudaInfo(&deviceIdxList, numDevices, maxThreadsPerBlock, device); - - int blockSize = getKernelMaxThreads(cudaAddScaler<PixelTypeOut>); - maxThreadsPerBlock = MIN(maxThreadsPerBlock, size_t(blockSize)); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelTypeOut>(imageIn.getDims(), NUM_BUFF_NEEDED, (size_t)(availMem*MAX_MEM_AVAIL), sizeof(PixelTypeOut), maxThreadsPerBlock, Vec<size_t>(0)); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - {// This is were the openMP should go - CudaDeviceImages<PixelTypeOut> deviceImages(NUM_BUFF_NEEDED, maxDeviceDims, deviceIdxList[0]); - - for(std::vector<ImageChunk>::iterator curChunk = chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn, deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaAddScaler<<<curChunk->blocks, curChunk->threads>>>(*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), additive, minVal, maxVal); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - curChunk->retriveROI(imOut, deviceImages.getCurBuffer()); - } - } -} - -/* -* Adds this image to the passed in one. You can apply a factor -* which is multiplied to the passed in image prior to adding -*/ -template <class PixelType> -void cAddImageWith(const ImageContainer<PixelType> imageIn1, const ImageContainer<PixelType> imageIn2, double additive, ImageContainer<PixelType> imageOut, int device=-1) -{ - - const int NUM_BUFF_NEEDED = 3; - setUpOutIm(imageIn.getDims(), imageOut); - - PixelType minVal = std::numeric_limits<PixelType>::lowest(); - PixelType maxVal = std::numeric_limits<PixelType>::max(); - - int* deviceIdxList; - int numDevices; - size_t maxThreadsPerBlock; - size_t availMem = getCudaInfo(&deviceIdxList, numDevices, maxThreadsPerBlock, device); - - int blockSize = getKernelMaxThreads(cudaAddTwoImagesWithFactor<PixelType>); - maxThreadsPerBlock = MIN(maxThreadsPerBlock, size_t(blockSize)); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(imageIn.getDims(), NUM_BUFF_NEEDED, (size_t)(availMem*MAX_MEM_AVAIL), sizeof(PixelType), maxThreadsPerBlock, Vec<size_t>(0)); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - {// This is were the openMP should go - CudaDeviceImages<PixelTypeOut> deviceImages(NUM_BUFF_NEEDED, maxDeviceDims, deviceIdxList[0]); - - for(std::vector<ImageChunk>::iterator curChunk = chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - deviceImages.setAllDims(curChunk->getFullChunkSize()); - curChunk->sendROI(imageIn1, deviceImages.getCurBuffer()); - curChunk->sendROI(imageIn1, deviceImages.getNextBuffer()); - - cudaAddTwoImagesWithFactor<<<curChunk->blocks, curChunk->threads>>>(*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()),*(deviceImages.getThirdBuffer()), additive, minVal, maxVal); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - curChunk->retriveROI(imOut, deviceImages.getThirdBuffer()); - } - } -} diff --git a/src/c/Cuda/CudaClamp.cuh b/src/c/Cuda/CudaClamp.cuh deleted file mode 100644 index 75c32893641cac50766f0ac68d8f492060cbd6b7..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaClamp.cuh +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#include "Vec.h" -#include "CudaImageContainer.cuh" -#include "CHelpers.h" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" - -template <class PixelType> -__global__ void cudaClamp(CudaImageContainer<PixelType> imageIn,CudaImageContainer<PixelType> imageOut, PixelType minValue,PixelType maxValue) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if(coordinate<imageIn.getDims()) - { - imageOut(coordinate) = (imageIn(coordinate)>maxValue) ? (maxValue) : ((imageIn(coordinate)<minValue) ? (minValue) : (imageIn(coordinate))); - } -} - -template <class PixelType> -PixelType* cClamp(const PixelType* imageIn,Vec<size_t> dims,PixelType minVal,PixelType maxVal,PixelType** imageOut=NULL,int device=0) -{ - cudaSetDevice(device); - - PixelType* imOut = setUpOutIm(dims,imageOut); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t availMem,total; - cudaMemGetInfo(&availMem,&total); - - int blockSize = getKernelMaxThreads(cudaClamp<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims, 2, (size_t)(availMem*MAX_MEM_AVAIL), props, Vec<size_t>(0, 0, 0), blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks,maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for(std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - deviceImages.setAllDims(curChunk->getFullChunkSize()); - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - - cudaClamp<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),minVal,maxVal); - DEBUG_KERNEL_CHECK(); - - curChunk->retriveROI(imOut,dims,deviceImages.getNextBuffer()); - } - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaContrastEnhancement.cuh b/src/c/Cuda/CudaContrastEnhancement.cuh deleted file mode 100644 index cb390c1880d019d5621084c4ce4c77690694c6cb..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaContrastEnhancement.cuh +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "Vec.h" -#include <vector> -#include <limits> -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" -#include "CudaUtilities.cuh" - -#include "CudaGaussianFilter.cuh" -#include "CudaAdd.cuh" -#include "CudaClamp.cuh" -#include "CudaMedianFilter.cuh" - -template <class PixelType> -PixelType* cContrastEnhancement(const PixelType* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, - PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - - PixelType* imGauss = cGaussianFilter<PixelType>(imageIn,dims,sigmas,NULL,device); - - PixelType* imSub = cAddImageWith<PixelType>(imageIn,imGauss,dims,-1.0,NULL,device); - - delete[] imGauss; - - PixelType maxVal = std::numeric_limits<PixelType>::max(); - cClamp(imSub,dims,(PixelType)(0),maxVal,&imSub,device); - - cMedianFilter(imSub,dims,neighborhood,imageOut,device); - - delete[] imSub; - - return *imageOut; -} diff --git a/src/c/Cuda/CudaConvertType.cuh b/src/c/Cuda/CudaConvertType.cuh deleted file mode 100644 index 4561d072166e7d211a52477414c35dd0bbf29098..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaConvertType.cuh +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "Vec.h" - -template <class PixelTypeIn, class PixelTypeOut> -__global__ void cudaConvertType( const PixelTypeIn* imageIn, PixelTypeOut* imageOut, size_t imSize, PixelTypeOut minValue, - PixelTypeOut maxValue) -{ - size_t i = threadIdx.x + blockIdx.x * blockDim.x; - - if (i<imSize) - { - PixelTypeOut outValue = (PixelTypeOut)(imageIn[i]); - imageOut[i] = (outValue>maxValue) ? (maxValue) : ((outValue<minValue) ? (minValue) : (outValue)); - } -} - -// template <class PixelType> -// __global__ void cudaConvertType( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, PixelType minValue, -// PixelType maxValue) -// { -// Vec<size_t> coordinate; -// coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; -// coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; -// coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; -// -// if (coordinate<imageIn.getDims()) -// imageOut[coordinate] = imageIn[coordinate]; -// } diff --git a/src/c/Cuda/CudaDeviceInfo.cpp b/src/c/Cuda/CudaDeviceInfo.cpp index 7fdfa6fb4ddea55414412b42fe1cf0df842e2f18..72c7732760c1df8af1c6af0c9bc672f80e66cdf8 100644 --- a/src/c/Cuda/CudaDeviceInfo.cpp +++ b/src/c/Cuda/CudaDeviceInfo.cpp @@ -1,4 +1,5 @@ #include "CudaDeviceInfo.h" +#include "CudaDeviceStats.h" #include "Defines.h" #include <cuda_runtime.h> @@ -37,9 +38,9 @@ void CudaDevices::getCudaInfo(int device/*=-1*/) availMem = ULLONG_MAX; for (int i=0; i<numDevices; ++i) { - cudaDeviceProp* props; + cudaDeviceProp props; cudaGetDeviceProperties(&props, deviceIdxList[i]); - size_t mTPB = props->maxThreadsPerBlock; + size_t mTPB = props.maxThreadsPerBlock; if (maxThreadsPerBlock > mTPB) maxThreadsPerBlock = mTPB; diff --git a/src/c/Cuda/CudaDeviceStats.cpp b/src/c/Cuda/CudaDeviceStats.cpp index a2cd98649271025ef76eddc6c25b88af0fd8af64..76ca39d7bbf99a0f7ef1ff4061e4df286832a723 100644 --- a/src/c/Cuda/CudaDeviceStats.cpp +++ b/src/c/Cuda/CudaDeviceStats.cpp @@ -1,4 +1,6 @@ #include "CudaDeviceStats.h" +#include "CudaUtilities.h" + #include <cuda_runtime.h> int cDeviceStats(DevStats** stats) @@ -31,4 +33,32 @@ int cDeviceStats(DevStats** stats) } return cnt; -} \ No newline at end of file +} + +size_t memoryAvailable(int device, size_t* totalOut/*=NULL*/) +{ + HANDLE_ERROR(cudaSetDevice(device)); + size_t free, total; + HANDLE_ERROR(cudaMemGetInfo(&free, &total)); + + if (totalOut != NULL) + *totalOut = total; + + return free; +} + +bool checkFreeMemory(size_t needed, int device, bool throws/*=false*/) +{ + size_t free = memoryAvailable(device); + if (needed > free) + { + if (throws) + { + char buff[255]; + sprintf_s(buff, "Out of CUDA Memory!\nNeed: %zu\nHave: %zu\n", needed, free); + throw std::runtime_error(buff); + } + return false; + } + return true; +} diff --git a/src/c/Cuda/CudaDeviceStats.h b/src/c/Cuda/CudaDeviceStats.h index 965aef1cf986636bd8e84369ee2cbd39a0fc9bb8..13b991671389c40b12712b99f2feb59c73e1c458 100644 --- a/src/c/Cuda/CudaDeviceStats.h +++ b/src/c/Cuda/CudaDeviceStats.h @@ -20,3 +20,6 @@ struct DevStats }; int cDeviceStats(DevStats** stats); +size_t memoryAvailable(int device, size_t* totalOut = NULL); +bool checkFreeMemory(size_t needed, int device, bool throws = false); + diff --git a/src/c/Cuda/CudaEntropyFilter.cuh b/src/c/Cuda/CudaEntropyFilter.cuh deleted file mode 100644 index 3d7b65165c90cab3d8a882e8ab9697bf1a47ee63..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaEntropyFilter.cuh +++ /dev/null @@ -1,149 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "KernelIterator.cuh" -#include "Vec.h" -#include <vector> -#include "CHelpers.h" -#include "CudaUtilities.cuh" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" -#include "CudaGetMinMax.cuh" - -#include <functional> - -#ifndef CUDA_CONST_KERNEL -#define CUDA_CONST_KERNEL -__constant__ float cudaConstKernel[MAX_KERNEL_DIM*MAX_KERNEL_DIM*MAX_KERNEL_DIM]; -#endif - -class HistoShared -{ -public: - inline __host__ __device__ HistoShared() {} - inline __host__ __device__ int operator()(int n) - { - n = n*256*sizeof(short); - return n; - } -}; - -template <class PixelType> -__global__ void cudaEntropyFilter(CudaImageContainer<PixelType> imageIn, CudaImageContainer<double> imageOut, Vec<size_t> hostKernelDims, PixelType minVal, PixelType maxVal) -{ - //extern __shared__ unsigned short histo[]; - Vec<size_t> coordinate; - coordinate.x = threadIdx.x+blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y+blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z+blockIdx.z * blockDim.z; - - //unsigned short* lclHisto = (threadIdx.x+threadIdx.y*blockDim.x+threadIdx.z*blockDim.y*blockDim.x)*256 +histo; - unsigned short lclHisto[256]; - double binWidth = (double)(maxVal-minVal+1)/256.0f; - for (int i=0; i<255; ++i) - { - lclHisto[i] = 0; - } - - if(coordinate<imageOut.getDims()) - { - double val = 0; - double numVals = 0; - - Vec<size_t> kernelDims = hostKernelDims; - KernelIterator kIt(coordinate, imageIn.getDims(), kernelDims); - - for(; !kIt.end(); ++kIt) - { - Vec<size_t> kernIdx(kIt.getKernelIdx()); - if(cudaConstKernel[hostKernelDims.linearAddressAt(kernIdx)]>0) - { - PixelType imVal = imageIn(kIt.getImageCoordinate()); - int binNum = floor((double)(imVal-minVal)/binWidth); - ++(lclHisto[binNum]); - ++numVals; - } - } - - for(int i = 0; i<255; ++i) - { - double hVal = lclHisto[i]/numVals; - if (hVal>0) - val = val+hVal*log2(hVal); - } - - - imageOut(coordinate) = -val; - } -} - -#pragma optimize("",off) -template <class PixelType> -double* cEntropyFilter(const PixelType* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel = NULL, double** imageOut = NULL, int device = 0) -{ - cudaSetDevice(device); - double* imOut = setUpOutIm(dims, imageOut); - - PixelType minVal = 0; - PixelType maxVal = 0; - - cGetMinMax(imageIn, dims, minVal, maxVal, device); - - if(kernel==NULL) - { - kernelDims = kernelDims.clamp(Vec<size_t>(1, 1, 1), dims); - float* ones = new float[kernelDims.product()]; - for(int i = 0; i<kernelDims.product(); ++i) - ones[i] = 1.0f; - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, ones, sizeof(double)*kernelDims.product())); - delete[] ones; - } else - { - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, kernel, sizeof(double)*kernelDims.product())); - } - - cudaDeviceProp props; - cudaGetDeviceProperties(&props, device); - - size_t availMem, total; - cudaMemGetInfo(&availMem, &total); - - HistoShared hitoMemObj; - //int blockSize = getKernelMaxThreadsSharedMem(cudaEntropyFilter<PixelType>, hitoMemObj); - int blockSize = getKernelMaxThreads(cudaEntropyFilter<PixelType>); - - double inOutSize = (double)(sizeof(PixelType)+sizeof(double)); - double inputPrcnt = sizeof(PixelType)/inOutSize; - - std::vector<ImageChunk> inChunks = calculateBuffers<PixelType>(dims, 1, (size_t)(availMem*MAX_MEM_AVAIL*inputPrcnt), props, kernelDims, blockSize); - std::vector<ImageChunk> outChunks(inChunks); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(inChunks, maxDeviceDims); - CudaDeviceImages<PixelType> deviceInImages(1, maxDeviceDims, device); - CudaDeviceImages<double> deviceOutImages(1, maxDeviceDims, device); - - std::vector<ImageChunk>::iterator inIt = inChunks.begin(); - std::vector<ImageChunk>::iterator outIt = outChunks.begin(); - - while(inIt!=inChunks.end() && outIt!=outChunks.end()) - { - inIt->sendROI(imageIn, dims, deviceInImages.getCurBuffer()); - deviceInImages.setNextDims(inIt->getFullChunkSize()); - - //int sharedMemSize = hitoMemObj((inIt->threads.x * inIt->threads.y * inIt->threads.z)); - - //cudaEntropyFilter<<<inIt->blocks, inIt->threads, sharedMemSize>>>(*(deviceInImages.getCurBuffer()), *(deviceOutImages.getCurBuffer()), kernelDims, minVal, maxVal); - cudaEntropyFilter<<<inIt->blocks, inIt->threads>>>(*(deviceInImages.getCurBuffer()), *(deviceOutImages.getCurBuffer()), kernelDims, minVal, maxVal); - DEBUG_KERNEL_CHECK(); - - outIt->retriveROI(imOut, dims, deviceOutImages.getCurBuffer()); - - ++inIt; - ++outIt; - } - - return imOut; -} -#pragma optimize("",on) \ No newline at end of file diff --git a/src/c/Cuda/CudaGaussianFilter.cuh b/src/c/Cuda/CudaGaussianFilter.cuh deleted file mode 100644 index 39f9fed672e820c93a13a0ee799c13973b808f85..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaGaussianFilter.cuh +++ /dev/null @@ -1,95 +0,0 @@ -#pragma once - -#include "Vec.h" -#include <vector> -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" -#include "CudaMultAddFilter.cuh" -#include "CudaUtilities.cuh" - -template <class PixelType> -void runGaussIterations(Vec<int> &gaussIterations, std::vector<ImageChunk>::iterator& curChunk, CudaDeviceImages<PixelType>& deviceImages, - Vec<size_t> sizeconstKernelDims, int device) -{ - cudaSetDevice(device); - if (curChunk->getFullChunkSize().x>1) - { - for (int x=0; x<gaussIterations.x; ++x) - { - cudaMultAddFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()), - Vec<size_t>(sizeconstKernelDims.x,1,1)); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - } - } - - if (curChunk->getFullChunkSize().y>1) - { - for (int y=0; y<gaussIterations.y; ++y) - { - cudaMultAddFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()), - Vec<size_t>(1,sizeconstKernelDims.y,1), sizeconstKernelDims.x); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - } - } - - if (curChunk->getFullChunkSize().z>1) - { - for (int z=0; z<gaussIterations.z; ++z) - { - cudaMultAddFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()), - Vec<size_t>(1,1,sizeconstKernelDims.z), sizeconstKernelDims.y+sizeconstKernelDims.x); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - } - } -} - -template <class PixelType> -PixelType* cGaussianFilter(const PixelType* imageIn, Vec<size_t> dims, Vec<float> sigmas, PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - Vec<int> gaussIterations(0,0,0); - sigmas.x = (dims.x==1) ? (0) : (sigmas.x); - sigmas.y = (dims.y==1) ? (0) : (sigmas.y); - sigmas.z = (dims.z==1) ? (0) : (sigmas.z); - - float* hostKernel; - - 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); - - int blockSize = getKernelMaxThreads(cudaMultAddFilter<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,sizeconstKernelDims,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,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->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - delete[] hostKernel; - - return imOut; -} diff --git a/src/c/Cuda/CudaGetMinMax.cuh b/src/c/Cuda/CudaGetMinMax.cuh deleted file mode 100644 index 91d2d1ef2ae4a17f4671ed86fe03e12ec3fc2b66..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaGetMinMax.cuh +++ /dev/null @@ -1,124 +0,0 @@ -#pragma once -#include "CudaImageContainer.cuh" -#include "Vec.h" - -template <class PixelType> -__global__ void cudaGetMinMax(PixelType* arrayIn, PixelType* minsOut, PixelType* maxsOut, size_t n, PixelType minVal, PixelType maxVal) -{ - extern __shared__ unsigned char sharedMem[]; - PixelType* mins = (PixelType*)sharedMem; - PixelType* maxs = mins+blockDim.x; - - size_t i = threadIdx.x + blockIdx.x*blockDim.x; - size_t imStride = blockDim.x*gridDim.x; - - if (i<n) - { - mins[threadIdx.x] = arrayIn[i]; - maxs[threadIdx.x] = arrayIn[i]; - - while (i+imStride<n) - { - i += imStride; - - if (mins[threadIdx.x] > arrayIn[i]) - mins[threadIdx.x] = arrayIn[i]; - if (maxs[threadIdx.x] < arrayIn[i]) - maxs[threadIdx.x] = arrayIn[i]; - } - } - else - { - mins[threadIdx.x] = maxVal; - maxs[threadIdx.x] = minVal; - } - - __syncthreads(); - - - for (int localStride=blockDim.x/2; localStride>0; localStride /= 2) - { - if (threadIdx.x<localStride) - { - if (mins[threadIdx.x] > mins[threadIdx.x+localStride]) - mins[threadIdx.x] = mins[threadIdx.x+localStride]; - if (maxs[threadIdx.x] < maxs[threadIdx.x+localStride]) - maxs[threadIdx.x] = maxs[threadIdx.x+localStride]; - } - - __syncthreads(); - } - - if (threadIdx.x==0) - { - minsOut[blockIdx.x] = mins[0]; - maxsOut[blockIdx.x] = maxs[0]; - } - __syncthreads(); -} - -template <class PixelType> -void cGetMinMax(const PixelType* imageIn, Vec<size_t> dims, PixelType& minVal, PixelType& maxVal, int device=0) -{ - cudaSetDevice(device); - - size_t n = dims.product(); - minVal = std::numeric_limits<PixelType>::max(); - maxVal = std::numeric_limits<PixelType>::lowest(); - PixelType initMin= std::numeric_limits<PixelType>::lowest(); - PixelType initMax = std::numeric_limits<PixelType>::max(); - PixelType* deviceMins; - PixelType* deviceMaxs; - PixelType* hostMins; - PixelType* hostMaxs; - PixelType* deviceBuffer; - - cudaDeviceProp props; - cudaGetDeviceProperties(&props, device); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - size_t numValsPerChunk = MIN(n,(size_t)((availMem*MAX_MEM_AVAIL)/sizeof(PixelType))); - - int threads = getKernelMaxThreads(cudaGetMinMax<PixelType>); - int maxBlocks = (int)ceil((double)numValsPerChunk/(threads*2)); - - HANDLE_ERROR(cudaMalloc((void**)&deviceBuffer,sizeof(PixelType)*numValsPerChunk)); - HANDLE_ERROR(cudaMalloc((void**)&deviceMins,sizeof(PixelType)*maxBlocks)); - HANDLE_ERROR(cudaMalloc((void**)&deviceMaxs,sizeof(PixelType)*maxBlocks)); - - hostMins = new PixelType[maxBlocks]; - hostMaxs = new PixelType[maxBlocks]; - - for (size_t startIdx=0; startIdx<n; startIdx += numValsPerChunk) - { - size_t curNumVals = MIN(numValsPerChunk,n-startIdx); - - HANDLE_ERROR(cudaMemcpy(deviceBuffer,imageIn+startIdx,sizeof(PixelType)*curNumVals,cudaMemcpyHostToDevice)); - - int blocks = (int)((double)curNumVals/(threads*2)); - size_t sharedMemSize = sizeof(PixelType)*threads*2; - - cudaGetMinMax<<<blocks,threads,sharedMemSize>>>(deviceBuffer,deviceMins,deviceMaxs,curNumVals,initMin,initMax); - DEBUG_KERNEL_CHECK(); - - HANDLE_ERROR(cudaMemcpy(hostMins,deviceMins,sizeof(PixelType)*blocks,cudaMemcpyDeviceToHost)); - HANDLE_ERROR(cudaMemcpy(hostMaxs,deviceMaxs,sizeof(PixelType)*blocks,cudaMemcpyDeviceToHost)); - - for (int i=0; i<blocks; ++i) - { - if (minVal > hostMins[i]) - minVal = hostMins[i]; - if (maxVal < hostMaxs[i]) - maxVal = hostMaxs[i]; - } - } - - HANDLE_ERROR(cudaFree(deviceMins)); - HANDLE_ERROR(cudaFree(deviceMaxs)); - HANDLE_ERROR(cudaFree(deviceBuffer)); - - delete[] hostMins; - delete[] hostMaxs; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaGetROI.cuh b/src/c/Cuda/CudaGetROI.cuh deleted file mode 100644 index 36eb01bb8d9279411b807751ee6686e0c4ee88ef..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaGetROI.cuh +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" - -template <class PixelType> -__global__ void cudaGetROI( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, - Vec<size_t> hostStartPos, Vec<size_t> hostNewSize ) -{ - cudaSetDevice(device); - - Vec<size_t> newSize = hostNewSize; - Vec<size_t> startPos = hostStartPos; - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate>=startPos && coordinate<startPos+newSize && coordinate<imageIn.getDims()) - { - imageOut[coordinate-startPos] = imageIn[coordinate]; - } -} \ No newline at end of file diff --git a/src/c/Cuda/CudaHistogram.cuh b/src/c/Cuda/CudaHistogram.cuh deleted file mode 100644 index 7f192b041f8c7e9fe65337410818793d3f73f41c..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaHistogram.cuh +++ /dev/null @@ -1,160 +0,0 @@ -#pragma once -#include "CudaImageContainer.cuh" - -#include "Vec.h" -#include <vector> -#include "CudaUtilities.cuh" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" -#include "Defines.h" - -template <class PixelType> -__global__ void cudaHistogramCreate( PixelType* values, size_t numValues, size_t* histogram, PixelType minVal, double binSize, - unsigned int numBins) -{ - //This code is modified from that of Sanders - Cuda by Example - extern __shared__ size_t tempHisto[]; - - if (threadIdx.x<numBins) - tempHisto[threadIdx.x] = 0; - - __syncthreads(); - - size_t i = threadIdx.x + blockIdx.x*blockDim.x; - size_t stride = blockDim.x * gridDim.x; - - while (i < numValues) - { - size_t binNum = (size_t)MAX( 0.0, ( (values[i])-minVal) / binSize ); - binNum = MIN(binNum, (size_t)numBins-1); - atomicAdd(&(tempHisto[binNum]), (size_t)1); - i += stride; - } - - __syncthreads(); - if (threadIdx.x<numBins) - atomicAdd(&(histogram[threadIdx.x]), tempHisto[threadIdx.x]); - - __syncthreads(); -} - -__global__ void cudaNormalizeHistogram(size_t* histogram, double* normHistogram, unsigned int numBins, double divisor) -{ - int i = threadIdx.x + blockIdx.x*blockDim.x; - int stride = blockDim.x * gridDim.x; - while (i<numBins) - { - normHistogram[i] = (double)(histogram[i]) / divisor; - i += stride; - } -} - -template <class PixelType> -size_t* createHistogram(int device, unsigned int arraySize, Vec<size_t> dims, PixelType maxVal, PixelType minVal, const PixelType* imageIn) -{ - cudaSetDevice(device); - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - if ((size_t)props.sharedMemPerBlock<sizeof(size_t)*arraySize) - throw std::runtime_error("Too many bins to calculate on GPU with current shared memory constraints!"); - - size_t* deviceHist; - HANDLE_ERROR(cudaMalloc((void**)&deviceHist,sizeof(size_t)*arraySize)); - HANDLE_ERROR(cudaMemset(deviceHist,0,sizeof(size_t)*arraySize)); - DEBUG_KERNEL_CHECK(); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - size_t numValsPerChunk = MIN(dims.product(),(size_t)((availMem*MAX_MEM_AVAIL)/sizeof(PixelType))); - - size_t maxThreads = getKernelMaxThreads(cudaHistogramCreate<PixelType>,numValsPerChunk); - - PixelType* deviceBuffer; - - HANDLE_ERROR(cudaMalloc((void**)&deviceBuffer,sizeof(PixelType)*numValsPerChunk)); - - double binSize = ((double)maxVal-minVal)/arraySize; - - for (size_t startIdx=0; startIdx<dims.product(); startIdx+=numValsPerChunk) - { - size_t numValues = MIN(numValsPerChunk,dims.product()-startIdx); - - HANDLE_ERROR(cudaMemcpy(deviceBuffer,imageIn+startIdx,sizeof(PixelType)*numValues,cudaMemcpyHostToDevice)); - - int threads = (int)MIN(numValues,maxThreads); - int blocks = (int)MIN(numValues/threads,(size_t)props.multiProcessorCount); - - cudaHistogramCreate<<<blocks,threads,sizeof(size_t)*arraySize>>>(deviceBuffer, numValues, deviceHist, minVal, binSize, arraySize); - DEBUG_KERNEL_CHECK(); - cudaThreadSynchronize(); - } - - HANDLE_ERROR(cudaFree(deviceBuffer)); - - return deviceHist; -} - -template <class PixelType> -size_t* cCalculateHistogram(const PixelType* imageIn, Vec<size_t> dims, unsigned int arraySize, - PixelType minVal=std::numeric_limits<PixelType>::lowest(), PixelType maxVal=std::numeric_limits<PixelType>::max(), - int device=0) -{ - size_t* hostHist = new size_t[arraySize]; - - size_t* deviceHist = createHistogram(device, arraySize, dims, maxVal, minVal, imageIn); - - HANDLE_ERROR(cudaMemcpy(hostHist,deviceHist,sizeof(size_t)*arraySize,cudaMemcpyDeviceToHost)); - HANDLE_ERROR(cudaFree(deviceHist)); - - return hostHist; -} - -template <class PixelType> -double* cNormalizeHistogram(const PixelType* imageIn, Vec<size_t> dims, unsigned int arraySize, - PixelType minVal=std::numeric_limits<PixelType>::lowest(), PixelType maxVal=std::numeric_limits<PixelType>::max(), - int device=0) -{ - size_t* deviceHist = createHistogram(device, arraySize, dims, maxVal, minVal, imageIn); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - double* hostHistNorm = new double[arraySize]; - double* deviceHistNorm; - - HANDLE_ERROR(cudaMalloc((void**)&deviceHistNorm,sizeof(double)*arraySize)); - - int threads = MIN(arraySize,(unsigned int)props.maxThreadsPerBlock); - int blocks = (int)MAX((int)ceil((double)arraySize/threads),props.multiProcessorCount); - - cudaNormalizeHistogram<<<blocks,threads>>>(deviceHist,deviceHistNorm,arraySize,(double)(dims.product())); - DEBUG_KERNEL_CHECK(); - - HANDLE_ERROR(cudaMemcpy(hostHistNorm,deviceHistNorm,sizeof(double)*arraySize,cudaMemcpyDeviceToHost)); - HANDLE_ERROR(cudaFree(deviceHist)); - HANDLE_ERROR(cudaFree(deviceHistNorm)); - - return hostHistNorm; -} - -template <class PixelType> -PixelType cOtsuThresholdValue(const PixelType* imageIn, Vec<size_t> dims, int device=0) -{ - PixelType minVal, maxVal; - cGetMinMax(imageIn,dims,minVal,maxVal,device); - unsigned int arraySize = NUM_BINS; - - double* hist = cNormalizeHistogram(imageIn,dims,arraySize,minVal,maxVal,device); - - int theshIdx = calcOtsuThreshold(hist,arraySize); - - delete[] hist; - - double binSize = ((double)maxVal-minVal)/arraySize; - - PixelType thrsh = (PixelType)(minVal + binSize*theshIdx); - - return thrsh; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaImageContainer.cuh b/src/c/Cuda/CudaImageContainer.cuh index f311185c193e9b6446c6d0f98c9e21eecde6b4dc..7a1a321458230ce434cf4f0f6a7026914aa97de9 100644 --- a/src/c/Cuda/CudaImageContainer.cuh +++ b/src/c/Cuda/CudaImageContainer.cuh @@ -1,7 +1,7 @@ #pragma once #include "Vec.h" -#include "CudaUtilities.cuh" +#include "CudaUtilities.h" #include "ImageContainer.h" #include <string> @@ -181,11 +181,11 @@ protected: __host__ __device__ void defaults() { - maxImageDims = ImageDimensions(Vec<size_t>(0), 0, 0)); - imageDims = ImageDimensions(Vec<size_t>(0), 0, 0)); + maxImageDims = ImageDimensions(Vec<size_t>(0), 0, 0); + imageDims = ImageDimensions(Vec<size_t>(0), 0, 0); device = 0; - roiStarts = ImageDimensions(Vec<size_t>(0), 0, 0)); - roiSizes = ImageDimensions(Vec<size_t>(0), 0, 0)); + roiStarts = ImageDimensions(Vec<size_t>(0), 0, 0); + roiSizes = ImageDimensions(Vec<size_t>(0), 0, 0); } __device__ PixelType& accessValue(Vec<size_t> coordinate, unsigned int chan = 0, unsigned int frame = 0) @@ -239,3 +239,16 @@ protected: ImageDimensions roiSizes; PixelType* image; }; + +template <class PixelType> +ImageContainer<PixelType> setUpOutIm(Vec<size_t> dims, PixelType** imageOut) +{ + + PixelType* imOut; + if (imageOut == NULL) + imOut = new PixelType[dims.product()]; + else + imOut = *imageOut; + + return imOut; +} \ No newline at end of file diff --git a/src/c/Cuda/CudaImageCopy.cuh b/src/c/Cuda/CudaImageCopy.cuh deleted file mode 100644 index bffa4823d38e66dc9d3fbf964c528d2169fbd3c2..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaImageCopy.cuh +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once -#include "CudaImageContainer.cuh" - -#include "Vec.h" -#include "ImageChunk.h" - -template <class PixelType> -__global__ void cudaImageCopy(CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if(coordinate<imageIn.getDims() && coordinate<imageOut.getDims()) - { - imageOut[coordinate] = imageIn[coordinate]; - } -} - -template <class PixelType> -PixelType* cTileImage(const PixelType* imageIn,Vec<size_t> dims,Vec<size_t> roiStart,Vec<size_t> roiSize, PixelType** imageOut=NULL,int device=0) -{ - return *imageOut; -// cudaDeviceProp props; -// cudaGetDeviceProperties(&props,device); -// -// CudaDeviceImages<PixelType> deviceImages(2,dims,device); -// -// dim3 blocks,threads; -// calcBlockThread(roiSize,props,blocks,threads); -// -// deviceImages.getCurBuffer()->loadImage(imageIn,dims); -// deviceImages.getCurBuffer()->setROIstart(roiStart); -// deviceImages.getCurBuffer()->setROIsize(roiSize); -// -// Vec<size_t> numTiles; -// numTiles.x = size_t(ceil(double(dims.x)/double(roiSize.x))); -// numTiles.y = size_t(ceil(double(dims.y)/double(roiSize.y))); -// numTiles.z = size_t(ceil(double(dims.z)/double(roiSize.z))); -// -// Vec<size_t> curTile(0,0,0); -// Vec<size_t> curStart(0,0,0); -// Vec<size_t> curSize(roiSize); -// for(curTile.z=0; curTile.z<numTiles.z; ++curTile.z) -// { -// curStart.z = curTile.z*roiSize.z; -// curSize.z = MIN(dims.z-curStart.z,roiSize.z); -// -// for (curTile.y=0; curTile.y<numTiles.y; ++curTile.y) -// { -// curStart.y = curTile.y*roiSize.y; -// curSize.y = MIN(dims.y-curStart.y,roiSize.y); -// -// for (curTile.x=0; curTile.x<numTiles.x; ++curTile.x) -// { -// curStart.x = curTile.x*roiSize.x; -// curSize.x = MIN(dims.x-curStart.x,roiSize.x); -// -// if(!deviceImages.getNextBuffer()->setROIstart(curStart)) -// { -// char buffer[255]; -// deviceImages.getNextBuffer()->resetROI(); -// Vec<size_t> d = deviceImages.getNextBuffer()->getDims(); -// sprintf_s(buffer,"Trying to set a start of (%d,%d,%d), when the size is (%d,%d,%d)", -// curStart.x,curStart.y,curStart.z,d.x,d.y,d.z); -// throw std::runtime_error(buffer); -// } -// -// if(!deviceImages.getNextBuffer()->setROIsize(curSize)) -// { -// char buffer[255]; -// deviceImages.getNextBuffer()->resetROI(); -// Vec<size_t> d = deviceImages.getNextBuffer()->getDims()-curStart; -// sprintf_s(buffer,"Trying to set a size of (%d,%d,%d), when the size to the end is (%d,%d,%d)", -// curSize.x,curSize.y,curSize.z,d.x,d.y,d.z); -// throw std::runtime_error(buffer); -// } -// -// cudaImageCopy<<<blocks,threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer())); -// DEBUG_KERNEL_CHECK(); -// } -// } -// } -// -// deviceImages.getNextBuffer()->resetROI(); -// -// return deviceImages.getNextBuffer()->retriveImage(imageOut); -} \ No newline at end of file diff --git a/src/c/Cuda/CudaIntensityProjection.cuh b/src/c/Cuda/CudaIntensityProjection.cuh deleted file mode 100644 index 44a3258505c61daff8df28c6098f314dcfbf3a01..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaIntensityProjection.cuh +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" - -template <class PixelType> -__global__ void cudaMaximumIntensityProjection( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut ) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn.getDims() && coordinate.z==0) - { - PixelType maxVal = imageIn[coordinate]; - for (; coordinate.z<imageIn.getDepth(); ++coordinate.z) - { - if (maxVal<imageIn[coordinate]) - { - maxVal = imageIn[coordinate]; - } - } - - imageOut[coordinate] = maxVal; - } -} - -template <class PixelType> -__global__ void cudaMeanIntensityProjection( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut ) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn.getDims() && coordinate.z==0) - { - double val = imageIn[coordinate]; - for (; coordinate.z<imageIn.getDepth(); ++coordinate.z) - { - val = imageIn[coordinate]; - } - - imageOut[coordinate] = val/imageIn.getDepth(); - } -} \ No newline at end of file diff --git a/src/c/Cuda/CudaLinearUnmixing.cuh b/src/c/Cuda/CudaLinearUnmixing.cuh deleted file mode 100644 index aaedee3cd1de8e35bee46ae9f9720f61a23309c4..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaLinearUnmixing.cuh +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once - -#include "Vec.h" -#include <limits> - -#ifndef CUDA_CONST_KERNEL -#define CUDA_CONST_KERNEL -__constant__ float cudaConstKernel[MAX_KERNEL_DIM*MAX_KERNEL_DIM*MAX_KERNEL_DIM]; -#endif - -template <class PixelType> -__global__ void cudaLinearUnmixing(PixelType* imageIn, size_t imageDim, size_t numImages, PixelType minVal, PixelType maxVal) -{ - size_t pixelIdx = threadIdx.x + blockIdx.x*blockDim.x; - extern __shared__ unsigned char sharedMemLin[]; - double* sharedM = (double*)sharedMemLin; - - if (pixelIdx < imageDim) - { - double* valueVector = sharedM + threadIdx.x*numImages; - for (int chanOut=0; chanOut<numImages; ++chanOut) - { - valueVector[chanOut] = 0.0; - for (int chanIn = 0; chanIn < numImages; ++chanIn) - { - valueVector[chanOut] += cudaConstKernel[chanOut + chanIn*numImages] * (double)(imageIn[pixelIdx + chanIn*imageDim]); - } - } - - for (int chanOut = 0; chanOut < numImages; ++chanOut) - { - PixelType valOut = (PixelType)fminf(fmaxf((float)(valueVector[chanOut]), minVal), maxVal); - imageIn[pixelIdx + chanOut*imageDim] = valOut; - } - } -} - -template <class PixelType> -PixelType* cLinearUnmixing(const PixelType* imageIn, Vec<size_t> imageDims, size_t numImages, const float* unmixing, Vec<size_t> umixingDims, PixelType** imageOut, int device = 0) -{ - cudaSetDevice(device); - PixelType* deviceIm; - PixelType* imOut; - if (imageOut == NULL) - imOut = new PixelType[imageDims.product()*numImages]; - else - imOut = *imageOut; - - memset(imOut, 0, imageDims.product()*numImages*sizeof(PixelType)); - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, unmixing, sizeof(float)*umixingDims.product())); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props, device); - size_t memAvail, total; - cudaMemGetInfo(&memAvail, &total); - - size_t numValsPerChunk = MIN(imageDims.product(), (size_t)((memAvail*MAX_MEM_AVAIL) / (numImages*sizeof(PixelType)))); - - HANDLE_ERROR(cudaMalloc((void**)&deviceIm, sizeof(PixelType)*numValsPerChunk*numImages)); - PixelType min = std::numeric_limits<PixelType>::lowest(); - PixelType max = std::numeric_limits<PixelType>::max(); - - for (size_t startIdx = 0; startIdx < imageDims.product(); startIdx+=numValsPerChunk) - { - size_t curNumVals = MIN(numValsPerChunk, imageDims.product() - startIdx); - for (size_t chan = 0; chan < numImages; ++chan) - { - PixelType* deviceChanStart = deviceIm + curNumVals*chan; - const PixelType* hostChanStart = imageIn + (imageDims.product()*chan + startIdx); - HANDLE_ERROR(cudaMemcpy(deviceChanStart,hostChanStart,sizeof(PixelType)*curNumVals,cudaMemcpyHostToDevice)); - } - - int numBlocks = (int)(ceil((double)curNumVals / props.maxThreadsPerBlock)); - int maxThreads = (int)((double)props.sharedMemPerBlock / (sizeof(double)*numImages)); - int threads = getKernelMaxThreads(cudaLinearUnmixing<PixelType>,maxThreads); - size_t sharedMemSize = sizeof(double)*threads*numImages; - cudaLinearUnmixing<<<numBlocks,props.maxThreadsPerBlock,sharedMemSize>>>(deviceIm, curNumVals, numImages, min, max); - DEBUG_KERNEL_CHECK(); - - for (size_t chan = 0; chan < numImages; ++chan) - { - PixelType* deviceOutChan = deviceIm + curNumVals*chan; - PixelType* imageOutChan = imOut + imageDims.product()*chan + startIdx; - HANDLE_ERROR(cudaMemcpy(imageOutChan, deviceOutChan, sizeof(PixelType)*curNumVals, cudaMemcpyDeviceToHost)); - } - } - - HANDLE_ERROR(cudaFree(deviceIm)); - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaLoG.cuh b/src/c/Cuda/CudaLoG.cuh deleted file mode 100644 index 176dfb301f7d662d9df5a26678552e3c06837bd1..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaLoG.cuh +++ /dev/null @@ -1,145 +0,0 @@ -#pragma once - -#include "Vec.h" -#include <vector> -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" -#include "CudaMultAddFilter.cuh" -#include "CudaUtilities.cuh" -#include "CudaConvertType.cuh" -#include <float.h> - -template <class PixelType> -void runLoGIterations(Vec<int> &gaussIterations, std::vector<ImageChunk>::iterator& curChunk, CudaDeviceImages<PixelType>& deviceImages, - Vec<size_t> sizeconstKernelDims, int device) -{ - cudaSetDevice(device); - if(curChunk->getFullChunkSize().x>1) - { - for(int x = 0; x<gaussIterations.x; ++x) - { - cudaMultAddFilter<<<curChunk->blocks, curChunk->threads>>>(*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), - Vec<size_t>(sizeconstKernelDims.x, 1, 1),0, false); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - } - } - - if(curChunk->getFullChunkSize().y>1) - { - for(int y = 0; y<gaussIterations.y; ++y) - { - cudaMultAddFilter<<<curChunk->blocks, curChunk->threads>>>(*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), - Vec<size_t>(1, sizeconstKernelDims.y, 1), sizeconstKernelDims.x, false); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - } - } - - if(curChunk->getFullChunkSize().z>1) - { - for(int z = 0; z<gaussIterations.z; ++z) - { - cudaMultAddFilter<<<curChunk->blocks, curChunk->threads>>>(*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), - Vec<size_t>(1, 1, sizeconstKernelDims.z), sizeconstKernelDims.y+sizeconstKernelDims.x, false); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - } - } -} - -template <class PixelType> -float* cLoGFilter(const PixelType* imageIn, Vec<size_t> dims, Vec<float> sigmas, float** imageOut = NULL, int device = 0) -{ - cudaSetDevice(device); - float* imOut = setUpOutIm(dims, imageOut); - - Vec<int> loGIterations(0, 0, 0); - sigmas.x = (dims.x==1) ? (0) : (sigmas.x); - sigmas.y = (dims.y==1) ? (0) : (sigmas.y); - sigmas.z = (dims.z==1) ? (0) : (sigmas.z); - - float* hostKernel = NULL; - float* deviceKernel = NULL; - - size_t kernSize = 0; - Vec<size_t> sizeconstKernelDims = createLoGKernel(sigmas, &hostKernel,kernSize); - - if(sizeconstKernelDims.product()<MAX_KERNEL_DIM*MAX_KERNEL_DIM*MAX_KERNEL_DIM) - { - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, hostKernel, sizeof(float)* kernSize)); - } - else - { - HANDLE_ERROR(cudaMalloc(&deviceKernel, sizeof(float)*kernSize)); - HANDLE_ERROR(cudaMemcpy(deviceKernel, hostKernel, sizeof(float)*kernSize,cudaMemcpyHostToDevice)); - } - - cudaDeviceProp props; - cudaGetDeviceProperties(&props, device); - - size_t availMem, total; - cudaMemGetInfo(&availMem, &total); - - int blockSize = getKernelMaxThreads(cudaMultAddFilter<float>); - float memoryDem = sizeof(float)*2+sizeof(PixelType); - float memoryForFloat = sizeof(float)*2 / memoryDem; - float memoryInput = sizeof(PixelType)/memoryDem; - - if(memoryInput<1.0f/3.0f+1e-4 && memoryInput>1.0f/3.0f-1e-4) - { - // This is when the input is already a float and we can just split up the memory - std::vector<ImageChunk> chunks = calculateBuffers<float>(dims, 2, (size_t)(availMem*MAX_MEM_AVAIL), props, sizeconstKernelDims, blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<float> deviceImages(2, maxDeviceDims, device); - - for(std::vector<ImageChunk>::iterator curChunk = chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - deviceImages.setAllDims(curChunk->getFullChunkSize()); - - curChunk->sendROI(imageIn, dims, deviceImages.getCurBuffer()); - - cudaMultAddFilter<<<curChunk->blocks, curChunk->threads>>>(*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), sizeconstKernelDims, 0, false,deviceKernel); - DEBUG_KERNEL_CHECK(); - - curChunk->retriveROI(imOut, dims, deviceImages.getNextBuffer()); - } - } - else - { - // in this case we have to convert the input before running the kernel - std::vector<ImageChunk> chunks = calculateBuffers<float>(dims, 2, (size_t)(availMem*MAX_MEM_AVAIL*memoryForFloat), props, sizeconstKernelDims, blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceInputImages(1, maxDeviceDims, device); - CudaDeviceImages<float> deviceFloatImages(2, maxDeviceDims, device); - - for(std::vector<ImageChunk>::iterator curChunk = chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - deviceInputImages.setAllDims(curChunk->getFullChunkSize()); - deviceFloatImages.setAllDims(curChunk->getFullChunkSize()); - - curChunk->sendROI(imageIn, dims, deviceInputImages.getCurBuffer()); - - double numVoxels = curChunk->getFullChunkSize().product(); - int numBlocks = ceil(numVoxels/props.maxThreadsPerBlock); - cudaConvertType<<<numBlocks,props.maxThreadsPerBlock>>>(deviceInputImages.getCurBuffer()->getDeviceImagePointer(), deviceFloatImages.getCurBuffer()->getDeviceImagePointer(), numVoxels, -FLT_MAX, FLT_MAX); - DEBUG_KERNEL_CHECK(); - - cudaMultAddFilter<<<curChunk->blocks, curChunk->threads>>>(*(deviceFloatImages.getCurBuffer()), *(deviceFloatImages.getNextBuffer()),sizeconstKernelDims, 0, false,deviceKernel); - DEBUG_KERNEL_CHECK(); - - curChunk->retriveROI(imOut, dims, deviceFloatImages.getNextBuffer()); - } - } - - - delete[] hostKernel; - - return imOut; -} diff --git a/src/c/Cuda/CudaMarkovRandomFieldDenoiser.cuh b/src/c/Cuda/CudaMarkovRandomFieldDenoiser.cuh deleted file mode 100644 index d0a843c8c648f1ace922f03fe20ad1abb80e3358..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaMarkovRandomFieldDenoiser.cuh +++ /dev/null @@ -1,208 +0,0 @@ -#pragma once -#include "Vec.h" -#include "Defines.h" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" -#include "CudaMultAddFilter.cuh" -#include "CudaVariance.cuh" -#include "CudaAdd.cuh" - -template <class PixelType> -__global__ void cudaMarkovGradDescent(CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, PixelType delta) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - Vec<size_t> moves[7] = - { - Vec<size_t>(1,0,0), - Vec<size_t>(0,1,0), - Vec<size_t>(0,0,1), - Vec<size_t>(1,1,0), - Vec<size_t>(1,0,1), - Vec<size_t>(0,1,1), - Vec<size_t>(1,1,1) - }; - - if (coordinate<imageOut.getDims()) - { - double maxDif = 0.0; - double centerVal = imageIn(coordinate); - double curVal = centerVal; - - if (coordinate>Vec<size_t>(0,0,0) && coordinate<imageIn.getDims()-Vec<size_t>(1,1,1))// left, top, and front planes avail - { - for (int i=0; i<7; ++i) - { - double curDif = SQR(imageIn(coordinate-moves[i]) - imageIn(coordinate+moves[i])); - if (maxDif < curDif) - if (true) - { - maxDif = curDif; - - if (SQR(centerVal-imageIn(coordinate-moves[i])) > SQR(centerVal-imageIn(coordinate+moves[i]))) - { - curVal = centerVal - SIGN(centerVal-imageIn(coordinate-moves[i])) * delta; - } - else - { - curVal = centerVal - SIGN(centerVal-imageIn(coordinate+moves[i])) * delta; - } - } - } - } - else - { - curVal = centerVal;//TODO change this if it looks like it is working!!!! - } - - imageOut(coordinate) = curVal; - -// double sgn = 0.0; -// if (coordinate.x>0) -// sgn -= SIGN(centerVal-imageIn[coordinate-Vec<int>(1,0,0)]); -// -// if (coordinate.x<imageIn.getDims().x-1) -// sgn += SIGN(imageIn[coordinate+Vec<int>(1,0,0)]-centerVal); -// -// if (coordinate.y>0) -// sgn -= SIGN(centerVal - imageIn[coordinate-Vec<int>(0,1,0)]); -// -// if (coordinate.y<imageIn.getDims().y-1) -// sgn += SIGN(imageIn[coordinate+Vec<int>(0,1,0)] - centerVal); -// -// if (coordinate.z>0) -// sgn -= SIGN(centerVal - imageIn[coordinate-Vec<int>(0,0,1)]); -// -// if (coordinate.z<imageIn.getDims().z-1) -// sgn += SIGN(imageIn[coordinate+Vec<int>(0,0,1)] - centerVal); -// -// imageOut[coordinate] = centerVal + SIGN(sgn)*delta; - } -} - -float* cMarkovRandomFieldDenoiser(const float* imageIn, Vec<size_t> dims, int maxIterations, float** imageOut=NULL, int device=0) -{ -// MATLAB code to generate kernel -// a(:,:,1) = [0 0 0;0 0 0;0 0 0] -// a(:,:,2) = [0 0 0;1 -2 1; 0 0 0] -// a(:,:,3) = [0 0 0;0 0 0;0 0 0] -// b = convn(a,permute(a,[2 1 3]),'same') -// c = convn(b,permute(a,[3 1 2]),'same') -// normalizer = sum((c(:).^2)) - - cudaSetDevice(device); - - const size_t SINGLE_KERN_DIM = 3; - const Vec<size_t> KERN_DIMS = Vec<size_t>(SINGLE_KERN_DIM,SINGLE_KERN_DIM,SINGLE_KERN_DIM); - float hostKernel[SINGLE_KERN_DIM][SINGLE_KERN_DIM][SINGLE_KERN_DIM] = - {{{ 1.0f, -2.0f, 1.0f}, - {-2.0f, 4.0f, -2.0f}, - { 1.0f, -2.0f, 1.0f}}, - {{-2.0f, 4.0f, -2.0f}, - { 4.0f, -8.0f, 4.0f}, - {-2.0f, 4.0f, -2.0f}}, - {{ 1.0f, -2.0f, 1.0f}, - {-2.0f, 4.0f, -2.0f}, - { 1.0f, -2.0f, 1.0f}}}; - - const double NORMALIZER = 216.0; - - float* imOut = setUpOutIm(dims, imageOut); - float minVal = std::numeric_limits<float>::lowest(); - float maxVal = std::numeric_limits<float>::max(); - - float* deviceSum; - float* hostSum; - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, hostKernel, sizeof(float)*KERN_DIMS.product())); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - std::vector<ImageChunk> chunks = calculateBuffers<float>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,Vec<size_t>(3,3,3)); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - int sumThreads = props.maxThreadsPerBlock; - int sumMaxBlocks = (int)ceil((double)maxDeviceDims.product()/(sumThreads*2)); - hostSum = new float[sumMaxBlocks]; - - HANDLE_ERROR(cudaMalloc((void**)&deviceSum,sizeof(float)*sumMaxBlocks)); - - CudaDeviceImages<float> deviceImages(3,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setAllDims(curChunk->getFullChunkSize()); - - cudaMultAddFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),KERN_DIMS,0,false); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - double noiseEstimator = (cVariance(imOut,dims,device,(float*)NULL) / NORMALIZER) * dims.product(); - double curNoiseEst = 0.0; - - memcpy(imOut,imageIn,sizeof(float)*dims.product()); - - int numIter = 0; - while (curNoiseEst <= noiseEstimator && numIter<maxIterations) - { - curNoiseEst = 0.0; - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imOut,dims,deviceImages.getCurBuffer()); - deviceImages.setAllDims(curChunk->getFullChunkSize()); - - cudaMarkovGradDescent<<<curChunk->blocks,curChunk->threads,sizeof(Vec<size_t>)*7>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),1.0f); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - - curChunk->sendROI(imageIn,dims,deviceImages.getNextBuffer()); - cudaAddTwoImagesWithFactor<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()), - *(deviceImages.getThirdBuffer()),-1.0,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - deviceImages.setNthBuffCurent(3); - - cudaPow<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),2.0,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - int sumBlocks = (int)ceil((double)curChunk->getFullChunkSize().product()/(sumThreads*2)); - size_t sharedMemSize = sizeof(float)*sumThreads; - - cudaSum<<<sumBlocks,sumThreads,sharedMemSize>>>(deviceImages.getCurBuffer()->getConstImagePointer(),deviceSum, - curChunk->getFullChunkSize().product()); - DEBUG_KERNEL_CHECK(); - - HANDLE_ERROR(cudaMemcpy(hostSum,deviceSum,sizeof(float)*sumBlocks,cudaMemcpyDeviceToHost)); - - for (int i=0; i<sumBlocks; ++i) - { - curNoiseEst += hostSum[i]; - } - - memset(hostSum,0,sizeof(float)*sumMaxBlocks); - } - - ++numIter; - } - - HANDLE_ERROR(cudaFree(deviceSum)); - delete[] hostSum; - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaMask.cuh b/src/c/Cuda/CudaMask.cuh deleted file mode 100644 index 27d9c46a9b5321d1d6b07d69d9a4d48964e1b004..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaMask.cuh +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" - -template <class PixelType> -__global__ void cudaMask( const CudaImageContainer<PixelType> imageIn1, const CudaImageContainer<PixelType> imageIn2, - CudaImageContainer<PixelType> imageOut, PixelType threshold ) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn1.getDims()) - { - PixelType val=0; - - if (imageIn2[coordinate] <= threshold) - val = imageIn1[coordinate]; - - imageOut[coordinate] = val; - } -} \ No newline at end of file diff --git a/src/c/Cuda/CudaMaxFilter.cuh b/src/c/Cuda/CudaMaxFilter.cuh deleted file mode 100644 index 42dfba7c0250d78541564a7c748664cff246e4e4..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaMaxFilter.cuh +++ /dev/null @@ -1,106 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "KernelIterator.cuh" -#include "Vec.h" -#include <vector> -#include "CHelpers.h" -#include "CudaUtilities.cuh" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" - -#ifndef CUDA_CONST_KERNEL -#define CUDA_CONST_KERNEL -__constant__ float cudaConstKernel[MAX_KERNEL_DIM*MAX_KERNEL_DIM*MAX_KERNEL_DIM]; -#endif - -template <class PixelType> -__global__ void cudaMaxFilter( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, Vec<size_t> hostKernelDims, PixelType minVal, PixelType maxVal) -{ - Vec<size_t> coordinate_xyz; - coordinate_xyz.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate_xyz.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate_xyz.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate_xyz<imageIn.getSpatialDims()) - { - double localMaxVal = imageIn(coordinate_xyz); - - Vec<size_t> kernelDims = hostKernelDims; - KernelIterator kIt(coordinate_xyz, imageIn.getDims(), kernelDims); - - for(; !kIt.end(); ++kIt) - { - float kernVal = cudaConstKernel[kIt.getKernelIdx()]; - - if(kernVal==0) - continue; - - Vec<float> imageCoord(kIt.getImageCoordinate()); - double temp = imageIn(imageCoord,kIt.getChannel(),kIt.getFrame()) * kernVal; - - if(temp>localMaxVal) - { - localMaxVal = temp; - } - } - - imageOut(coordinate_xyz) = (localMaxVal>maxVal) ? (maxVal) : ((PixelType)localMaxVal); - } -} - -template <class PixelType> -PixelType* cMaxFilter(const PixelType* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel=NULL, PixelType** imageOut=NULL, int device=-1) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - PixelType minVal = std::numeric_limits<PixelType>::lowest(); - PixelType maxVal = std::numeric_limits<PixelType>::max(); - - if (kernel==NULL) - { - kernelDims = kernelDims.clamp(Vec<size_t>(1,1,1),dims); - float* ones = new float[kernelDims.product()]; - for (int i=0; i<kernelDims.product(); ++i) - ones[i] = 1.0f; - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, ones, sizeof(float)*kernelDims.product())); - delete[] ones; - } - else - { - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, kernel, sizeof(float)*kernelDims.product())); - } - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - int blockSize = getKernelMaxThreads(cudaMaxFilter<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,kernelDims,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaMaxFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),kernelDims, - minVal,maxVal); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaMeanFilter.cuh b/src/c/Cuda/CudaMeanFilter.cuh deleted file mode 100644 index c3bfffa21d4f3f5d66a980f54e72ebdbb57f21a0..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaMeanFilter.cuh +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "Vec.h" -#include <vector> -#include "CHelpers.h" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" - -template <class PixelType> -__global__ void cudaMeanFilter( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, Vec<size_t> hostKernelDims ) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn.getDims()) - { - double val = 0; - double kernelVolume = 0; - Vec<size_t> kernelDims = hostKernelDims; - KernelIterator kIt(coordinate, imageIn.getDims(), kernelDims); - - for(; !kIt.end(); ++kIt) - { - val += imageIn(kIt.getKernelIdx()); - ++kernelVolume; - } - - imageOut(coordinate) = val/kernelVolume; - } -} - -template <class PixelType> -PixelType* cMeanFilter(const PixelType* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - neighborhood = neighborhood.clamp(Vec<size_t>(1,1,1),dims); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t memAvail, total; - cudaMemGetInfo(&memAvail,&total); - - int blockSize = getKernelMaxThreads(cudaMeanFilter<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(memAvail*MAX_MEM_AVAIL),props,neighborhood,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaMeanFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),neighborhood); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaMedianFilter.cuh b/src/c/Cuda/CudaMedianFilter.cuh deleted file mode 100644 index 823ff2142f358098dce6a8ae4e0f39629729c073..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaMedianFilter.cuh +++ /dev/null @@ -1,147 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "Vec.h" -#include <vector> -#include "CHelpers.h" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" - -template <class PixelType> -__device__ PixelType* SubDivide(PixelType* pB, PixelType* pE) -{ - PixelType* pPivot = --pE; - const PixelType pivot = *pPivot; - - while (pB < pE) - { - if (*pB > pivot) - { - --pE; - PixelType temp = *pB; - *pB = *pE; - *pE = temp; - } else - ++pB; - } - - PixelType temp = *pPivot; - *pPivot = *pE; - *pE = temp; - - return pE; -} - -template <class PixelType> -__device__ void SelectElement(PixelType* pB, PixelType* pE, size_t k) -{ - while (true) - { - PixelType* pPivot = SubDivide(pB, pE); - size_t n = pPivot - pB; - - if (n == k) - break; - - if (n > k) - pE = pPivot; - else - { - pB = pPivot + 1; - k -= (n + 1); - } - } -} - -template <class PixelType> -__device__ PixelType cudaFindMedian(PixelType* vals, int numVals) -{ - SelectElement(vals,vals+numVals, numVals/2); - return vals[numVals/2]; -} - -template <class PixelType> -__global__ void cudaMedianFilter( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, - Vec<size_t> hostKernelDims ) -{ - extern __shared__ unsigned char valsShared[]; - PixelType* vals = (PixelType*)valsShared; - - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn.getDims()) - { - Vec<size_t> blockDimVec(blockDim.x,blockDim.y,blockDim.z); - Vec<size_t> kernelDims = hostKernelDims; - size_t linearThreadIdx = blockDimVec.linearAddressAt(Vec<size_t>(threadIdx.x,threadIdx.y,threadIdx.z)); - int sharedMemOffset = linearThreadIdx*kernelDims.product(); - int kernelVolume = 0; - - KernelIterator kIt(coordinate, imageIn.getDims(), kernelDims); - - for(; !kIt.end(); ++kIt) - { - vals[kernelVolume+sharedMemOffset] = (double)imageIn(kIt.getImageCoordinate()); - ++kernelVolume; - } - - imageOut(coordinate) = (PixelType)cudaFindMedian(vals+sharedMemOffset,kernelVolume); - } - __syncthreads(); -} - -template <class PixelType> -PixelType* cMedianFilter(const PixelType* imageIn, Vec<size_t> dims, Vec<size_t> neighborhood, PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - neighborhood = neighborhood.clamp(Vec<size_t>(1,1,1),dims); - - if (neighborhood == Vec<size_t>(1, 1, 1)) - { - memcpy(imOut, imageIn, sizeof(PixelType)*dims.product()); - return imOut; - } - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t memAvail, total; - cudaMemGetInfo(&memAvail,&total); - - size_t sizeOfsharedMem = neighborhood.product()*sizeof(PixelType); - int numThreads = (int)floor((double)props.sharedMemPerBlock/(double)sizeOfsharedMem); - if (numThreads<1) - throw std::runtime_error("Median neighborhood is too large to fit in shared memory on the GPU!"); - - int blockSize = getKernelMaxThreads(cudaMedianFilter<PixelType>,numThreads); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(memAvail*MAX_MEM_AVAIL),props,neighborhood,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - size_t sharedMemorysize = neighborhood.product()*sizeof(PixelType) * curChunk->threads.x * curChunk->threads.y * curChunk->threads.z; - - cudaMedianFilter<<<curChunk->blocks,curChunk->threads,sharedMemorysize>>> - (*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),neighborhood); - - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaMinFilter.cuh b/src/c/Cuda/CudaMinFilter.cuh deleted file mode 100644 index 7362ddb2be5806fd0dfce5632fca4c07f604fe18..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaMinFilter.cuh +++ /dev/null @@ -1,106 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" - -#include "Vec.h" -#include <vector> -#include "CHelpers.h" -#include "CudaUtilities.cuh" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" - -#ifndef CUDA_CONST_KERNEL -#define CUDA_CONST_KERNEL -__constant__ float cudaConstKernel[MAX_KERNEL_DIM*MAX_KERNEL_DIM*MAX_KERNEL_DIM]; -#endif - -template <class PixelType> -__global__ void cudaMinFilter( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, Vec<size_t> hostKernelDims, - PixelType minVal, PixelType maxVal) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn.getDims()) - { - double localMinVal = imageIn(coordinate); - Vec<size_t> kernelDims = hostKernelDims; - KernelIterator kIt(coordinate, imageIn.getDims(), kernelDims); - - for(; !kIt.end(); ++kIt) - { - Vec<size_t> kernIdx(kIt.getKernelIdx()); - float kernVal = cudaConstKernel[kernelDims.linearAddressAt(kernIdx)]; - - if(kernVal==0) - continue; - - double temp = imageIn(kIt.getImageCoordinate()) * cudaConstKernel[kernelDims.linearAddressAt(kernIdx)]; - if(temp<localMinVal) - { - localMinVal = temp; - } - } - - imageOut(coordinate) = (localMinVal<minVal) ? (minVal) : (localMinVal); - } -} - -template <class PixelType> -PixelType* cMinFilter(const PixelType* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel=NULL, PixelType** imageOut=NULL, - int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - PixelType minVal = std::numeric_limits<PixelType>::lowest(); - PixelType maxVal = std::numeric_limits<PixelType>::max(); - - if (kernel==NULL) - { - kernelDims = kernelDims.clamp(Vec<size_t>(1,1,1),dims); - float* ones = new float[kernelDims.product()]; - for (int i=0; i<kernelDims.product(); ++i) - ones[i] = 1.0f; - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, ones, sizeof(float)*kernelDims.product())); - delete[] ones; - } - else - { - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, kernel, sizeof(float)*kernelDims.product())); - } - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - int blockSize = getKernelMaxThreads(cudaMinFilter<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,kernelDims,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaMinFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),kernelDims, - minVal,maxVal); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaMorphologicalOperations.cuh b/src/c/Cuda/CudaMorphologicalOperations.cuh deleted file mode 100644 index 557b1dee939367177edff98e7d2f0ba3a0dfc619..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaMorphologicalOperations.cuh +++ /dev/null @@ -1,124 +0,0 @@ -#pragma once - -#include "Vec.h" -#include "CHelpers.h" -#include "CudaMaxFilter.cuh" -#include "CudaMinFilter.cuh" -#include "CudaUtilities.cuh" - -template <class PixelType> -PixelType* cMorphologicalClosure(const PixelType* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel=NULL, 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(); - - if (kernel==NULL) - { - kernelDims = kernelDims.clamp(Vec<size_t>(1,1,1),dims); - float* ones = new float[kernelDims.product()]; - for (int i=0; i<kernelDims.product(); ++i) - ones[i] = 1.0f; - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, ones, sizeof(float)*kernelDims.product())); - delete[] ones; - } - else - { - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, kernel, sizeof(float)*kernelDims.product())); - } - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t memAvail, total; - cudaMemGetInfo(&memAvail,&total); - - int blockSize = MIN(getKernelMaxThreads(cudaMaxFilter<PixelType>), getKernelMaxThreads(cudaMinFilter<PixelType>)); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(memAvail*MAX_MEM_AVAIL),props,kernelDims, blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaMaxFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),kernelDims,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - cudaMinFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),kernelDims,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} - -template <class PixelType> -PixelType* cMorphologicalOpening(const PixelType* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel=NULL, PixelType** imageOut=NULL, - int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - PixelType minVal = std::numeric_limits<PixelType>::lowest(); - PixelType maxVal = std::numeric_limits<PixelType>::max(); - - if (kernel==NULL) - { - kernelDims = kernelDims.clamp(Vec<size_t>(1,1,1),dims); - float* ones = new float[kernelDims.product()]; - for (int i=0; i<kernelDims.product(); ++i) - ones[i] = 1.0f; - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, ones, sizeof(float)*kernelDims.product())); - delete[] ones; - } - else - { - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, kernel, sizeof(float)*kernelDims.product())); - } - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t memAvail, total; - cudaMemGetInfo(&memAvail,&total); - - int blockSize = MIN(getKernelMaxThreads(cudaMaxFilter<PixelType>), getKernelMaxThreads(cudaMinFilter<PixelType>)); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(memAvail*MAX_MEM_AVAIL),props,kernelDims,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaMinFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),kernelDims,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - cudaMaxFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),kernelDims,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} diff --git a/src/c/Cuda/CudaMultAddFilter.cuh b/src/c/Cuda/CudaMultAddFilter.cuh deleted file mode 100644 index 4e6906151c96c733fbbc9b4c4e7a36f2ca41d8c3..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaMultAddFilter.cuh +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "KernelIterator.cuh" -#include "float.h" - -#ifndef CUDA_CONST_KERNEL -#define CUDA_CONST_KERNEL -__constant__ float cudaConstKernel[MAX_KERNEL_DIM*MAX_KERNEL_DIM*MAX_KERNEL_DIM]; -#endif - -template <class PixelType> -__global__ void cudaMultAddFilter( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, - Vec<size_t> hostKernelDims, size_t kernelOffset=0, bool normalize=true, float* globalKernel=NULL) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - const float* convKernel = NULL; - if(NULL!=globalKernel) - convKernel = globalKernel; - else - convKernel = cudaConstKernel; - - if (coordinate<imageIn.getDims()) - { - double val = 0; - double kernFactor = 0; - int kernHits = 0; - - PixelType localMaxVal = imageIn(coordinate); - Vec<size_t> kernelDims = hostKernelDims; - KernelIterator kIt(coordinate, imageIn.getDims(), kernelDims); - - for(; !kIt.end(); ++kIt) - { - Vec<size_t> kernIdx(kIt.getKernelIdx()); - float kernVal = cudaConstKernel[kernelDims.linearAddressAt(kernIdx)]; - - if(kernVal<=FLT_MIN && kernVal>=FLT_MIN)//float zero - continue; - - kernFactor += kernVal; - val += double((imageIn(kIt.getImageCoordinate())) * kernVal); - - ++kernHits; - } - - if (normalize) - { - imageOut(coordinate) = (PixelType)(val/kernFactor); - } - else - { - kernFactor = double(kernHits)/kernelDims.product(); - imageOut(coordinate) = (PixelType)(val/kernFactor); - } - } -} \ No newline at end of file diff --git a/src/c/Cuda/CudaMultiplyImage.cuh b/src/c/Cuda/CudaMultiplyImage.cuh deleted file mode 100644 index 7d0e81b98756d99d3fdb0bc50ba5b3dfdce49bd4..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaMultiplyImage.cuh +++ /dev/null @@ -1,123 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "Vec.h" -#include <vector> -#include "CHelpers.h" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" - -template <class PixelType> -__global__ void cudaMultiplyImageScaler( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, double factor, - PixelType minValue, PixelType maxValue ) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn.getDims()) - { - double outValue = factor*imageIn(coordinate); - imageOut(coordinate) = (outValue>maxValue) ? (maxValue) : ((outValue<minValue) ? (minValue) : (outValue)); - } -} - -template <class PixelType> -__global__ void cudaMultiplyTwoImages(CudaImageContainer<PixelType> imageIn1, CudaImageContainer<PixelType> imageIn2, - CudaImageContainer<PixelType> imageOut, double factor, PixelType minValue, - PixelType maxValue) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn1.getDims()) - { - double outValue = factor * (double)(imageIn1(coordinate)) * (double)(imageIn2(coordinate)); - imageOut(coordinate) = (outValue>(double)maxValue) ? (maxValue) : ((outValue<(double)minValue) ? (minValue) : (outValue)); - } -} - -template <class PixelType> -PixelType* cMultiplyImage(const PixelType* imageIn, Vec<size_t> dims, double multiplier, PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - PixelType minVal = std::numeric_limits<PixelType>::lowest(); - PixelType maxVal = std::numeric_limits<PixelType>::max(); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - int blockSize = getKernelMaxThreads(cudaMultiplyImageScaler<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaMultiplyImageScaler<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()), - multiplier,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} - -template <class PixelType> -PixelType* cMultiplyImageWith(const PixelType* imageIn1, const PixelType* imageIn2, Vec<size_t> dims, double factor, PixelType** imageOut=NULL, - int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - PixelType minVal = std::numeric_limits<PixelType>::lowest(); - PixelType maxVal = std::numeric_limits<PixelType>::max(); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - int blockSize = getKernelMaxThreads(cudaMultiplyTwoImages<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,3,(size_t)(availMem*MAX_MEM_AVAIL),props,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(3,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - deviceImages.setAllDims(curChunk->getFullChunkSize()); - curChunk->sendROI(imageIn1,dims,deviceImages.getCurBuffer()); - curChunk->sendROI(imageIn2,dims,deviceImages.getNextBuffer()); - - cudaMultiplyTwoImages<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()), - *(deviceImages.getThirdBuffer()),factor,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - - curChunk->retriveROI(imOut,dims,deviceImages.getThirdBuffer()); - } - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaNeighborhoodSum.cuh b/src/c/Cuda/CudaNeighborhoodSum.cuh deleted file mode 100644 index 0f6ecd2c2e44b1695163dc7c336651bd630871be..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaNeighborhoodSum.cuh +++ /dev/null @@ -1,100 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "Vec.h" -#include <vector> -#include "CHelpers.h" -#include "CudaUtilities.cuh" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" - -#ifndef CUDA_CONST_KERNEL -#define CUDA_CONST_KERNEL -__constant__ float cudaConstKernel[MAX_KERNEL_DIM*MAX_KERNEL_DIM*MAX_KERNEL_DIM]; -#endif - -template <class PixelTypeIn, class PixelTypeOut> -__global__ void cudaNeighborhoodSum( CudaImageContainer<PixelTypeIn> imageIn, CudaImageContainer<PixelTypeOut> imageOut, Vec<size_t> hostKernelDims, - PixelTypeOut minVal, PixelTypeOut maxVal) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn.getDims()) - { - double sumVal = imageIn(coordinate); - Vec<size_t> kernelDims = hostKernelDims; - KernelIterator kIt(coordinate, imageIn.getDims(), kernelDims); - - for (; !kIt.end(); ++kIt) - { - Vec<size_t> kernIdx(kIt.getKernelIdx()); - float kernVal = cudaConstKernel[kernelDims.linearAddressAt(kernIdx)]; - if (kernVal == 0) - continue; - - sumVal += imageIn(kIt.getImageCoordinate()) * kernVal; - } - - imageOut(coordinate) = (sumVal>maxVal) ? (maxVal) : ((PixelTypeOut)sumVal); - } -} - -template <class PixelTypeIn,class PixelTypeOut> -PixelTypeOut* cNeighborhoodSum(const PixelTypeIn* imageIn, Vec<size_t> dims, Vec<size_t> kernelDims, float* kernel=NULL, PixelTypeOut** imageOut=NULL, - int device=0) -{ - cudaSetDevice(device); - PixelTypeOut* imOut = setUpOutIm(dims, imageOut); - - PixelTypeOut minVal = std::numeric_limits<PixelTypeOut>::lowest(); - PixelTypeOut maxVal = std::numeric_limits<PixelTypeOut>::max(); - - if (kernel==NULL) - { - kernelDims = kernelDims.clamp(Vec<size_t>(1,1,1),dims); - float* ones = new float[kernelDims.product()]; - for (int i=0; i<kernelDims.product(); ++i) - ones[i] = 1.0f; - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, ones, sizeof(float)*kernelDims.product())); - delete[] ones; - } - else - { - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, kernel, sizeof(float)*kernelDims.product())); - } - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - int blockSize = getKernelMaxThreads(cudaMaxFilter<PixelTypeOut>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelTypeOut>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,kernelDims,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelTypeOut> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaNeighborhoodSum <<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),kernelDims, - minVal,maxVal); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaNormalizedCovariance.cuh b/src/c/Cuda/CudaNormalizedCovariance.cuh deleted file mode 100644 index 0c465aa4afdfb58f3b14f8489cb3548c14fdeeb3..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaNormalizedCovariance.cuh +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include "CudaSum.cuh" -#include "CudaAdd.cuh" -#include "CudaPow.cuh" -#include "CudaMultiplyImage.cuh" -#include "CudaVariance.cuh" - -template <class PixelType> -double cNormalizedCovariance(const PixelType* imageIn1, const PixelType* imageIn2, Vec<size_t> dims, int device=0) -{ - cudaSetDevice(device); - - float* im1Sub = new float[dims.product()]; - float* im2Sub = new float[dims.product()]; - - double sigma1 = sqrt(cVariance(imageIn1,dims,device,im1Sub)); - double sigma2 = sqrt(cVariance(imageIn2,dims,device,im2Sub)); - - float* imMul = cMultiplyImageWith<float>(im1Sub,im2Sub,dims,1.0,NULL,device); - double numerator = cSumArray<double>(imMul,dims.product(),device); - - double coVar = numerator/(dims.product()*sigma1*sigma2); - - delete[] im1Sub; - delete[] im2Sub; - delete[] imMul; - - return coVar; -} - -double cNormalizedCovariance(const double* imageIn1, const double* imageIn2, Vec<size_t> dims, int device=0) -{ - cudaSetDevice(device); - - double* im1Sub = new double[dims.product()]; - double* im2Sub = new double[dims.product()]; - - double sigma1 = sqrt(cVariance(imageIn1,dims,device,im1Sub)); - double sigma2 = sqrt(cVariance(imageIn2,dims,device,im2Sub)); - - double* imMul = cMultiplyImageWith<double>(im1Sub,im2Sub,dims,1.0,NULL,device); - double numerator = cSumArray<double>(imMul,dims.product(),device); - - double coVar = numerator/(dims.product()*sigma1*sigma2); - - delete[] im1Sub; - delete[] im2Sub; - delete[] imMul; - - return coVar; -} diff --git a/src/c/Cuda/CudaPolyTransferFunc.cuh b/src/c/Cuda/CudaPolyTransferFunc.cuh deleted file mode 100644 index bebacdb501fa25008f158efcb4b44bdfc12ed18a..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaPolyTransferFunc.cuh +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "Vec.h" -#include <vector> -#include "ImageChunk.h" -#include "CHelpers.h" -#include "CudaDeviceImages.cuh" - -template <class PixelType> -__global__ void cudaPolyTransferFunc( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, double a, double b, - double c, PixelType minPixelValue, PixelType maxPixelValue ) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn.getDims()) - { - double pixVal = (double)imageIn(coordinate) / maxPixelValue;// place value between [0,1] - double multiplier = a*pixVal*pixVal + b*pixVal + c; - if (multiplier<0) - multiplier = 0; - if (multiplier>1) - multiplier = 1; - - PixelType newPixelVal = min((double)maxPixelValue,max((double)minPixelValue, multiplier*maxPixelValue)); - - imageOut(coordinate) = newPixelVal; - } -} - -template <class PixelType> -PixelType* cApplyPolyTransferFunction(const PixelType* imageIn, Vec<size_t> dims, double a, double b, double c, - PixelType minValue=std::numeric_limits<PixelType>::lowest(), - PixelType maxValue=std::numeric_limits<PixelType>::max(), PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t memAvail, total; - cudaMemGetInfo(&memAvail,&total); - - int blockSize = getKernelMaxThreads(cudaPolyTransferFunc<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(memAvail*MAX_MEM_AVAIL),props,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaPolyTransferFunc<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()), - a,b,c,minValue,maxValue); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} diff --git a/src/c/Cuda/CudaPow.cuh b/src/c/Cuda/CudaPow.cuh deleted file mode 100644 index e00ba22e25ce147b5f37b01933f6e7acd2e9bc2a..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaPow.cuh +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -#include "Vec.h" - -#include "CudaImageContainer.cuh" - -template <class PixelType> -__global__ void cudaPow( CudaImageContainer<PixelType> imageIn1, CudaImageContainer<PixelType> imageOut, double power, PixelType minValue, - PixelType maxValue) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn1.getDims()) - { - double outValue = pow((double)imageIn1(coordinate), power); - imageOut(coordinate) = (outValue>maxValue) ? (maxValue) : ((outValue<minValue) ? (minValue) : (outValue)); - } -} - -template <class PixelType> -PixelType* cImagePow(const PixelType* imageIn, Vec<size_t> dims, double power, PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - PixelType minVal = std::numeric_limits<PixelType>::lowest(); - PixelType maxVal = std::numeric_limits<PixelType>::max(); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - int blockSize = getKernelMaxThreads(cudaPow<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaPow<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()), - power,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaRegionGrowing.cuh b/src/c/Cuda/CudaRegionGrowing.cuh deleted file mode 100644 index 5598104330d773d044f9ff426d5d82829b6385d6..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaRegionGrowing.cuh +++ /dev/null @@ -1,238 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "Vec.h" -#include <vector> -#include "CHelpers.h" -#include "CudaUtilities.cuh" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" - -#ifndef CUDA_CONST_KERNEL -#define CUDA_CONST_KERNEL -__constant__ float cudaConstKernel[MAX_KERNEL_DIM*MAX_KERNEL_DIM*MAX_KERNEL_DIM]; -#endif - -__device__ bool lineConnect(const CudaImageContainer<bool>& maskIn,Vec<size_t> prevCoord,Vec<size_t> nextCoord) -{ - if(prevCoord>=Vec<size_t>(0,0,0) && nextCoord>=Vec<size_t>(0,0,0)) - { - if(prevCoord<maskIn.getDims() && nextCoord<maskIn.getDims()) - { - - if(maskIn(Vec<size_t>(prevCoord)) && maskIn(Vec<size_t>(nextCoord))) - return true; - } - } - - return false; -} - -__device__ bool willConnect(const CudaImageContainer<bool>& maskIn, Vec<size_t> coordinateIn) -{ - if(maskIn(coordinateIn)) - return true; - - Vec<size_t> coordinate(coordinateIn); - Vec<size_t> prevCoord; - Vec<size_t> nextCoord; - Vec<size_t> prevDelta; - Vec<size_t> nextDelta; - const char n = -2; - const char z = 0; - const char p = 2; - - prevDelta = Vec<char>(n,n,n); nextDelta = Vec<char>(p,p,n); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(n,z,n); nextDelta = Vec<char>(p,z,n); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(n,p,n); nextDelta = Vec<char>(p,n,n); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(z,p,n); nextDelta = Vec<char>(z,n,n); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - - prevDelta = Vec<char>(n,n,z); nextDelta = Vec<char>(p,p,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(n,z,z); nextDelta = Vec<char>(p,z,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(n,p,z); nextDelta = Vec<char>(p,n,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(z,p,z); nextDelta = Vec<char>(p,p,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - - prevDelta = Vec<char>(n,n,p); nextDelta = Vec<char>(p,p,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(n,z,p); nextDelta = Vec<char>(p,z,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(n,p,p); nextDelta = Vec<char>(p,n,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(z,p,p); nextDelta = Vec<char>(z,n,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - - - prevDelta = Vec<char>(n,n,n); nextDelta = Vec<char>(n,p,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(n,z,n); nextDelta = Vec<char>(n,z,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(n,p,n); nextDelta = Vec<char>(n,n,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(n,p,z); nextDelta = Vec<char>(n,n,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - - prevDelta = Vec<char>(z,n,n); nextDelta = Vec<char>(z,p,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(z,z,n); nextDelta = Vec<char>(z,z,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(z,p,n); nextDelta = Vec<char>(z,n,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(z,p,z); nextDelta = Vec<char>(z,n,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - - prevDelta = Vec<char>(p,n,n); nextDelta = Vec<char>(p,p,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(p,z,n); nextDelta = Vec<char>(p,z,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(p,p,n); nextDelta = Vec<char>(p,n,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(p,p,z); nextDelta = Vec<char>(p,n,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - - - prevDelta = Vec<char>(n,n,n); nextDelta = Vec<char>(p,n,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(z,n,n); nextDelta = Vec<char>(z,n,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(p,n,n); nextDelta = Vec<char>(n,n,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(p,n,z); nextDelta = Vec<char>(n,n,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - - prevDelta = Vec<char>(n,z,n); nextDelta = Vec<char>(p,z,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(z,z,n); nextDelta = Vec<char>(z,z,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(p,z,n); nextDelta = Vec<char>(n,z,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(p,z,z); nextDelta = Vec<char>(n,z,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - - prevDelta = Vec<char>(n,p,n); nextDelta = Vec<char>(p,p,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(z,p,n); nextDelta = Vec<char>(z,p,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(p,p,n); nextDelta = Vec<char>(n,p,p); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - prevDelta = Vec<char>(p,p,z); nextDelta = Vec<char>(n,p,z); - if(lineConnect(maskIn,coordinate+prevDelta,coordinate+nextDelta)) return true; - - return false; -} - -template<class PixelType> -__device__ void evalNeighborhood(const CudaImageContainer<PixelType> &imageIn,const Vec<size_t> &coordinate,double threshold,Vec<size_t> hostKernelDims,CudaImageContainer<bool>& maskIn,CudaImageContainer<bool> &maskOut) -{ - PixelType curPixelVal = imageIn(coordinate) + threshold; - Vec<size_t> kernelDims = hostKernelDims; - Vec<size_t> halfKernal = kernelDims/2; - - Vec<size_t> curCoordIm = coordinate - halfKernal; - curCoordIm.z = (coordinate.z<halfKernal.z) ? 0 : coordinate.z-halfKernal.z; - for(; curCoordIm.z<=coordinate.z+halfKernal.z && curCoordIm.z<imageIn.getDims().z; ++curCoordIm.z) - { - curCoordIm.y = (coordinate.y<halfKernal.y) ? 0 : coordinate.y-halfKernal.y; - for(; curCoordIm.y<=coordinate.y+halfKernal.y && curCoordIm.y<imageIn.getDims().y; ++curCoordIm.y) - { - curCoordIm.x = (coordinate.x<halfKernal.x) ? 0 : coordinate.x-halfKernal.x; - for(; curCoordIm.x<=coordinate.x+halfKernal.x && curCoordIm.x<imageIn.getDims().x; ++curCoordIm.x) - { - if(curPixelVal > imageIn(curCoordIm) && maskIn(curCoordIm)==true) - { - maskOut(coordinate) = true; - } - } - } - } -} - -template<class PixelType> -__global__ void cudaRegionGrowing(CudaImageContainer<PixelType> imageIn,CudaImageContainer<bool> maskIn,CudaImageContainer<bool> maskOut, - Vec<size_t> hostKernelDims,double threshold,bool allowConnection=true) -{ - Vec<size_t> coordinate; - Vec<size_t> deviceKernelDims(hostKernelDims); - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if(coordinate<imageIn.getDims()) - { - if(maskIn(coordinate)==true) - { - maskOut(coordinate) = true; - } - else - { - if(!allowConnection) - { - if(willConnect(maskIn,coordinate)) - maskOut(coordinate) = false; - else - evalNeighborhood(imageIn,coordinate,threshold,deviceKernelDims,maskIn,maskOut); - } - else - { - evalNeighborhood(imageIn,coordinate,threshold,deviceKernelDims,maskIn,maskOut); - } - } - } -} - -template <class PixelType> -void cRegionGrowing(const PixelType* imageIn,Vec<size_t> dims,Vec<size_t> kernelDims,float* kernel,bool* imageMask,double threshold,bool allowConnection=true,int device=0) -{ - //cudaSetDevice(device); - //PixelType minVal = std::numeric_limits<PixelType>::lowest(); - //PixelType maxVal = std::numeric_limits<PixelType>::max(); - - //if(kernel==NULL) - //{ - // kernelDims = kernelDims.clamp(Vec<size_t>(1,1,1),dims); - // float* ones = new float[kernelDims.product()]; - // for(int i=0; i<kernelDims.product(); ++i) - // ones[i] = 1.0f; - - // HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel,ones,sizeof(float)*kernelDims.product())); - // delete[] ones; - //} else - //{ - // HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel,kernel,sizeof(float)*kernelDims.product())); - //} - - //cudaDeviceProp props; - //cudaGetDeviceProperties(&props,device); - - //size_t availMem,total; - //cudaMemGetInfo(&availMem,&total); - - //std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,kernelDims); - - //Vec<size_t> maxDeviceDims; - //setMaxDeviceDims(chunks,maxDeviceDims); - - //CudaDeviceImages<PixelType> deviceImages(1,maxDeviceDims,device); - //CudaDeviceImages<bool> deviceMask(2,maxDeviceDims,device); - - //for(std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - //{ - // curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - // deviceImages.setNextDims(curChunk->getFullChunkSize()); - // curChunk->sendROI(imageMask,dims,deviceMask.getCurBuffer()); - // deviceMask.setNextDims(curChunk->getFullChunkSize()); - - // cudaRegionGrowing<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceMask.getCurBuffer()), - // *(deviceMask.getNextBuffer()),kernelDims,threshold,allowConnection); - // DEBUG_KERNEL_CHECK(); - - // curChunk->retriveROI(imageMask,dims,deviceMask.getNextBuffer()); - //} -} diff --git a/src/c/Cuda/CudaResize.cuh b/src/c/Cuda/CudaResize.cuh deleted file mode 100644 index ba2340fade4b1e44062fcf1f86147bbd9943d008..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaResize.cuh +++ /dev/null @@ -1,205 +0,0 @@ -#ifndef CUDA_RESIZE_CUH -#define CUDA_RESIZE_CUH - -#include "CudaImageContainer.cuh" -#include "CudaMedianFilter.cuh" - -#include "Vec.h" -#include <vector> -#include "ImageChunk.h" -#include "CudaImageContainerClean.cuh" -#include "Defines.h" -#include "CudaUtilities.cuh" - -#ifndef CUDA_CONST_KERNEL -#define CUDA_CONST_KERNEL -__constant__ float cudaConstKernel[MAX_KERNEL_DIM*MAX_KERNEL_DIM*MAX_KERNEL_DIM]; -#endif - - -template <class PixelType> -__global__ void cudaMeanResize(CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, Vec<float> hostResizeFactors, Vec<size_t> hostKernelDims, PixelType minVal, PixelType maxVal) -{ - Vec<float> resizeFactors = hostResizeFactors; - Vec<int> kernelDims(hostKernelDims); - Vec<size_t> coordinateOut; - coordinateOut.x = threadIdx.x+blockIdx.x * blockDim.x; - coordinateOut.y = threadIdx.y+blockIdx.y * blockDim.y; - coordinateOut.z = threadIdx.z+blockIdx.z * blockDim.z; - - if(coordinateOut<imageOut.getDims()) - { - double val = 0; - double kernelFactor = 0; - Vec<float> inputCenter = Vec<float>(coordinateOut+0.5) / resizeFactors; - Vec<float> kernelCenter = Vec<float>(kernelDims-1)/2.0f; - Vec<int> kernelStart(0,0,0); - Vec<int> kernelEnd(0,0,0); - - Vec<float> neighborhoodStart = inputCenter-Vec<float>(kernelDims)/2.0f; - // if the input start position is negative, we need to start further in on the kernel - kernelStart.x = (neighborhoodStart.x>=0.0f) ? (0) : (ceil(-neighborhoodStart.x)); - kernelStart.y = (neighborhoodStart.y>=0.0f) ? (0) : (ceil(-neighborhoodStart.y)); - kernelStart.z = (neighborhoodStart.z>=0.0f) ? (0) : (ceil(-neighborhoodStart.z)); - neighborhoodStart = Vec<float>::max(Vec<float>(0.0f, 0.0f, 0.0f), neighborhoodStart); - - // This is the last place to visit in the input (inclusive) - Vec<float> neighborhoodEnd = inputCenter+(Vec<float>(kernelDims)/2.0f); - // if the input end position is outside the image, we need to end earlier in on the kernel - kernelEnd.x = (neighborhoodEnd.x<=imageIn.getDims().x) ? (kernelDims.x) : - (kernelDims.x-(neighborhoodEnd.x-imageIn.getDims().x));// will floor to int value - kernelEnd.y = (neighborhoodEnd.y<=imageIn.getDims().y) ? (kernelDims.y) : - (kernelDims.y-(neighborhoodEnd.y-imageIn.getDims().y));// will floor to int value - kernelEnd.z = (neighborhoodEnd.z<=imageIn.getDims().z) ? (kernelDims.z) : - (kernelDims.z-(neighborhoodEnd.z-imageIn.getDims().z));// will floor to int value - - neighborhoodEnd = Vec<float>::min(imageIn.getDims(), neighborhoodEnd); - - Vec<int> curKernelPos(0, 0, 0); - Vec<int> curInPos(neighborhoodStart); - for(curKernelPos.z = kernelStart.z; curKernelPos.z<kernelEnd.z; ++curKernelPos.z) - { - curInPos.z = neighborhoodStart.z + curKernelPos.z; - for(curKernelPos.y = kernelStart.y; curKernelPos.y<kernelEnd.y; ++curKernelPos.y) - { - curInPos.y = neighborhoodStart.y+curKernelPos.y; - for(curKernelPos.x = kernelStart.x; curKernelPos.x<kernelEnd.x; ++curKernelPos.x) - { - curInPos.x = neighborhoodStart.x+curKernelPos.x; - double imVal = imageIn(curInPos); - val += imVal; - ++kernelFactor; - } - } - } - - double meanVal = 0; - if(kernelFactor>0) - { - meanVal = val/kernelFactor; - meanVal = (meanVal>minVal) ? (meanVal) : ((double)minVal); - meanVal = (meanVal<maxVal) ? (meanVal) : ((double)maxVal); - } - - imageOut(coordinateOut) = (PixelType)meanVal; - } -} - -template <class PixelType> -PixelType* cResize(const PixelType* imageIn, Vec<size_t> dimsIn, Vec<double> resizeFactors, Vec<size_t>& dimsOut, - ReductionMethods method = REDUC_MEAN, PixelType** imageOut = NULL, int device = 0) -{ - cudaSetDevice(device); - if(resizeFactors.maxValue()<=0) - resizeFactors = Vec<double>(dimsOut)/Vec<double>(dimsIn); - - dimsOut = Vec<size_t>(Vec<double>(dimsIn)*resizeFactors); - - PixelType* resizedImage = NULL; - if(imageOut==NULL) - { - resizedImage = new PixelType[dimsOut.product()]; - *imageOut = resizedImage; - } - else - resizedImage = *imageOut; - - if(resizeFactors.product()==1) - { - memcpy(*imageOut, imageIn, sizeof(PixelType)*dimsIn.product()); - return *imageOut; - } - - double memSizeRatio = (double)dimsOut.product()/(double)dimsIn.product(); - bool reduce = memSizeRatio<1; - - if(!reduce) - std::runtime_error("Enlarging is currently not implemented."); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props, device); - - size_t memAvail, total; - cudaMemGetInfo(&memAvail, &total); - - float* hostKernel; - Vec<size_t> neighborhood; - Vec<double> neighborhood_ = Vec<double>::max(resizeFactors,Vec<double>(1.0,1.0,1.0)/resizeFactors); - - int blockSize = props.maxThreadsPerBlock; - if(method==REDUC_GAUS) - { - Vec<float> sigmas = Vec<float>(neighborhood_*3); - - neighborhood = createGaussianKernelFull(sigmas, &hostKernel); - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, hostKernel, sizeof(float)*neighborhood.product())); - - //blockSize = getKernelMaxThreads(<PixelType>); - } - else if(method==REDUC_MEAN) - { - neighborhood = Vec<size_t>(ceil(neighborhood_.x), ceil(neighborhood_.y), ceil(neighborhood_.z)); - hostKernel = new float[neighborhood.product()]; - for(int i = 0; i<neighborhood.product(); ++i) - hostKernel[i] = 1.0f; - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, hostKernel, sizeof(float)*neighborhood.product())); - - blockSize = getKernelMaxThreads(cudaMeanResize<PixelType>); - - delete[] hostKernel; - } - - Vec<size_t> bigDims = (reduce) ? (dimsIn) : (dimsOut); - Vec<size_t> smallDims = (reduce) ? (dimsOut) : (dimsIn); - memSizeRatio = (reduce) ? (memSizeRatio) : (1/memSizeRatio); // this will be in terms of the smaller image - - std::vector<ImageChunk> bigChunks = calculateBuffers<PixelType>(bigDims, 1, memAvail*MAX_MEM_AVAIL*(1-memSizeRatio), props, neighborhood,blockSize); - std::vector<ImageChunk> smallChunks(bigChunks); - - for(auto& it:smallChunks) - { - Vec<double> start = it.chunkROIstart*resizeFactors; - it.imageStart = Vec<size_t>(ceil(start.x), ceil(start.y), ceil(start.z)); - it.chunkROIstart = Vec<size_t>(0,0,0); - it.imageROIstart = it.imageStart; - - Vec<double> end = (it.imageEnd+1)*resizeFactors; - it.imageEnd = Vec<size_t>(floor(end.x), floor(end.y), floor(end.z))-1; - it.chunkROIend = it.imageEnd-it.imageStart; - it.imageROIend = it.imageEnd; - } - - Vec<size_t> maxBigDeviceDims; - setMaxDeviceDims(bigChunks, maxBigDeviceDims); - CudaImageContainerClean<PixelType> deviceBigImage(maxBigDeviceDims, device); - - Vec<size_t> maxSmallDeviceDims; - setMaxDeviceDims(smallChunks, maxSmallDeviceDims); - CudaImageContainerClean<PixelType> deviceSmallImage(maxSmallDeviceDims, device); - - std::vector<ImageChunk>::iterator bigIt = bigChunks.begin(); - std::vector<ImageChunk>::iterator smallIt = smallChunks.begin(); - - while(bigIt!=bigChunks.end() && smallIt!=smallChunks.end()) - { - bigIt->sendROI(imageIn, dimsIn, &deviceBigImage); - deviceSmallImage.setDims(smallIt->getFullChunkSize()); - - switch(method) - { - case REDUC_MEAN: - cudaMeanResize<<<smallIt->blocks, smallIt->threads>>>(deviceBigImage, deviceSmallImage, Vec<float>(resizeFactors), neighborhood, std::numeric_limits<PixelType>::min(), std::numeric_limits<PixelType>::max()); - break; - } - DEBUG_KERNEL_CHECK(); - - smallIt->retriveROI(resizedImage, smallDims, &deviceSmallImage); - - ++bigIt; - ++smallIt; - } - - return resizedImage; -} -#endif diff --git a/src/c/Cuda/CudaRidgidRegistaration.cuh b/src/c/Cuda/CudaRidgidRegistaration.cuh deleted file mode 100644 index f0dc738bb105ee66d05429f8d008b46abd75b9e9..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaRidgidRegistaration.cuh +++ /dev/null @@ -1,140 +0,0 @@ -#pragma once -#include "Vec.h" -#include "CudaUtilities.cuh" -#include "cuda_runtime.h" - -// function normCoCube = iterateOverZ(maxIterZ,maxIterX,maxIterY,im1,im2,xStart1,xStart2,yStart1,yStart2,zStart1,zStart2,minOverlap,visualize) -// normCoCube = zeros(maxIterY*2,maxIterX*2,maxIterZ*2); -// -// for delta = 1:maxIterZ*2 -// curDelta = delta-maxIterZ; -// [start1,start2,end1,end2] = calculateROIs(curDelta,zStart1,zStart2,size(im1,3),size(im2,3)); -// if(end1-start1<minOverlap/5 || end2-start2<minOverlap/5),continue,end -// -// imZ1 = im1(:,: ,start1 : end1); -// imZ2 = im2(:,: ,start2 : end2); -// normCoCube(:,: ,delta) = iterateOverX(maxIterX,maxIterY,imZ1,imZ2,xStart1,xStart2,... -// yStart1,yStart2,curDelta,minOverlap,visualize); -// end -// imZ1 =[]; -// imZ2 =[]; -// end -// -// function normCoSquare = iterateOverX(maxIterX,maxIterY,im1,im2,xStart1,xStart2,yStart1,yStart2,curDeltaZ,minOverlap,visualize) -// global Rect1 Rect2 -// normCoSquare = zeros(maxIterY*2,maxIterX*2); -// -// for delta = 1:maxIterX*2 -// curDelta = delta-maxIterX; -// [start1,start2,end1,end2] = calculateROIs(curDelta,xStart1,xStart2,size(im1,2),size(im2,2)); -// if(end1-start1<minOverlap || end2-start2<minOverlap),continue,end -// -// if(visualize==1) -// pos1 = get(Rect1,'Position'); -// pos2 = get(Rect2,'Position'); -// set(Rect1,'Position',[max(start1,1),max(pos1(2),1),max(end1-start1,1),max(pos1(4),1)]); -// set(Rect2,'Position',[max(start2,1),max(pos2(2),1),max(end2-start2,1),max(pos2(4),1)]); -// end -// -// imX1 = im1(:,start1 : end1,: ); -// imX2 = im2(:,start2 : end2,: ); -// normCoSquare(:,delta) = iterateOverY(maxIterY,imX1,imX2,curDelta,yStart1,yStart2,curDeltaZ,minOverlap,visualize); -// end -// imX1 =[]; -// imX2 =[]; -// end - -// function normCoLine = iterateOverY(maxIterY,im1,im2,curDeltaX,yStart1,yStart2,curDeltaZ,minOverlap,visualize) -// global Rect1 Rect2 -// normCoLine = zeros(maxIterY*2,1); -// -// for delta = 1:maxIterY*2 -// curDelta = delta-maxIterY; -// [start1,start2,end1,end2] = calculateROIs(curDelta,yStart1,yStart2,size(im1,1),size(im2,1)); -// if(end1-start1<minOverlap || end2-start2<minOverlap),continue,end -// -// imY1 = im1(start1:end1,: ,: ); -// imY2 = im2(start2:end2,: ,: ); -// -// normCoLine(delta) = NormalizedCovariance(imY1,imY2); -// -// if(visualize==1) -// pos1 = get(Rect1,'Position'); -// pos2 = get(Rect2,'Position'); -// set(Rect1,'Position',[max(pos1(1),1),max(start1,1),max(pos1(3),1),max(end1-start1,1)]); -// set(Rect2,'Position',[max(pos2(1),1),max(start2,1),max(pos2(3),1),max(end2-start2,1)]); -// updateXYviewer(imY1,imY2,normCoLine(delta),curDeltaX,curDelta,curDeltaZ); -// end -// -// if(normCoLine(delta)>1 || normCoLine(delta)<-1) -// warning('Recived a NCV out of bounds:%f, overlap:(%d,%d,%d)',normCoLine(delta),size(imY1,2),size(imY1,1),size(imY1,3)); -// normCoLine(delta) = 0; -// end -// end -// imY1 =[]; -// imY2 =[]; -// end -// -// function[start1,start2,end1,end2] = calculateROIs(delta,oldStart1,oldStart2,size1,size2) -// if(oldStart1==1 && oldStart2~=1) -// start1 = 1; -// else -// start1 = max(1,oldStart1+delta); -// end -// -// if(oldStart2==1 && oldStart1~=1) -// start2 = 1; -// else -// start2 = max(1,oldStart2-delta); -// end -// -// minSize = min(size1-start1,size2-start2); -// end1 = start1 + minSize; -// end2 = start2 + minSize; -// -// if(end1-start1~=end2-start2),error('Sizes dont`t match %d : %d!',end1-start1,end2-start2),end -// end - -Vec<int> calcNewROI(Vec<int> delta,const Vec<int> starts1, const Vec<int> starts2,const Vec<size_t> imDim, - Vec<int>& newStarts1, Vec<int>& newStarts2) -{ - newStarts1 = Vec<int>::max(Vec<int>(0,0,0),starts1+delta); - newStarts2 = Vec<int>::max(Vec<int>(0,0,0),starts2+delta); - return Vec<int>::min(imDim-starts1,imDim-starts2); -} - -// Return pointer is to a new array that need to be cleaned up elsewhere! -template <class PixelType> -float* cRidgidRegistaration(PixelType* imageIn1, PixelType* imageIn1, Vec<size_t> imageDims, float** normCovarResults, - Vec<size_t> maxIterations, Vec<int> roiStart1Init, Vec<int> roiStart2Init, Vec<int> minOverlap, int device=0) -{ - cudaSetDevice(device); - - float normCovarResults[] = new float[maxIterations.product()]; - for(int i=0; i<maxIterations.product(); ++i) - normCovarResults[i] = 0; - - // Find the greatest overlap and consequently the largest image buffers needed. - Vec<int> delta(0,0,0); - Vec<size_t> maxSizes(0,0,0); - size_t maxVol = 0; - for(; delta.z<maxIterations.z; ++delta.z) - { - for(; delta.y<maxIterations.y; ++delta.y) - { - for(; delta.x<maxIterations.x; ++delta.x) - { - Vec<size_t> roiStart1,roiStart2; - Vec<size_t> curSizes = Vec<size_t>(calcNewROI(delta,roiStart1Init,roiStart2Init,imageDims,roiStart1,roiStart2)); - if(maxVol<curSizes.product()) - { - maxVol = curSizes.product(); - maxSizes = curSizes; - } - } - } - } - - - return normCovarResults; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaSegment.cuh b/src/c/Cuda/CudaSegment.cuh deleted file mode 100644 index 966ce71ac1a2be2a7a26a457fcbb7cfdabe989c0..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaSegment.cuh +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once -#include "CudaThreshold.cuh" -#include "CudaMaxFilter.cuh" -#include "CudaMinFilter.cuh" - -template <class PixelType> -PixelType* cSegment(const PixelType* imageIn, Vec<size_t> dims, double alpha, Vec<size_t> kernelDims, float* kernel=NULL, - PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - PixelType thresh = cOtsuThresholdValue(imageIn,dims,device); - thresh = (PixelType)(thresh*alpha); - - PixelType* imOut = setUpOutIm(dims, imageOut); - - PixelType minVal = std::numeric_limits<PixelType>::min(); - PixelType maxVal = std::numeric_limits<PixelType>::max(); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - if (kernel==NULL) - { - kernelDims = kernelDims.clamp(Vec<size_t>(1,1,1),dims); - float* ones = new float[kernelDims.product()]; - for (int i=0; i<kernelDims.product(); ++i) - ones[i] = 1.0f; - - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, ones, sizeof(float)*kernelDims.product())); - delete[] ones; - } - else - { - HANDLE_ERROR(cudaMemcpyToSymbol(cudaConstKernel, kernel, sizeof(float)*kernelDims.product())); - } - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - int blockSize = getKernelMaxThreads(cudaThreshold<PixelType>); - blockSize = MIN(blockSize, getKernelMaxThreads(cudaMinFilter<PixelType>)); - blockSize = MIN(blockSize, getKernelMaxThreads(cudaMaxFilter<PixelType>)); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,kernelDims,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - DEBUG_KERNEL_CHECK(); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaThreshold<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),thresh,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - cudaMinFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),kernelDims, - minVal,maxVal); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - cudaMaxFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),kernelDims, - minVal,maxVal); - DEBUG_KERNEL_CHECK(); - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaStdFilter.cuh b/src/c/Cuda/CudaStdFilter.cuh deleted file mode 100644 index 58e8cc5933629cc480030a403726550841789aac..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaStdFilter.cuh +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "KernelIterator.cuh" -#include "Vec.h" -#include <vector> -#include "CHelpers.h" -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" - -template <class PixelType> -__global__ void cudaStdFilter(CudaImageContainer<PixelType> imageIn,CudaImageContainer<PixelType> imageOut,Vec<size_t> hostKernelDims) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if(coordinate<imageIn.getDims()) - { - double val = 0; - double kernelVolume = 0; - Vec<size_t> kernelDims = hostKernelDims; - KernelIterator kIt(coordinate, imageIn.getDims(), kernelDims); - - for(; !kIt.end(); ++kIt) - { - val += imageIn(kIt.getImageCoordinate()); - ++kernelVolume; - } - - double mu = val/kernelVolume; - - kIt.reset(); - - for(; !kIt.end(); ++kIt) - { - val += SQR(imageIn(kIt.getImageCoordinate())-mu); - } - - imageOut(coordinate) = sqrt(val/(kernelVolume-1)); - } -} - -template <class PixelType> -PixelType* cStdFilter(const PixelType* imageIn,Vec<size_t> dims,Vec<size_t> neighborhood,PixelType** imageOut=NULL,int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims,imageOut); - - neighborhood = neighborhood.clamp(Vec<size_t>(1,1,1),dims); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t memAvail,total; - cudaMemGetInfo(&memAvail,&total); - - int blockSize = getKernelMaxThreads(cudaStdFilter<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(memAvail*MAX_MEM_AVAIL),props,neighborhood,blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks,maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for(std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaStdFilter<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()),neighborhood); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} diff --git a/src/c/Cuda/CudaSum.cuh b/src/c/Cuda/CudaSum.cuh deleted file mode 100644 index 5c15fb21ec5fbeedce3486e14ae047465fe350af..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaSum.cuh +++ /dev/null @@ -1,109 +0,0 @@ -#pragma once -#include "Vec.h" -#include "CudaUtilities.cuh" -#include "cuda_runtime.h" - -template <class PixelTypeIn, class OutType> -__global__ void cudaSum(const PixelTypeIn* arrayIn, OutType* arrayOut, size_t n) -{ - extern __shared__ unsigned char sharedMem[]; - OutType* sums = (OutType*)sharedMem; - - size_t i = threadIdx.x + blockIdx.x*blockDim.x; - size_t imStride = blockDim.x*gridDim.x; - - if (i<n) - { - sums[threadIdx.x] = (OutType)(arrayIn[i]); - while (i+imStride<n) - { - sums[threadIdx.x] += (OutType)(arrayIn[i+imStride]); - i += imStride; - } - } - else - { - sums[threadIdx.x] = 0; - } - - __syncthreads(); - - for (int localStride=blockDim.x/2; localStride>0; localStride=localStride/2) - { - if (threadIdx.x<localStride) - sums[threadIdx.x] += sums[threadIdx.x+localStride]; - - __syncthreads(); - } - - if (threadIdx.x==0) - { - arrayOut[blockIdx.x] = sums[0]; - } - __syncthreads(); -} - -template < class OutType, class PixelTypeIn> -OutType cSumArray(const PixelTypeIn* imageIn, size_t n, int device=0) -{ - cudaSetDevice(device); - OutType sum = 0; - OutType* deviceSum; - OutType* hostSum; - PixelTypeIn* deviceBuffer; - - cudaDeviceProp props; - cudaGetDeviceProperties(&props, device); - - if (n <= props.maxThreadsPerBlock) - { - for (size_t i = 0; i < n; ++i) - { - sum += imageIn[i]; - } - - return sum; - } - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - size_t numValsPerChunk = MIN(n,(size_t)((availMem*MAX_MEM_AVAIL)/sizeof(PixelTypeIn))); - - int threads = getKernelMaxThreads(cudaSum<PixelTypeIn,OutType>); - int maxBlocks = (int)ceil((double)numValsPerChunk/(threads*2)); - - HANDLE_ERROR(cudaMalloc((void**)&deviceBuffer,sizeof(PixelTypeIn)*numValsPerChunk)); - HANDLE_ERROR(cudaMalloc((void**)&deviceSum,sizeof(OutType)*maxBlocks)); - - hostSum = new OutType[maxBlocks]; - - for (size_t startIdx=0; startIdx<n; startIdx += numValsPerChunk) - { - size_t curNumVals = MIN(numValsPerChunk,n-startIdx); - - HANDLE_ERROR(cudaMemcpy(deviceBuffer,imageIn+startIdx,sizeof(PixelTypeIn)*curNumVals,cudaMemcpyHostToDevice)); - - int blocks = (int)ceil((double)curNumVals/(threads*2)); - size_t sharedMemSize = sizeof(OutType)*threads; - - cudaSum<<<blocks,threads,sharedMemSize>>>(deviceBuffer,deviceSum,curNumVals); - DEBUG_KERNEL_CHECK(); - - HANDLE_ERROR(cudaMemcpy(hostSum,deviceSum,sizeof(OutType)*blocks,cudaMemcpyDeviceToHost)); - - for (int i=0; i<blocks; ++i) - { - sum += hostSum[i]; - } - - memset(hostSum,0,sizeof(OutType)*maxBlocks); - } - - HANDLE_ERROR(cudaFree(deviceSum)); - HANDLE_ERROR(cudaFree(deviceBuffer)); - - delete[] hostSum; - - return sum; -} \ No newline at end of file diff --git a/src/c/Cuda/CudaThreshold.cuh b/src/c/Cuda/CudaThreshold.cuh deleted file mode 100644 index b50b45a9371a36c06ffb78fedeb360c2cf06f67d..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaThreshold.cuh +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once - -#include "CudaImageContainer.cuh" -#include "Vec.h" -#include <vector> -#include "ImageChunk.h" -#include "CudaDeviceImages.cuh" -#include "CHelpers.h" -#include "CudaHistogram.cuh" - -template <class PixelType> -__global__ void cudaThreshold( CudaImageContainer<PixelType> imageIn, CudaImageContainer<PixelType> imageOut, PixelType threshold, - PixelType minValue, PixelType maxValue ) -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; - - if (coordinate<imageIn.getDims()) - { - imageOut(coordinate) = (imageIn(coordinate)>=threshold) ? (maxValue) : (minValue); - } -} - -template <class PixelType> -PixelType* cThresholdFilter(const PixelType* imageIn, Vec<size_t> dims, PixelType thresh, PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - PixelType* imOut = setUpOutIm(dims, imageOut); - - PixelType minVal = std::numeric_limits<PixelType>::min(); - PixelType maxVal = std::numeric_limits<PixelType>::max(); - - cudaDeviceProp props; - cudaGetDeviceProperties(&props,device); - - size_t availMem, total; - cudaMemGetInfo(&availMem,&total); - - int blockSize = getKernelMaxThreads(cudaThreshold<PixelType>); - - std::vector<ImageChunk> chunks = calculateBuffers<PixelType>(dims,2,(size_t)(availMem*MAX_MEM_AVAIL),props,Vec<size_t>(0,0,0),blockSize); - - Vec<size_t> maxDeviceDims; - setMaxDeviceDims(chunks, maxDeviceDims); - - CudaDeviceImages<PixelType> deviceImages(2,maxDeviceDims,device); - - for (std::vector<ImageChunk>::iterator curChunk=chunks.begin(); curChunk!=chunks.end(); ++curChunk) - { - curChunk->sendROI(imageIn,dims,deviceImages.getCurBuffer()); - deviceImages.setNextDims(curChunk->getFullChunkSize()); - - cudaThreshold<<<curChunk->blocks,curChunk->threads>>>(*(deviceImages.getCurBuffer()),*(deviceImages.getNextBuffer()), - thresh,minVal,maxVal); - DEBUG_KERNEL_CHECK(); - - deviceImages.incrementBuffer(); - - curChunk->retriveROI(imOut,dims,deviceImages.getCurBuffer()); - } - - return imOut; -} - -template <class PixelType> -PixelType* cOtsuThresholdFilter(const PixelType* imageIn, Vec<size_t> dims, double alpha=1.0, PixelType** imageOut=NULL, int device=0) -{ - cudaSetDevice(device); - PixelType thresh = cOtsuThresholdValue(imageIn,dims,device); - thresh = (PixelType)(thresh*alpha); - - return cThresholdFilter(imageIn,dims,thresh,imageOut,device); -} \ No newline at end of file diff --git a/src/c/Cuda/CudaUtilities.cpp b/src/c/Cuda/CudaUtilities.cpp index fa3eb4e9db61ddc9420a60368329971e4956e046..3d9eea42af3c295a911ad61e251bdef18fc2ff32 100644 --- a/src/c/Cuda/CudaUtilities.cpp +++ b/src/c/Cuda/CudaUtilities.cpp @@ -63,32 +63,3 @@ void calcBlockThread(const Vec<size_t>& dims, size_t maxThreads, dim3 &blocks, d blocks.y = (unsigned int)ceil((float)dims.y/threads.y); blocks.z = (unsigned int)ceil((float)dims.z/threads.z); } - -size_t memoryAvailable(int device, size_t* totalOut/*=NULL*/) -{ - HANDLE_ERROR(cudaSetDevice(device)); - size_t free, total; - HANDLE_ERROR(cudaMemGetInfo(&free,&total)); - - if (totalOut!=NULL) - *totalOut = total; - - return free; -} - -bool checkFreeMemory(size_t needed, int device, bool throws/*=false*/) -{ - size_t free = memoryAvailable(device); - if (needed>free) - { - if (throws) - { - char buff[255]; - sprintf_s(buff,"Out of CUDA Memory!\nNeed: %zu\nHave: %zu\n",needed,free); - throw std::runtime_error(buff); - } - return false; - } - return true; -} - diff --git a/src/c/Cuda/CudaUtilities.cuh b/src/c/Cuda/CudaUtilities.cuh deleted file mode 100644 index 69a1c9ae9f1783d8c9977f95e398080929b123ee..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaUtilities.cuh +++ /dev/null @@ -1,95 +0,0 @@ -#pragma once - -#include "Vec.h" -#include "Defines.h" -#include "ImageDimensions.cuh" -#include "ImageContainer.h" - -#include <cuda_runtime.h> -#include <stdio.h> -#include <stdexcept> -#include <vector> -#include <cuda_occupancy.h> -#include <functional> - -template <typename T, typename U> -int getKernelMaxThreadsSharedMem(T func, U f, int threadLimit = 0) -{ - int blockSizeMax = 0; - int minGridSize = 0; - - cudaOccupancyMaxPotentialBlockSizeVariableSMem(&minGridSize, &blockSizeMax, func, f, threadLimit); - - return blockSizeMax; -} - -template <typename T> -int getKernelMaxThreads(T func, int threadLimit=0) -{ - int blockSizeMax = 0; - int minGridSize = 0; - - cudaOccupancyMaxPotentialBlockSize(&minGridSize, &blockSizeMax, func, 0, threadLimit); - - return blockSizeMax; -} - - -#ifdef _DEBUG -#define DEBUG_KERNEL_CHECK() { cudaThreadSynchronize(); gpuErrchk( cudaPeekAtLastError() ); } -#else -#define DEBUG_KERNEL_CHECK() {} -#endif // _DEBUG - -static void HandleError( cudaError_t err, const char *file, int line ) -{ - if (err != cudaSuccess) - { - char* errorMessage = new char[255]; - sprintf_s(errorMessage, 255, "%s in %s at line %d\n", cudaGetErrorString( err ), file, line ); - throw std::runtime_error(errorMessage); - } -} -#define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ )) - -inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true) -{ - if (code != cudaSuccess) - { - char buff[255]; - sprintf_s(buff, "GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line); - throw std::runtime_error(buff); - } -} -#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } - -template <class PixelType> -void setUpOutIm(ImageDimensions dims, ImageContainer<PixelType>& imageOut) -{ - if(imageOut.getPtr()==NULL) - { - imageOut.getPtr() = new PixelType[dims.getNumElements()]; - imageOut.dimensions = dims; - } - else if(imageOut.dimensions!=dims) - { - throw std::runtime_error("Image out buffer malformed!"); - } -} - -Vec<size_t> GetThreadBlockCoordinate() -{ - Vec<size_t> coordinate; - coordinate.x = threadIdx.x+blockIdx.x * blockDim.x; - coordinate.y = threadIdx.y+blockIdx.y * blockDim.y; - coordinate.z = threadIdx.z+blockIdx.z * blockDim.z; - - return coordinate; -} - -size_t memoryAvailable(int device, size_t* totalOut=NULL); -bool checkFreeMemory(size_t needed, int device, bool throws=false); -void calcBlockThread(const Vec<size_t>& dims, const cudaDeviceProp &prop, dim3 &blocks, dim3 &threads, size_t maxThreads=std::numeric_limits<size_t>::max()); -Vec<size_t> createGaussianKernel(Vec<float> sigma, float** kernel, Vec<int>& iterations); -Vec<size_t> createLoGKernel(Vec<float> sigma, float** kernelOut, size_t& kernSize); -Vec<size_t> createGaussianKernelFull(Vec<float> sigma, float** kernelOut, Vec<size_t> maxKernelSize = Vec<size_t>(std::numeric_limits<size_t>::max())); diff --git a/src/c/Cuda/CudaUtilities.h b/src/c/Cuda/CudaUtilities.h index 37fa1271d63af5080a74a06d8c9016bf2524a1b8..02c0874673a6804ea2d2df3d35ddf5bad28d109e 100644 --- a/src/c/Cuda/CudaUtilities.h +++ b/src/c/Cuda/CudaUtilities.h @@ -1,13 +1,13 @@ #pragma once -#include "cuda_runtime.h" -#include <stdio.h> -#include <stdexcept> -#include <vector> #include "Vec.h" #include "Defines.h" #include "ImageContainer.h" +#include <cuda_runtime.h> +#include <stdio.h> +#include <stdexcept> +#include <vector> #include <cuda_occupancy.h> template <typename T, typename U> @@ -61,19 +61,5 @@ inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true) } #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } -template <class PixelType> -ImageContainer<PixelType> setUpOutIm(Vec<size_t> dims, PixelType** imageOut) -{ - - PixelType* imOut; - if (imageOut==NULL) - imOut = new PixelType[dims.product()]; - else - imOut = *imageOut; - - return imOut; -} -size_t memoryAvailable(int device, size_t* totalOut=NULL); -bool checkFreeMemory(size_t needed, int device, bool throws=false); void calcBlockThread(const Vec<size_t>& dims, size_t maxThreads, dim3 &blocks, dim3 &threads); diff --git a/src/c/Cuda/CudaVariance.cuh b/src/c/Cuda/CudaVariance.cuh deleted file mode 100644 index d5832b603c2c4c1716e65ce6a1fb1b717478b945..0000000000000000000000000000000000000000 --- a/src/c/Cuda/CudaVariance.cuh +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "Vec.h" -#include "CudaSum.cuh" -#include "CudaAdd.cuh" -#include "CudaPow.cuh" -#include "CudaConvertType.cuh" - -template <class PixelType, class PixelTypeOut> -double cVariance(const PixelType* imageIn, Vec<size_t> dims, int device=0, PixelTypeOut* imageOut=NULL) -{ - cudaSetDevice(device); - double variance = 0.0; - - double imMean = cSumArray<double>(imageIn, dims.product(), device) / (double)dims.product(); - PixelTypeOut* imSub = cAddConstant<PixelType, PixelTypeOut>(imageIn, dims, -imMean, NULL, device); - PixelTypeOut* imP = cImagePow<PixelTypeOut>(imSub, dims, 2.0, NULL, device); - variance = cSumArray<double>(imP, dims.product(), device) / (double)dims.product(); - - if (imageOut != NULL) - { - memcpy(imageOut, imSub, sizeof(PixelTypeOut)*dims.product()); - } - - delete[] imSub; - delete[] imP; - - return variance; -} diff --git a/src/c/Cuda/ImageChunk.cpp b/src/c/Cuda/ImageChunk.cpp index 7aa72f8b7c4dc43cd5f6ce12efd6058b10a9241c..84f56c357f87834a5d67297ad32bed26cbc71fea 100644 --- a/src/c/Cuda/ImageChunk.cpp +++ b/src/c/Cuda/ImageChunk.cpp @@ -40,17 +40,17 @@ std::vector<ImageChunk> calculateChunking(ImageDimensions imageDims, ImageDimens Vec<size_t> devSpatialDims = deviceDims.dims; if(imageDims.dims.x>deviceDims.dims.x) - numChunks.dims.x = (size_t)ceil((double)imageDims.dims.x/chunkDelta.x); + numChunks.dims.x = (size_t)ceil((double)imageDims.dims.x/chunkDelta.dims.x); else chunkDelta.dims.x = imageDims.dims.x; if(imageDims.dims.y>deviceDims.dims.y) - numChunks.dims.y = (size_t)ceil((double)imageDims.dims.y/chunkDelta.y); + numChunks.dims.y = (size_t)ceil((double)imageDims.dims.y/chunkDelta.dims.y); else chunkDelta.dims.y = imageDims.dims.y; if(imageDims.dims.z>deviceDims.dims.z) - numChunks.dims.z = (size_t)ceil((double)imageDims.dims.z/chunkDelta.z); + numChunks.dims.z = (size_t)ceil((double)imageDims.dims.z/chunkDelta.dims.z); else chunkDelta.dims.z = imageDims.dims.z; diff --git a/src/c/Cuda/Kernel.cu b/src/c/Cuda/Kernel.cu index eaa0e1d96b7000b9f6adcc913ed65e3842ed0337..d2b55c73a667305c185e7e4c4180c5d559e24ee9 100644 --- a/src/c/Cuda/Kernel.cu +++ b/src/c/Cuda/Kernel.cu @@ -1,5 +1,5 @@ #include "Kernel.cuh" -#include "CudaUtilities.cuh" +#include "CudaUtilities.h" Kernel::Kernel(Vec<size_t> dimensions) { diff --git a/src/c/Cuda/KernelIterator.cuh b/src/c/Cuda/KernelIterator.cuh index 2f97a5cc6dffc5aa5a800077ab630ed626c49e33..91c48deb69121a50b80301d71a9e9f99e765f8e1 100644 --- a/src/c/Cuda/KernelIterator.cuh +++ b/src/c/Cuda/KernelIterator.cuh @@ -3,6 +3,15 @@ #include "Vec.h" #include "ImageDimensions.cuh" +#include <cuda_runtime.h> + +__global__ void GetThreadBlockCoordinate(Vec<size_t>& coordinate) +{ + coordinate.x = threadIdx.x + blockIdx.x * blockDim.x; + coordinate.y = threadIdx.y + blockIdx.y * blockDim.y; + coordinate.z = threadIdx.z + blockIdx.z * blockDim.z; +} + class KernelIterator { public: diff --git a/src/c/CudaImageProcessor_dll.vcxproj b/src/c/CudaImageProcessor_dll.vcxproj index b4d4dd7f2b89a57d748fd3ffff96f33518aa259b..001da6333c8605c8b4b77f66b1564ccc96e3a6ab 100644 --- a/src/c/CudaImageProcessor_dll.vcxproj +++ b/src/c/CudaImageProcessor_dll.vcxproj @@ -23,58 +23,26 @@ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> </ExcludedFromBuild> </ClInclude> - <ClInclude Include="Cuda\CudaAdd.cuh"> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - </ExcludedFromBuild> - </ClInclude> - <ClInclude Include="Cuda\CudaClamp.cuh" /> - <ClInclude Include="Cuda\CudaContrastEnhancement.cuh" /> - <ClInclude Include="Cuda\CudaConvertType.cuh" /> <ClInclude Include="Cuda\CudaDeviceCount.cuh" /> <ClInclude Include="Cuda\CudaDeviceImages.cuh" /> + <ClInclude Include="Cuda\CudaDeviceInfo.h" /> <ClInclude Include="Cuda\CudaDeviceStats.h" /> - <ClInclude Include="Cuda\CudaEntropyFilter.cuh" /> - <ClInclude Include="Cuda\CudaGaussianFilter.cuh" /> - <ClInclude Include="Cuda\CudaGetMinMax.cuh" /> - <ClInclude Include="Cuda\CudaGetROI.cuh" /> - <ClInclude Include="Cuda\CudaHistogram.cuh" /> <ClInclude Include="Cuda\CudaImageContainer.cuh" /> <ClInclude Include="Cuda\CudaImageContainerClean.cuh" /> - <ClInclude Include="Cuda\CudaImageCopy.cuh" /> - <ClInclude Include="Cuda\CudaIntensityProjection.cuh" /> - <ClInclude Include="Cuda\CudaLinearUnmixing.cuh" /> - <ClInclude Include="Cuda\CudaLoG.cuh"> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - </ExcludedFromBuild> - </ClInclude> - <ClInclude Include="Cuda\CudaMarkovRandomFieldDenoiser.cuh" /> - <ClInclude Include="Cuda\CudaMask.cuh" /> - <ClInclude Include="Cuda\CudaMaxFilter.cuh" /> - <ClInclude Include="Cuda\CudaMeanFilter.cuh" /> - <ClInclude Include="Cuda\CudaMedianFilter.cuh" /> <ClInclude Include="Cuda\CudaMemoryStats.cuh" /> - <ClInclude Include="Cuda\CudaMinFilter.cuh" /> - <ClInclude Include="Cuda\CudaMorphologicalOperations.cuh" /> - <ClInclude Include="Cuda\CudaMultAddFilter.cuh" /> - <ClInclude Include="Cuda\CudaMultiplyImage.cuh" /> - <ClInclude Include="Cuda\CudaNeighborhoodSum.cuh" /> - <ClInclude Include="Cuda\CudaNormalizedCovariance.cuh" /> - <ClInclude Include="Cuda\CudaPolyTransferFunc.cuh" /> - <ClInclude Include="Cuda\CudaPow.cuh" /> - <ClInclude Include="Cuda\CudaRegionGrowing.cuh" /> - <ClInclude Include="Cuda\CudaResize.cuh" /> - <ClInclude Include="Cuda\CudaRidgidRegistaration.cuh" /> - <ClInclude Include="Cuda\CudaSegment.cuh" /> - <ClInclude Include="Cuda\CudaStdFilter.cuh" /> - <ClInclude Include="Cuda\CudaSum.cuh" /> - <ClInclude Include="Cuda\CudaThreshold.cuh" /> <ClInclude Include="Cuda\CudaUtilities.h" /> - <ClInclude Include="Cuda\CudaVariance.cuh" /> <ClInclude Include="Cuda\CWrappers.h" /> <ClInclude Include="Cuda\Defines.h" /> + <ClInclude Include="Cuda\FooKernel.cuh"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + </ClInclude> + <ClInclude Include="Cuda\FooValueManipulation.cuh"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + </ClInclude> <ClInclude Include="Cuda\ImageChunk.h" /> <ClInclude Include="Cuda\ImageContainer.h" /> <ClInclude Include="Cuda\ImageDimensions.cuh" /> + <ClInclude Include="Cuda\Kernel.cuh" /> <ClInclude Include="Cuda\KernelGenerators.h" /> <ClInclude Include="Cuda\KernelIterator.cuh" /> <ClInclude Include="Cuda\Vec.h" /> @@ -82,6 +50,9 @@ <ItemGroup> <ClCompile Include="Cuda\CHelpers.cpp" /> <ClCompile Include="Cuda\ImageChunk.cpp" /> + <CudaCompile Include="Cuda\Kernel.cu"> + <FileType>CppCode</FileType> + </CudaCompile> <ClCompile Include="Cuda\LoGKernel.cpp" /> </ItemGroup> <ItemGroup> diff --git a/src/c/CudaImageProcessor_dll.vcxproj.filters b/src/c/CudaImageProcessor_dll.vcxproj.filters index 6fa5ef8b38424faea13002275cf6130c9f2c2cd1..d236fd716909331517a9401f7a894dd031703075 100644 --- a/src/c/CudaImageProcessor_dll.vcxproj.filters +++ b/src/c/CudaImageProcessor_dll.vcxproj.filters @@ -20,145 +20,55 @@ <ClInclude Include="Cuda\Vec.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaAdd.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaContrastEnhancement.cuh"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="Cuda\CudaDeviceImages.cuh"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaGaussianFilter.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaGetMinMax.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaGetROI.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaHistogram.cuh"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="Cuda\CudaImageContainer.cuh"> <Filter>Header Files</Filter> </ClInclude> <ClInclude Include="Cuda\CudaImageContainerClean.cuh"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaIntensityProjection.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMask.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMaxFilter.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMeanFilter.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMedianFilter.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMinFilter.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMorphologicalOperations.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMultAddFilter.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMultiplyImage.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaNormalizedCovariance.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaPolyTransferFunc.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaPow.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaSum.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaThreshold.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaSegment.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMarkovRandomFieldDenoiser.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaVariance.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaConvertType.cuh"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="Cuda\CudaDeviceCount.cuh"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaImageCopy.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaLinearUnmixing.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaMemoryStats.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaRidgidRegistaration.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaStdFilter.cuh"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="Cuda\CWrappers.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaRegionGrowing.cuh"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Cuda\CudaClamp.cuh"> + <ClInclude Include="Cuda\CudaDeviceStats.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaDeviceStats.h"> + <ClInclude Include="Cuda\KernelIterator.cuh"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaResize.cuh"> + <ClInclude Include="Cuda\ImageContainer.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaEntropyFilter.cuh"> + <ClInclude Include="Cuda\ImageChunk.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaLoG.cuh"> + <ClInclude Include="Cuda\CudaUtilities.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\KernelIterator.cuh"> + <ClInclude Include="Cuda\KernelGenerators.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaNeighborhoodSum.cuh"> + <ClInclude Include="Cuda\ImageDimensions.cuh"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\ImageContainer.h"> + <ClInclude Include="Cuda\CudaDeviceInfo.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\ImageChunk.h"> + <ClInclude Include="Cuda\FooValueManipulation.cuh"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\CudaUtilities.h"> + <ClInclude Include="Cuda\FooKernel.cuh"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\KernelGenerators.h"> + <ClInclude Include="Cuda\Kernel.cuh"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Cuda\ImageDimensions.cuh"> + <ClInclude Include="Cuda\CudaMemoryStats.cuh"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> @@ -192,5 +102,8 @@ <CudaCompile Include="Cuda\KernelIterator.cu"> <Filter>Source Files</Filter> </CudaCompile> + <CudaCompile Include="Cuda\Kernel.cu"> + <Filter>Source Files</Filter> + </CudaCompile> </ItemGroup> </Project> \ No newline at end of file diff --git a/src/c/Mex/CommandList.h b/src/c/Mex/CommandList.h index bd4cdc3975b1aca8430b54fd2c9162982d04f2a6..c6bda29f6faab1d1320200bdf8ed0324a1571f6a 100644 --- a/src/c/Mex/CommandList.h +++ b/src/c/Mex/CommandList.h @@ -38,43 +38,7 @@ BEGIN_MEX_COMMANDS DEF_MEX_COMMAND(Info) DEF_MEX_COMMAND(Help) // Additional specific mex commands should be added here. -DEF_MEX_COMMAND(AddConstant) -DEF_MEX_COMMAND(AddImageWith) -DEF_MEX_COMMAND(ApplyPolyTransformation) -DEF_MEX_COMMAND(ContrastEnhancement) DEF_MEX_COMMAND(DeviceCount) DEF_MEX_COMMAND(DeviceStats) -DEF_MEX_COMMAND(EntropyFilter) -DEF_MEX_COMMAND(GaussianFilter) -DEF_MEX_COMMAND(Histogram) -DEF_MEX_COMMAND(ImagePow) -DEF_MEX_COMMAND(LinearUnmixing) -DEF_MEX_COMMAND(LoG) -DEF_MEX_COMMAND(MarkovRandomFieldDenoiser) -DEF_MEX_COMMAND(MaxFilterEllipsoid) -DEF_MEX_COMMAND(MaxFilterKernel) -DEF_MEX_COMMAND(MaxFilterNeighborhood) -DEF_MEX_COMMAND(MeanFilter) -DEF_MEX_COMMAND(MedianFilter) -DEF_MEX_COMMAND(MinFilterEllipsoid) -DEF_MEX_COMMAND(MinFilterKernel) -DEF_MEX_COMMAND(MinFilterNeighborhood) -DEF_MEX_COMMAND(MinMax) -DEF_MEX_COMMAND(MorphologicalClosure) -DEF_MEX_COMMAND(MorphologicalOpening) -DEF_MEX_COMMAND(MultiplyImage) -DEF_MEX_COMMAND(MultiplyTwoImages) -DEF_MEX_COMMAND(NeighborhoodSum) -DEF_MEX_COMMAND(NormalizedCovariance) -DEF_MEX_COMMAND(NormalizedHistogram) -DEF_MEX_COMMAND(OtsuThresholdFilter) -DEF_MEX_COMMAND(OtsuThresholdValue) -DEF_MEX_COMMAND(RegionGrowing) -DEF_MEX_COMMAND(Resize) -DEF_MEX_COMMAND(SumArray) -DEF_MEX_COMMAND(Segment) -DEF_MEX_COMMAND(StdFilter) -DEF_MEX_COMMAND(ThresholdFilter) -DEF_MEX_COMMAND(TileImage) -DEF_MEX_COMMAND(Variance) +DEF_MEX_COMMAND(MaxFilter) END_MEX_COMMANDS \ No newline at end of file diff --git a/src/c/Mex/MexAddConstant.cpp b/src/c/Mex/MexAddConstant.cpp deleted file mode 100644 index 9e3ae3d5a0c878081b7db89a157788e0ed3096b2..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexAddConstant.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "MexCommand.h" -#include "CWrappers.h" -#include "Vec.h" - -void MexAddConstant::execute(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double additive = mxGetScalar(prhs[1]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - addConstant(imageIn,imageDims,additive,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - addConstant(imageIn,imageDims,additive,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - addConstant(imageIn,imageDims,additive,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - addConstant(imageIn,imageDims,additive,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - addConstant(imageIn,imageDims,additive,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - addConstant(imageIn,imageDims,additive,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - addConstant(imageIn,imageDims,additive,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexAddConstant::check(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - if (!mxIsDouble(prhs[1])) - return "Additive needs to be a single double!"; - - return ""; -} - -void MexAddConstant::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("additive"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); -} - -void MexAddConstant::help(std::vector<std::string>& helpLines) const -{ - helpLines.push_back("This will add a constant value at every voxel location."); - - helpLines.push_back("\tImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tAdditive -- must be a double and will be floored if input is an integer type."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\tImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space."); -} \ No newline at end of file diff --git a/src/c/Mex/MexAddImageWith.cpp b/src/c/Mex/MexAddImageWith.cpp deleted file mode 100644 index c1ccf1b5a294dedb26c22e80a47980ecf9fea4c0..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexAddImageWith.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "MexCommand.h" -#include "CWrappers.h" -#include "Vec.h" - - void MexAddImageWith::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - int device = 0; - - if (nrhs>3) - device = mat_to_c((int)mxGetScalar(prhs[3])); - - double additive = mxGetScalar(prhs[2]); - - Vec<size_t> imageDims, imageDims2; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - unsigned char* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - addImageWith(imageIn,imageIn2,imageDims,additive,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - unsigned short* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - addImageWith(imageIn,imageIn2,imageDims,additive,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - short* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - addImageWith(imageIn,imageIn2,imageDims,additive,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - unsigned int* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - addImageWith(imageIn,imageIn2,imageDims,additive,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - int* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - addImageWith(imageIn,imageIn2,imageDims,additive,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - float* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - addImageWith(imageIn,imageIn2,imageDims,additive,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - double* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - addImageWith(imageIn,imageIn2,imageDims,additive,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - } - - std::string MexAddImageWith::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - if (nrhs<3 || nrhs>4) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims1 = mxGetNumberOfDimensions(prhs[0]); - if (numDims1>3) - return "Image can have a maximum of three dimensions!"; - - size_t numDims2 = mxGetNumberOfDimensions(prhs[1]); - if (numDims2>3) - return "Image can have a maximum of three dimensions!"; - - if (numDims1!=numDims2) - return "Image dimensions must agree!"; - - if (!mxIsDouble(prhs[2])) - return "Factor needs to be a double!"; - - return ""; - } - - void MexAddImageWith::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const - { - inArgs.push_back("imageIn1"); - inArgs.push_back("imageIn2"); - inArgs.push_back("factor"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); - } - - void MexAddImageWith::help(std::vector<std::string>& helpLines) const - { - helpLines.push_back("This takes two images and adds them together."); - - helpLines.push_back("\tImageIn1 -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tImageIn2 -- can be an image up to three dimensions and of the same type as imageIn1."); - helpLines.push_back("\tFactor -- this is a multiplier to the second image in the form imageOut = imageIn1 + factor*imageIn2."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\timageOut -- this is the result of imageIn1 + factor*imageIn2 and will be of the same type as imageIn1."); - } \ No newline at end of file diff --git a/src/c/Mex/MexApplyPolyTransformation.cpp b/src/c/Mex/MexApplyPolyTransformation.cpp deleted file mode 100644 index 575399b3504c9f96bac4bdd36061e34866dce220..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexApplyPolyTransformation.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexApplyPolyTransformation::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>6) - device = mat_to_c((int)mxGetScalar(prhs[6])); - - double a, b, c; - a = mxGetScalar(prhs[1]); - b = mxGetScalar(prhs[2]); - c = mxGetScalar(prhs[3]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned char mn = std::numeric_limits<unsigned char>::lowest(); - unsigned char mx = std::numeric_limits<unsigned char>::max(); - - if (nrhs>5) - mx = MIN((unsigned char)mxGetScalar(prhs[5]),mx); - - if (nrhs>4) - mn = MAX((unsigned char)mxGetScalar(prhs[4]),mn); - - applyPolyTransferFunction(imageIn,imageDims,a,b,c,mn,mx,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned short mn = std::numeric_limits<unsigned short>::lowest(); - unsigned short mx = std::numeric_limits<unsigned short>::max(); - - if (nrhs>5) - mx = MIN((unsigned short)mxGetScalar(prhs[5]),mx); - - if (nrhs>4) - mn = MAX((unsigned short)mxGetScalar(prhs[4]),mn); - - applyPolyTransferFunction(imageIn,imageDims,a,b,c,mn,mx,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - short mn = std::numeric_limits<short>::lowest(); - short mx = std::numeric_limits<short>::max(); - - if (nrhs>5) - mx = MIN((short)mxGetScalar(prhs[5]),mx); - - if (nrhs>4) - mn = MAX((short)mxGetScalar(prhs[4]),mn); - - applyPolyTransferFunction(imageIn,imageDims,a,b,c,mn,mx,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned int mn = std::numeric_limits<unsigned int>::lowest(); - unsigned int mx = std::numeric_limits<unsigned int>::max(); - - if (nrhs>5) - mx = MIN((unsigned int)mxGetScalar(prhs[5]),mx); - - if (nrhs>4) - mn = MAX((unsigned int)mxGetScalar(prhs[4]),mn); - - applyPolyTransferFunction(imageIn,imageDims,a,b,c,mn,mx,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - int mn = std::numeric_limits<int>::lowest(); - int mx = std::numeric_limits<int>::max(); - - if (nrhs>5) - mx = MIN((int)mxGetScalar(prhs[5]),mx); - - if (nrhs>4) - mn = MAX((int)mxGetScalar(prhs[4]),mn); - - applyPolyTransferFunction(imageIn,imageDims,a,b,c,mn,mx,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - float mn = std::numeric_limits<float>::lowest(); - float mx = std::numeric_limits<float>::max(); - - if (nrhs>5) - mx = MIN((float)mxGetScalar(prhs[5]),mx); - - if (nrhs>4) - mn = MAX((float)mxGetScalar(prhs[4]),mn); - - applyPolyTransferFunction(imageIn,imageDims,a,b,c,mn,mx,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - double mn = (double)std::numeric_limits<double>::lowest(); - double mx = (double)std::numeric_limits<double>::max(); - - if (nrhs>5) - mx = MIN(mxGetScalar(prhs[5]),mx); - - if (nrhs>4) - mn = MAX(mxGetScalar(prhs[4]),mn); - - applyPolyTransferFunction(imageIn,imageDims,a,b,c,mn,mx,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexApplyPolyTransformation::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<4 || nrhs>7) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - if (!mxIsDouble(prhs[1]) || !mxIsDouble(prhs[2]) || !mxIsDouble(prhs[3])) - return "a,b,c all have to be doubles!"; - - return ""; -} - -void MexApplyPolyTransformation::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("a"); - inArgs.push_back("b"); - inArgs.push_back("c"); - inArgs.push_back("min"); - inArgs.push_back("max"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); -} - -void MexApplyPolyTransformation::help(std::vector<std::string>& helpLines) const -{ - helpLines.push_back("This returns an image with the quadradic function applied. ImageOut = a*ImageIn^2 + b*ImageIn + c"); - - helpLines.push_back("\tA -- this multiplier is applied to the square of the image."); - helpLines.push_back("\tB -- this multiplier is applied to the image."); - helpLines.push_back("\tC -- is the constant additive."); - helpLines.push_back("\tMin -- this is an optional parameter to clamp the output to and is useful for signed or floating point to remove negative values."); - helpLines.push_back("\tMax -- this is an optional parameter to clamp the output to."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\tImageOut -- this is the result of ImageOut = a*ImageIn^2 + b*ImageIn + c and is the same dimension and type as imageIn."); -} diff --git a/src/c/Mex/MexContrastEnhancement.cpp b/src/c/Mex/MexContrastEnhancement.cpp deleted file mode 100644 index 6e1ba5c7c10339a1f053f54e8f3f6619e08f49d3..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexContrastEnhancement.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexContrastEnhancement::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>3) - device = mat_to_c((int)mxGetScalar(prhs[3])); - - double* sigmasD = (double*)mxGetData(prhs[1]); - double* neighborhoodD = (double*)mxGetData(prhs[2]); - - - Vec<float> sigmas((float)sigmasD[0],(float)sigmasD[1],(float)sigmasD[2]); - Vec<size_t> neighborhood((size_t)neighborhoodD[0],(size_t)neighborhoodD[1],(size_t)neighborhoodD[2]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - contrastEnhancement(imageIn,imageDims,sigmas,neighborhood,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - contrastEnhancement(imageIn,imageDims,sigmas,neighborhood,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - contrastEnhancement(imageIn,imageDims,sigmas,neighborhood,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - contrastEnhancement(imageIn,imageDims,sigmas,neighborhood,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - contrastEnhancement(imageIn,imageDims,sigmas,neighborhood,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - contrastEnhancement(imageIn,imageDims,sigmas,neighborhood,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - contrastEnhancement(imageIn,imageDims,sigmas,neighborhood,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexContrastEnhancement::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<3 || nrhs>4) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl= mxGetNumberOfElements(prhs[1]); - if (numEl!=3 || !mxIsDouble(prhs[1])) - return "Sigmas has to be an array of three doubles!"; - - numEl = mxGetNumberOfElements(prhs[2]); - if (numEl!=3 || !mxIsDouble(prhs[2])) - return "Median neighborhood has to be an array of three doubles!"; - - return ""; -} - -void MexContrastEnhancement::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("sigma"); - inArgs.push_back("MedianNeighborhood"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); -} - -void MexContrastEnhancement::help(std::vector<std::string>& helpLines) const -{ - helpLines.push_back("This attempts to increase contrast by removing noise as proposed by Michel et al. This starts with subtracting off a highly smoothed version of imageIn followed by median filter."); - - helpLines.push_back("\tImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tSigma -- these values will create a n-dimensional Gaussian kernel to get a smoothed image that will be subtracted of the original."); - helpLines.push_back("\t\tN is the number of dimensions of imageIn"); - helpLines.push_back("\t\tThe larger the sigma the more object preserving the high pass filter will be (e.g. sigma > 35)"); - helpLines.push_back("\tMedianNeighborhood -- this is the neighborhood size in each dimension that will be evaluated for the median neighborhood filter."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\tImageOut -- will have the same dimensions and type as imageIn."); -} \ No newline at end of file diff --git a/src/c/Mex/MexEntropyFilter.cpp b/src/c/Mex/MexEntropyFilter.cpp deleted file mode 100644 index daabab2081f3238085b07c008f6faf78daa18f81..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexEntropyFilter.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexEntropyFilter::execute(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - int device = 0; - - if(nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - size_t numDims = mxGetNumberOfDimensions(prhs[1]); - const mwSize* DIMS = mxGetDimensions(prhs[1]); - - Vec<size_t> kernDims; - - if(numDims>2) - kernDims.z = (size_t)DIMS[2]; - else - kernDims.z = 1; - - if(numDims>1) - kernDims.y = (size_t)DIMS[1]; - else - kernDims.y = 1; - - if(numDims>0) - kernDims.x = (size_t)DIMS[0]; - else - return; - - double* matKernel; - matKernel = (double*)mxGetData(prhs[1]); - - float* kernel = new float[kernDims.product()]; - for(int i = 0; i<kernDims.product(); ++i) - kernel[i] = (float)matKernel[i]; - - Vec<size_t> imageDims(0, 0, 0); - setupDims(prhs[0], &imageDims); - - double* imageOut; - setupOutputPointers(&(plhs[0]), imageDims, &imageOut); - - if(mxIsUint8(prhs[0])) - { - unsigned char* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - entropyFilter(imageIn, imageDims, kernDims, kernel, &imageOut, device); - } else if(mxIsUint16(prhs[0])) - { - unsigned short* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - entropyFilter(imageIn, imageDims, kernDims, kernel, &imageOut, device); - } else if(mxIsInt16(prhs[0])) - { - short* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - entropyFilter(imageIn, imageDims, kernDims, kernel, &imageOut, device); - } else if(mxIsUint32(prhs[0])) - { - unsigned int* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - entropyFilter(imageIn, imageDims, kernDims, kernel, &imageOut, device); - } else if(mxIsInt32(prhs[0])) - { - int* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - entropyFilter(imageIn, imageDims, kernDims, kernel, &imageOut, device); - } else if(mxIsSingle(prhs[0])) - { - float* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - entropyFilter(imageIn, imageDims, kernDims, kernel, &imageOut, device); - } else if(mxIsDouble(prhs[0])) - { - double* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - entropyFilter(imageIn, imageDims, kernDims, kernel, &imageOut, device); - } else - { - mexErrMsgTxt("Image type not supported!"); - } - - delete[] kernel; -} - -std::string MexEntropyFilter::check(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - if(nrhs<2||nrhs>3) - return "Incorrect number of inputs!"; - - if(nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if(imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t kernDims = mxGetNumberOfDimensions(prhs[1]); - if(kernDims<1||kernDims>3) - return "Kernel can only be either 1-D, 2-D, or 3-D!"; - - return ""; -} - -void MexEntropyFilter::usage(std::vector<std::string>& outArgs, std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("kernel"); - inArgs.push_back("device"); - outArgs.push_back("imageOut"); -} - -void MexEntropyFilter::help(std::vector<std::string>& helpLines) const -{ - //\ std::string msg = "\tThis will set each pixel/voxel to the max value of the neighborhood defined by the given kernel.\n"; - //\ msg += "\n"; - //\ return msg; -} diff --git a/src/c/Mex/MexGaussianFilter.cpp b/src/c/Mex/MexGaussianFilter.cpp deleted file mode 100644 index c9a53ae8cff6ced4c9e5a353edebf909cc0eb878..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexGaussianFilter.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - - void MexGaussianFilter::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* sigmasMat = (double*)mxGetData(prhs[1]); - Vec<float> sigmas((float)(sigmasMat[0]),(float)(sigmasMat[1]),(float)(sigmasMat[2])); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - gaussianFilter(imageIn,imageDims,sigmas,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - gaussianFilter(imageIn,imageDims,sigmas,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - gaussianFilter(imageIn,imageDims,sigmas,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - gaussianFilter(imageIn,imageDims,sigmas,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - gaussianFilter(imageIn,imageDims,sigmas,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - gaussianFilter(imageIn,imageDims,sigmas,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - gaussianFilter(imageIn,imageDims,sigmas,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - } - - std::string MexGaussianFilter::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl = mxGetNumberOfElements(prhs[1]); - if (numEl!=3 || !mxIsDouble(prhs[1])) - return "Sigmas must be an array of three doubles!"; - - return ""; - } - - void MexGaussianFilter::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const - { - inArgs.push_back("imageIn"); - inArgs.push_back("sigma"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); - } - - void MexGaussianFilter::help(std::vector<std::string>& helpLines) const - { - helpLines.push_back("Smooths image using a Gaussian kernel."); - - helpLines.push_back("\tImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tSigma -- these values will create a n-dimensional Gaussian kernel to get a smoothed image that will be subtracted of the original."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\tImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space."); - } \ No newline at end of file diff --git a/src/c/Mex/MexHistogram.cpp b/src/c/Mex/MexHistogram.cpp deleted file mode 100644 index b81c9da5219723d7477fb78055d78fe04d7d4acf..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexHistogram.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - - void MexHistogram::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - int device = 0; - - if (nrhs>4) - device = mat_to_c((int)mxGetScalar(prhs[4])); - - unsigned int arraySize = (unsigned int)mxGetScalar(prhs[1]); - size_t* hist; - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned char mn = std::numeric_limits<unsigned char>::lowest(); - unsigned char mx = std::numeric_limits<unsigned char>::max(); - - if (nrhs>2) - mn = MAX(mn,(unsigned char)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(unsigned char)mxGetScalar(prhs[3])); - - hist = histogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned short mn = std::numeric_limits<unsigned short>::lowest(); - unsigned short mx = std::numeric_limits<unsigned short>::max(); - - if (nrhs>2) - mn = MAX(mn,(unsigned short)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(unsigned short)mxGetScalar(prhs[3])); - - hist = histogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - short mn = std::numeric_limits<short>::lowest(); - short mx = std::numeric_limits<short>::max(); - - if (nrhs>2) - mn = MAX(mn,(short)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(short)mxGetScalar(prhs[3])); - - hist = histogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned int mn = std::numeric_limits<unsigned int>::lowest(); - unsigned int mx = std::numeric_limits<unsigned int>::max(); - - if (nrhs>2) - mn = MAX(mn,(unsigned int)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(unsigned int)mxGetScalar(prhs[3])); - - hist = histogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - int mn = std::numeric_limits<int>::lowest(); - int mx = std::numeric_limits<int>::max(); - - if (nrhs>2) - mn = MAX(mn,(int)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(int)mxGetScalar(prhs[3])); - - hist = histogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - float mn = std::numeric_limits<float>::lowest(); - float mx = std::numeric_limits<float>::max(); - - if (nrhs>2) - mn = MAX(mn,(float)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(float)mxGetScalar(prhs[3])); - - hist = histogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - double mn = std::numeric_limits<double>::lowest(); - double mx = std::numeric_limits<double>::max(); - - if (nrhs>2) - mn = MAX(mn,mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,mxGetScalar(prhs[3])); - - hist = histogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - return; - } - - const mwSize DIM = arraySize; - plhs[0] = mxCreateNumericArray(1,&DIM,mxUINT64_CLASS,mxREAL); - size_t* histPr = (size_t*)mxGetPr(plhs[0]); - - for (unsigned int i=0; i<arraySize; ++i) - histPr[i] = hist[i]; - - delete[] hist; - } - - std::string MexHistogram::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - if (nrhs<2 || nrhs>5) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one outputs!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - return ""; - } - - void MexHistogram::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const - { - inArgs.push_back("imageIn"); - inArgs.push_back("numBins"); - inArgs.push_back("min"); - inArgs.push_back("max"); - inArgs.push_back("device"); - - outArgs.push_back("histogram"); - } - - void MexHistogram::help(std::vector<std::string>& helpLines) const - { - helpLines.push_back("Creates a histogram array with numBins bins between min/max values."); - - helpLines.push_back("\tImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tNumBins -- number of bins that the histogram should partition the signal into."); - helpLines.push_back("\tMin -- this is the minimum value for the histogram."); - helpLines.push_back("\t\tIf min is not provided, the min of the image type is used."); - helpLines.push_back("\tMax -- this is the maximum value for the histogram."); - helpLines.push_back("\t\tIf min is not provided, the min of the image type is used."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\tImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space."); - } \ No newline at end of file diff --git a/src/c/Mex/MexImagePow.cpp b/src/c/Mex/MexImagePow.cpp deleted file mode 100644 index 9d4f7ad902c0e724ef7f785050bbe6bb33ee1217..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexImagePow.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "MexCommand.h" -#include "CWrappers.h" -#include "Vec.h" - - void MexImagePow::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double power = mxGetScalar(prhs[1]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - imagePow(imageIn,imageDims,power,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - imagePow(imageIn,imageDims,power,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - imagePow(imageIn,imageDims,power,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - imagePow(imageIn,imageDims,power,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - imagePow(imageIn,imageDims,power,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - imagePow(imageIn,imageDims,power,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - imagePow(imageIn,imageDims,power,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - } - - std::string MexImagePow::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - if (!mxIsDouble(prhs[1])) - return "Power has to be a single double!"; - - return ""; - } - - void MexImagePow::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const - { - inArgs.push_back("imageIn"); - inArgs.push_back("power"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); - } - - void MexImagePow::help(std::vector<std::string>& helpLines) const - { - helpLines.push_back("This will raise each voxel value to the power provided."); - - helpLines.push_back("\tImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tPower -- must be a double."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\tImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space."); - } \ No newline at end of file diff --git a/src/c/Mex/MexLinearUnmixing.cpp b/src/c/Mex/MexLinearUnmixing.cpp deleted file mode 100644 index c6d9454f930e4a7aca182c75a4d443d9680dadab..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexLinearUnmixing.cpp +++ /dev/null @@ -1,142 +0,0 @@ -#include "MexCommand.h" -#include "CWrappers.h" -#include "Vec.h" - -void MexLinearUnmixing::execute(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - int device = 0; - - if (nrhs > 3) - device = mat_to_c((int)mxGetScalar(prhs[3])); - - size_t numImDims = mxGetNumberOfDimensions(prhs[0]); - const mwSize* IM_DIMS = mxGetDimensions(prhs[0]); - size_t numMatrixDims = mxGetNumberOfDimensions(prhs[1]); - const mwSize* MATRIX_DIMS = mxGetDimensions(prhs[1]); - size_t numImages = IM_DIMS[numImDims - 1]; - - Vec<size_t> imageDims, umixingDims; - - double* unmixing; - setupImagePointers(prhs[1], &unmixing, &umixingDims); - float* unmix = new float[umixingDims.product()]; - for (int i = 0; i < umixingDims.product(); ++i) - unmix[i] = (float)unmixing[i]; - - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn, *imageOut; - setupImagePointers(prhs[0], &imageIn, &imageDims); - plhs[0] = mxCreateNumericArray(numImDims, IM_DIMS, mxUINT8_CLASS, mxREAL); - imageOut = (unsigned char*)mxGetData(plhs[0]); - - linearUnmixing(imageIn, imageDims, numImages, unmix, umixingDims, &imageOut, device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn, *imageOut; - setupImagePointers(prhs[0], &imageIn, &imageDims); - plhs[0] = mxCreateNumericArray(numImDims, IM_DIMS, mxUINT16_CLASS, mxREAL); - imageOut = (unsigned short*)mxGetData(plhs[0]); - - linearUnmixing(imageIn, imageDims, numImages, unmix, umixingDims, &imageOut, device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn, *imageOut; - setupImagePointers(prhs[0], &imageIn, &imageDims); - plhs[0] = mxCreateNumericArray(numImDims, IM_DIMS, mxINT16_CLASS, mxREAL); - imageOut = (short*)mxGetData(plhs[0]); - - linearUnmixing(imageIn, imageDims, numImages, unmix, umixingDims, &imageOut, device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn, *imageOut; - setupImagePointers(prhs[0], &imageIn, &imageDims); - plhs[0] = mxCreateNumericArray(numImDims, IM_DIMS, mxUINT32_CLASS, mxREAL); - imageOut = (unsigned int*)mxGetData(plhs[0]); - - linearUnmixing(imageIn, imageDims, numImages, unmix, umixingDims, &imageOut, device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn, *imageOut; - setupImagePointers(prhs[0], &imageIn, &imageDims); - plhs[0] = mxCreateNumericArray(numImDims, IM_DIMS, mxINT32_CLASS, mxREAL); - imageOut = (int*)mxGetData(plhs[0]); - - linearUnmixing(imageIn, imageDims, numImages, unmix, umixingDims, &imageOut, device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn, *imageOut; - setupImagePointers(prhs[0], &imageIn, &imageDims); - plhs[0] = mxCreateNumericArray(numImDims, IM_DIMS, mxSINGLE_CLASS, mxREAL); - imageOut = (float*)mxGetData(plhs[0]); - - linearUnmixing(imageIn, imageDims, numImages, unmix, umixingDims, &imageOut, device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn, *imageOut; - setupImagePointers(prhs[0], &imageIn, &imageDims); - plhs[0] = mxCreateNumericArray(numImDims, IM_DIMS, mxDOUBLE_CLASS, mxREAL); - imageOut = (double*)mxGetData(plhs[0]); - - linearUnmixing(imageIn, imageDims, numImages, unmix, umixingDims, &imageOut, device); - } - else - { - delete[] unmix; - mexErrMsgTxt("Image type not supported!"); - } - - delete[] unmix; -} - -std::string MexLinearUnmixing::check(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - if (nrhs < 2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs != 1) - return "Requires one output!"; - - size_t numDims1 = int(mxGetNumberOfDimensions(prhs[0])); - const mwSize* DIMS1 = mxGetDimensions(prhs[0]); - size_t numDims2 = int(mxGetNumberOfDimensions(prhs[1])); - const mwSize* DIMS2 = mxGetDimensions(prhs[1]); - - size_t numImages = DIMS1[numDims1 - 1]; - - if (numDims1 > 4) - return "Input images can be at most 3-D!"; - if (numDims2 != 2) - return "Unmixing matrix should be 2-D!"; - if (DIMS2[0] != DIMS2[1] || numImages != DIMS2[0]) - return "Unmixing matrix needs to be NxN, where N is the number of images to unmix!"; - if (!mxIsDouble(prhs[1])) - return "Unmixing matrix needs to be a doubles!"; - - return ""; -} - -void MexLinearUnmixing::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("mixedImages"); - inArgs.push_back("unmixMatrix"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); -} - -void MexLinearUnmixing::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tLinear Unmixing takes an image that is one dimension larger than the\n"; -//\ msg += "\tinput images. This can be done with the cat function: cat(ndims(im)+1,im,im2,..).\n"; -//\ msg += "\tThe output image will have the same dimension as this input image and contains the\n"; -//\ msg += "\tunmixed images as single precision floating point values."; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexLoG.cpp b/src/c/Mex/MexLoG.cpp deleted file mode 100644 index 3da9ece382a505ea153ddd04779358a6a2f60577..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexLoG.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexLoG::execute(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - int device = 0; - - if(nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* sigmasMat = (double*)mxGetData(prhs[1]); - Vec<float> sigmas((float)(sigmasMat[0]), (float)(sigmasMat[1]), (float)(sigmasMat[2])); - - Vec<size_t> imageDims; - setupDims(prhs[0], &imageDims); - float* imageOut = NULL; - setupOutputPointers(&plhs[0], imageDims, &imageOut); - - if(mxIsUint8(prhs[0])) - { - unsigned char* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - loG(imageIn, imageDims, sigmas, &imageOut, device); - } else if(mxIsUint16(prhs[0])) - { - unsigned short* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - loG(imageIn, imageDims, sigmas, &imageOut, device); - } else if(mxIsInt16(prhs[0])) - { - short* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - loG(imageIn, imageDims, sigmas, &imageOut, device); - } else if(mxIsUint32(prhs[0])) - { - unsigned int* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - loG(imageIn, imageDims, sigmas, &imageOut, device); - } else if(mxIsInt32(prhs[0])) - { - int* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - loG(imageIn, imageDims, sigmas, &imageOut, device); - } else if(mxIsSingle(prhs[0])) - { - float* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - loG(imageIn, imageDims, sigmas, &imageOut, device); - } else if(mxIsDouble(prhs[0])) - { - double* imageIn; - setupInputPointers(prhs[0], &imageDims, &imageIn); - - loG(imageIn, imageDims, sigmas, &imageOut, device); - } else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexLoG::check(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - if(nrhs<2||nrhs>3) - return "Incorrect number of inputs!"; - - if(nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if(numDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl = mxGetNumberOfElements(prhs[1]); - if(numEl!=3||!mxIsDouble(prhs[1])) - return "Sigmas must be an array of three doubles!"; - - return ""; -} - -void MexLoG::usage(std::vector<std::string>& outArgs, std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("sigma"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); -} - -void MexLoG::help(std::vector<std::string>& helpLines) const -{ - helpLines.push_back("Smooths image using a Gaussian kernel."); - - helpLines.push_back("\tImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tSigma -- these values will create a n-dimensional Gaussian kernel to get a smoothed image that will be subtracted of the original."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\tImageOut -- will have the same dimensions and type as imageIn. Values are clamped to the range of the image space."); -} \ No newline at end of file diff --git a/src/c/Mex/MexMarkovRandomFieldDenoiser.cpp b/src/c/Mex/MexMarkovRandomFieldDenoiser.cpp deleted file mode 100644 index 2a4b49c6d097d51137163ff52ef5d4c667c7934f..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMarkovRandomFieldDenoiser.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "MexCommand.h" - -#include "MexCommand.h" -#include "CWrappers.h" -#include "Vec.h" - -void MexMarkovRandomFieldDenoiser::execute(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double maxIterations = mxGetScalar(prhs[1]); - - Vec<size_t> imageDims; -// if (mxIsUint8(prhs[0])) -// { -// unsigned char* imageIn,* imageOut; -// setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); -// -// markovRandomFieldDenoiser(imageIn,imageDims,maxIterations,&imageOut,device); -// } -// else if (mxIsUint16(prhs[0])) -// { -// unsigned short* imageIn,* imageOut; -// setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); -// -// markovRandomFieldDenoiser(imageIn,imageDims,maxIterations,&imageOut,device); -// } -// else if (mxIsInt16(prhs[0])) -// { -// short* imageIn,* imageOut; -// setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); -// -// markovRandomFieldDenoiser(imageIn,imageDims,maxIterations,&imageOut,device); -// } -// else if (mxIsUint32(prhs[0])) -// { -// unsigned int* imageIn,* imageOut; -// setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); -// -// markovRandomFieldDenoiser(imageIn,imageDims,maxIterations,&imageOut,device); -// } -// else if (mxIsInt32(prhs[0])) -// { -// int* imageIn,* imageOut; -// setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); -// -// markovRandomFieldDenoiser(imageIn,imageDims,maxIterations,&imageOut,device); -// } -// else - if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - markovRandomFieldDenoiser(imageIn,imageDims,int(maxIterations),&imageOut,device); - } -// else if (mxIsDouble(prhs[0])) -// { -// double* imageIn,* imageOut; -// setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); -// -// markovRandomFieldDenoiser(imageIn,imageDims,maxIterations,&imageOut,device); -// } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexMarkovRandomFieldDenoiser::check(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - return ""; -} - -void MexMarkovRandomFieldDenoiser::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("maxIterations"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexMarkovRandomFieldDenoiser::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tMarkov Random Field Denoiser will denoise the image using a noise estimation iteratively until the image\n"; -//\ msg += "\tmatches the noise model or the max iterations is reached.\n"; -//\ msg += "\tSee Ceccarelli, M. (2007). \"A Finite Markov Random Field approach to fast edge-preserving image recovery.\"\n"; -//\ msg += "Image and Vision Computing 25(6): 792-804.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMaxFilterEllipsoid.cpp b/src/c/Mex/MexMaxFilterEllipsoid.cpp deleted file mode 100644 index 5298821fb462984a350bdd563fd3feeff402776a..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMaxFilterEllipsoid.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include "MexCommand.h" -#include "CHelpers.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMaxFilterEllipsoid::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* radiiD = (double*)mxGetData(prhs[1]); - - Vec<size_t> radii((size_t)radiiD[0],(size_t)radiiD[1],(size_t)radiiD[2]); - Vec<size_t> kernDims; - float* circleKernel = createEllipsoidKernel(radii,kernDims); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - delete[] circleKernel; -} - -std::string MexMaxFilterEllipsoid::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if (imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl = mxGetNumberOfElements(prhs[1]); - if (numEl!=3 || !mxIsDouble(prhs[1])) - return "Radii must be an array of three doubles!"; - - return ""; -} - -void MexMaxFilterEllipsoid::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("radius"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexMaxFilterEllipsoid::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tThis will set each pixel/voxel to the max value of an ellipsoidal neighborhood with the radii given.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMaxFilterKernel.cpp b/src/c/Mex/MexMaxFilterKernel.cpp deleted file mode 100644 index f49c0597bc68fcc1ad799be7015c17c6400ae4db..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMaxFilterKernel.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMaxFilterKernel::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - size_t numDims = mxGetNumberOfDimensions(prhs[1]); - const mwSize* DIMS = mxGetDimensions(prhs[1]); - - Vec<size_t> kernDims; - - if (numDims>2) - kernDims.z = (size_t)DIMS[2]; - else - kernDims.z = 1; - - if (numDims>1) - kernDims.y = (size_t)DIMS[1]; - else - kernDims.y = 1; - - if (numDims>0) - kernDims.x = (size_t)DIMS[0]; - else - return; - - double* matKernel; - matKernel = (double*)mxGetData(prhs[1]); - - float* kernel = new float[kernDims.product()]; - for (int i=0; i<kernDims.product(); ++i) - kernel[i] = (float)matKernel[i]; - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - delete[] kernel; -} - -std::string MexMaxFilterKernel::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if (imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t kernDims = mxGetNumberOfDimensions(prhs[1]); - if (kernDims<1 || kernDims>3) - return "Kernel can only be either 1-D, 2-D, or 3-D!"; - - return ""; -} - -void MexMaxFilterKernel::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("kernel"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexMaxFilterKernel::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tThis will set each pixel/voxel to the max value of the neighborhood defined by the given kernel.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMaxFilterNeighborhood.cpp b/src/c/Mex/MexMaxFilterNeighborhood.cpp deleted file mode 100644 index 6a1bc8fbe8a7e682d61e322a7ab145e6c9562c8b..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMaxFilterNeighborhood.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - - void MexMaxFilterNeighborhood::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* nbh = (double*)mxGetData(prhs[1]); - Vec<size_t> neighborhood((size_t)nbh[0],(size_t)nbh[1],(size_t)nbh[2]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - maxFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - } - - std::string MexMaxFilterNeighborhood::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if (imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl = mxGetNumberOfElements(prhs[1]); - if (numEl!=3) - return "Neighborhood needs to be an array of three doubles!"; - - return ""; - } - - void MexMaxFilterNeighborhood::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const - { - inArgs.push_back("imageIn"); - inArgs.push_back("Neighborhood"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); - } - - - void MexMaxFilterNeighborhood::help(std::vector<std::string>& helpLines) const - { -//\ std::string msg = "\tThis will set each pixel/voxel to the max value within the neighborhood given.\n"; -//\ msg += "\n"; -//\ return msg; - } diff --git a/src/c/Mex/MexMeanFilter.cpp b/src/c/Mex/MexMeanFilter.cpp deleted file mode 100644 index dcc89624d5f67a053356fae2efa4f34716445608..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMeanFilter.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - - void MexMeanFilter::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* neighborhoodD = (double*)mxGetData(prhs[1]); - Vec<size_t> neighborhood((size_t)neighborhoodD[1],(size_t)neighborhoodD[0],(size_t)neighborhoodD[2]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - meanFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - meanFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - meanFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - meanFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - meanFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - meanFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - meanFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - } - - std::string MexMeanFilter::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl= mxGetNumberOfElements(prhs[1]); - if (numEl!=3 || !mxIsDouble(prhs[1])) - return "Neighborhood has to be an array of three doubles!"; - - return ""; - } - - void MexMeanFilter::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const - { - inArgs.push_back("imageIn"); - inArgs.push_back("Neighborhood"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); - } - - void MexMeanFilter::help(std::vector<std::string>& helpLines) const - { -//\ std::string msg = "\tNeighborhoodX, NeighborhoodY, and NeighborhoodZ are the directions and area to look for a given pixel."; -//\ msg += "\n"; -//\ return msg; - } diff --git a/src/c/Mex/MexMedianFilter.cpp b/src/c/Mex/MexMedianFilter.cpp deleted file mode 100644 index 73a34e07430ee2c63509925512a752d51b0dc1d2..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMedianFilter.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMedianFilter::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* neighborhoodD = (double*)mxGetData(prhs[1]); - Vec<size_t> neighborhood((size_t)neighborhoodD[1],(size_t)neighborhoodD[0],(size_t)neighborhoodD[2]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - medianFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - medianFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - medianFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - medianFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - medianFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - medianFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - medianFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexMedianFilter::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl = mxGetNumberOfElements(prhs[1]); - if (numEl!=3 || !mxIsDouble(prhs[1])) - return "Neighborhood has to be an array of three doubles!"; - - return ""; -} - -void MexMedianFilter::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("Neighborhood"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexMedianFilter::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tNeighborhoodX, NeighborhoodY, and NeighborhoodZ are the directions and area to look for a given pixel."; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMinFilterEllipsoid.cpp b/src/c/Mex/MexMinFilterEllipsoid.cpp deleted file mode 100644 index d231e0c8d0354c767ad69d5ef8cf40378b55ddaa..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMinFilterEllipsoid.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include "MexCommand.h" -#include "CHelpers.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMinFilterEllipsoid::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* radiiD = (double*)mxGetData(prhs[1]); - - Vec<size_t> radii((size_t)radiiD[0],(size_t)radiiD[1],(size_t)radiiD[2]); - Vec<size_t> kernDims; - float* circleKernel = createEllipsoidKernel(radii,kernDims); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,circleKernel,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - delete[] circleKernel; -} - -std::string MexMinFilterEllipsoid::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if (imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl = mxGetNumberOfElements(prhs[1]); - if (numEl!=3 || !mxIsDouble(prhs[1])) - return "Radii must be an array of three doubles!"; - - return ""; -} - -void MexMinFilterEllipsoid::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("radius"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexMinFilterEllipsoid::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tThis will set each pixel/voxel to the min value of an ellipsoidal neighborhood with the radii given.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMinFilterKernal.cpp b/src/c/Mex/MexMinFilterKernal.cpp deleted file mode 100644 index 47ad7221acb5982b766bd9d83b76d98654efae1d..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMinFilterKernal.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMinFilterKernel::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - size_t numDims = mxGetNumberOfDimensions(prhs[1]); - const mwSize* DIMS = mxGetDimensions(prhs[1]); - - Vec<size_t> kernDims; - - if (numDims>2) - kernDims.z = (size_t)DIMS[2]; - else - kernDims.z = 1; - - if (numDims>1) - kernDims.y = (size_t)DIMS[1]; - else - kernDims.y = 1; - - if (numDims>0) - kernDims.x = (size_t)DIMS[0]; - else - return; - - double* matKernel; - matKernel = (double*)mxGetData(prhs[1]); - - float* kernel = new float[kernDims.product()]; - for (int i=0; i<kernDims.product(); ++i) - kernel[i] = (float)matKernel[i]; - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - delete[] kernel; -} - -std::string MexMinFilterKernel::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if (imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t kernDims = mxGetNumberOfDimensions(prhs[0]); - if (kernDims<1 || kernDims>3) - return "Kernel can only be either 1-D, 2-D, or 3-D!"; - - return ""; -} - -void MexMinFilterKernel::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("kernel"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexMinFilterKernel::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tThis will set each pixel/voxel to the min value of the neighborhood defined by the given kernel.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMinFilterNeighborhood.cpp b/src/c/Mex/MexMinFilterNeighborhood.cpp deleted file mode 100644 index 63197327c06e474392050d459af6a81b36b34752..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMinFilterNeighborhood.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMinFilterNeighborhood::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* nbh = (double*)mxGetData(prhs[1]); - Vec<size_t> neighborhood((size_t)nbh[0],(size_t)nbh[1],(size_t)nbh[2]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - minFilter(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexMinFilterNeighborhood::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if (imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl = mxGetNumberOfElements(prhs[1]); - if (numEl!=3) - return "Neighborhood needs to be an array of three doubles!"; - - return ""; -} - -void MexMinFilterNeighborhood::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("Neighborhood"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - - -void MexMinFilterNeighborhood::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tThis will set each pixel/voxel to the min value within the neighborhood given.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMinMax.cpp b/src/c/Mex/MexMinMax.cpp deleted file mode 100644 index b9bd018f2f7eab26459baae3bd8825f6aac0e62e..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMinMax.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMinMax::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>1) - device = mat_to_c((int)mxGetScalar(prhs[1])); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned char minVal, maxVal; - getMinMax(imageIn,imageDims,minVal,maxVal,device); - plhs[0] = mxCreateDoubleScalar(minVal); - plhs[1] = mxCreateDoubleScalar(maxVal); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned short minVal, maxVal; - getMinMax(imageIn,imageDims,minVal,maxVal,device); - plhs[0] = mxCreateDoubleScalar(minVal); - plhs[1] = mxCreateDoubleScalar(maxVal); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - short minVal, maxVal; - - getMinMax(imageIn,imageDims,minVal,maxVal,device); - plhs[0] = mxCreateDoubleScalar(minVal); - plhs[1] = mxCreateDoubleScalar(maxVal); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned int minVal, maxVal; - getMinMax(imageIn,imageDims,minVal,maxVal,device); - plhs[0] = mxCreateDoubleScalar(minVal); - plhs[1] = mxCreateDoubleScalar(maxVal); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - int minVal, maxVal; - - getMinMax(imageIn,imageDims,minVal,maxVal,device); - plhs[0] = mxCreateDoubleScalar(minVal); - plhs[1] = mxCreateDoubleScalar(maxVal); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - float minVal, maxVal; - getMinMax(imageIn,imageDims,minVal,maxVal,device); - plhs[0] = mxCreateDoubleScalar(minVal); - plhs[1] = mxCreateDoubleScalar(maxVal); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - double minVal, maxVal; - getMinMax(imageIn,imageDims,minVal,maxVal,device); - plhs[0] = mxCreateDoubleScalar(minVal); - plhs[1] = mxCreateDoubleScalar(maxVal); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexMinMax::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<1 || nrhs>2) - return "Incorrect number of inputs!"; - - if (nlhs!=2) - return "Requires two outputs!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - return ""; -} - -void MexMinMax::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); -inArgs.push_back("device"); - -outArgs.push_back("min"); -outArgs.push_back("max"); -} - -void MexMinMax::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tReturns the minimum and maximum values.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMorphologicalClosure.cpp b/src/c/Mex/MexMorphologicalClosure.cpp deleted file mode 100644 index 4fe646df8ee2a8b4e1302520096b38f418fa5880..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMorphologicalClosure.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMorphologicalClosure::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - float* kernel = NULL; - Vec<size_t> kernDims = FillKernel(prhs[1], &kernel); - - Vec<size_t> imageDims; - if(mxIsLogical(prhs[0])) - { - bool* imageIn, *imageOut; - setupImagePointers(prhs[0], &imageIn, &imageDims, &plhs[0], &imageOut); - - morphologicalClosure(imageIn, imageDims, kernDims, kernel, &imageOut, device); - } else if(mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalClosure(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalClosure(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalClosure(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalClosure(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalClosure(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalClosure(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalClosure(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - delete[] kernel; -} - -std::string MexMorphologicalClosure::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if (imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t kernDims = mxGetNumberOfDimensions(prhs[0]); - if (kernDims<1 || kernDims>3) - return "Kernel can only be either 1-D, 2-D, or 3-D!"; - - return ""; -} - -void MexMorphologicalClosure::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("kernel"); - inArgs.push_back("device"); - outArgs.push_back("imageOut"); -} - -void MexMorphologicalClosure::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tThis will set each pixel/voxel to the max value of the neighborhood defined by the given kernel,\n"; -//\ msg += "\tfollowed by a min value of the neighborhood defined by the given kernel.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMorphologicalOpening.cpp b/src/c/Mex/MexMorphologicalOpening.cpp deleted file mode 100644 index dced0b02320a5744cb8b03115349c0208b4eefd6..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMorphologicalOpening.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMorphologicalOpening::execute(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - float* kernel = NULL; - Vec<size_t> kernDims = FillKernel(prhs[1],&kernel); - - Vec<size_t> imageDims; - if(mxIsLogical(prhs[0])) - { - bool* imageIn, *imageOut; - setupImagePointers(prhs[0], &imageIn, &imageDims, &plhs[0], &imageOut); - - morphologicalOpening(imageIn, imageDims, kernDims, kernel, &imageOut, device); - } - else if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalOpening(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalOpening(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalOpening(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalOpening(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalOpening(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalOpening(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - morphologicalOpening(imageIn,imageDims,kernDims,kernel,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - delete[] kernel; -} - -std::string MexMorphologicalOpening::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if (imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t kernDims = mxGetNumberOfDimensions(prhs[0]); - if (kernDims<1 || kernDims>3) - return "Kernel can only be either 1-D, 2-D, or 3-D!"; - - return ""; -} - -void MexMorphologicalOpening::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("kernel"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexMorphologicalOpening::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tThis will set each pixel/voxel to the in value of the neighborhood defined by the given kernel,\n"; -//\ msg += "\tfollowed by a max value of the neighborhood defined by the given kernel.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexMultiplyImage.cpp b/src/c/Mex/MexMultiplyImage.cpp deleted file mode 100644 index 1b3d491f44741a79f1586e48139418fa44a3bdd2..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMultiplyImage.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - - void MexMultiplyImage::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double multiplier = mxGetScalar(prhs[1]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - multiplyImage(imageIn,imageDims,multiplier,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - multiplyImage(imageIn,imageDims,multiplier,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - multiplyImage(imageIn,imageDims,multiplier,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - multiplyImage(imageIn,imageDims,multiplier,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - multiplyImage(imageIn,imageDims,multiplier,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - multiplyImage(imageIn,imageDims,multiplier,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - multiplyImage(imageIn,imageDims,multiplier,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - } - - std::string MexMultiplyImage::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - if (!mxIsDouble(prhs[1])) - return "Multiplier needs to be a single double!"; - - return ""; - } - - void MexMultiplyImage::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const - { - inArgs.push_back("imageIn"); - inArgs.push_back("multiplier"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); - } - - void MexMultiplyImage::help(std::vector<std::string>& helpLines) const - { -//\ std::string msg = "\tMultiplier must be a double.\n"; -//\ msg += "\tImageOut will not roll over. Values are clamped to the range of the image space.\n"; -//\ msg += "\tImageOut will have the same dimensions as imageIn.\n"; -//\ msg += "\n"; -//\ return msg; - } diff --git a/src/c/Mex/MexMultiplyImageWith.cpp b/src/c/Mex/MexMultiplyImageWith.cpp deleted file mode 100644 index 279f236ac4ecf0c8646cfdbce1cc018f02a80f1c..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexMultiplyImageWith.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexMultiplyTwoImages::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>3) - device = mat_to_c((int)mxGetScalar(prhs[3])); - - double factor = mxGetScalar(prhs[2]); - - Vec<size_t> imageDims, imageDims2; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - unsigned char* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - multiplyImageWith(imageIn,imageIn2,imageDims,factor,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - unsigned short* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - multiplyImageWith(imageIn,imageIn2,imageDims,factor,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - short* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - multiplyImageWith(imageIn,imageIn2,imageDims,factor,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - unsigned int* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - multiplyImageWith(imageIn,imageIn2,imageDims,factor,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - int* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - multiplyImageWith(imageIn,imageIn2,imageDims,factor,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - float* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - multiplyImageWith(imageIn,imageIn2,imageDims,factor,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - double* imageIn2; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims!=imageDims2) - mexErrMsgTxt("Image dimensions must agree!"); - - multiplyImageWith(imageIn,imageIn2,imageDims,factor,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexMultiplyTwoImages::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<3 || nrhs>4) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims1 = mxGetNumberOfDimensions(prhs[0]); - if (numDims1>3) - return "Image can only be either 2D or 3D!"; - - size_t numDims2 = mxGetNumberOfDimensions(prhs[1]); - if (numDims2>3) - return "Image can have a maximum of three dimensions!"; - - if (numDims1!=numDims2) - return "Image can have a maximum of three dimensions!"; - - if (!mxIsDouble(prhs[2])) - return "Factor needs to be a double!"; - - return ""; -} - -void MexMultiplyTwoImages::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn1"); - inArgs.push_back("imageIn2"); - inArgs.push_back("factor"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexMultiplyTwoImages::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tWhere factor is a multiplier. Pixel = factor * imageIn1 * imageIn2."; -//\ msg += "\tPixel value is floored at assignment only when integer.\n"; -//\ msg += "\tImageIn1 and ImageIn2 must have the same dimensions.\n"; -//\ msg += "\tImageOut will have the same dimensions as the input images.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexNeighborhoodSum.cpp b/src/c/Mex/MexNeighborhoodSum.cpp deleted file mode 100644 index 5a7deab8b3eacca121e6bc28dda6567a788cb896..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexNeighborhoodSum.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - - void MexNeighborhoodSum::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* nbh = (double*)mxGetData(prhs[1]); - Vec<size_t> neighborhood((size_t)nbh[0],(size_t)nbh[1],(size_t)nbh[2]); - - Vec<size_t> imageDims; - if (mxIsLogical(prhs[0])) - { - bool* imageIn; - unsigned char* imageOut; - setupInputPointers(prhs[0], &imageDims, &imageIn); - setupOutputPointers(&plhs[0], imageDims, &imageOut); - - imageOut = neighborhoodSum(imageIn, imageDims, neighborhood, NULL,&imageOut, device); - } - else if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn; - unsigned short* imageOut; - setupInputPointers(prhs[0], &imageDims, &imageIn); - setupOutputPointers(&plhs[0], imageDims, &imageOut); - - imageOut = neighborhoodSum(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn; - unsigned int* imageOut; - setupInputPointers(prhs[0], &imageDims, &imageIn); - //setupOutputPointers(&plhs[0], imageDims, &imageOut); - - imageOut = neighborhoodSum(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn; - int* imageOut; - setupInputPointers(prhs[0], &imageDims, &imageIn); - setupOutputPointers(&plhs[0], imageDims, &imageOut); - - imageOut = neighborhoodSum(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn; - double* imageOut; - setupInputPointers(prhs[0], &imageDims, &imageIn); - setupOutputPointers(&plhs[0], imageDims, &imageOut); - - imageOut = neighborhoodSum(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn; - double* imageOut; - setupInputPointers(prhs[0], &imageDims, &imageIn); - setupOutputPointers(&plhs[0], imageDims, &imageOut); - - imageOut = neighborhoodSum(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn; - double* imageOut; - setupInputPointers(prhs[0], &imageDims, &imageIn); - setupOutputPointers(&plhs[0], imageDims, &imageOut); - - imageOut = neighborhoodSum(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn; - double* imageOut; - setupInputPointers(prhs[0], &imageDims, &imageIn); - setupOutputPointers(&plhs[0], imageDims, &imageOut); - - imageOut = neighborhoodSum(imageIn,imageDims,neighborhood,NULL,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - } - - std::string MexNeighborhoodSum::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if (imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl = mxGetNumberOfElements(prhs[1]); - if (numEl!=3) - return "Neighborhood needs to be an array of three doubles!"; - - return ""; - } - - void MexNeighborhoodSum::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const - { - inArgs.push_back("imageIn"); - inArgs.push_back("Neighborhood"); - inArgs.push_back("device"); - outArgs.push_back("imageOut"); - } - - - void MexNeighborhoodSum::help(std::vector<std::string>& helpLines) const - { -//\ std::string msg = "\tThis will set each pixel/voxel to the max value within the neighborhood given.\n"; -//\ msg += "\n"; -//\ return msg; - } diff --git a/src/c/Mex/MexNormalizedCovariance.cpp b/src/c/Mex/MexNormalizedCovariance.cpp deleted file mode 100644 index ac24efa322d86a9e76299d8e5796c24c65a81419..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexNormalizedCovariance.cpp +++ /dev/null @@ -1,137 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexNormalizedCovariance::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double normCoVar; - - Vec<size_t> imageDims1, imageDims2; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn1,* imageIn2; - setupImagePointers(prhs[0],&imageIn1,&imageDims1); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims1!=imageDims2) - mexErrMsgTxt("Image Dimensions Must Match!\n"); - - normCoVar = normalizedCovariance(imageIn1,imageIn2,imageDims1,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn1,* imageIn2; - setupImagePointers(prhs[0],&imageIn1,&imageDims1); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims1!=imageDims2) - mexErrMsgTxt("Image Dimensions Must Match!\n"); - - normCoVar = normalizedCovariance(imageIn1,imageIn2,imageDims1,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn1,* imageIn2; - setupImagePointers(prhs[0],&imageIn1,&imageDims1); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims1!=imageDims2) - mexErrMsgTxt("Image Dimensions Must Match!\n"); - - normCoVar = normalizedCovariance(imageIn1,imageIn2,imageDims1,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn1,* imageIn2; - setupImagePointers(prhs[0],&imageIn1,&imageDims1); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims1!=imageDims2) - mexErrMsgTxt("Image Dimensions Must Match!\n"); - - normCoVar = normalizedCovariance(imageIn1,imageIn2,imageDims1,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn1,* imageIn2; - setupImagePointers(prhs[0],&imageIn1,&imageDims1); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims1!=imageDims2) - mexErrMsgTxt("Image Dimensions Must Match!\n"); - - normCoVar = normalizedCovariance(imageIn1,imageIn2,imageDims1,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn1,* imageIn2; - setupImagePointers(prhs[0],&imageIn1,&imageDims1); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims1!=imageDims2) - mexErrMsgTxt("Image Dimensions Must Match!\n"); - - normCoVar = normalizedCovariance(imageIn1,imageIn2,imageDims1,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn1,* imageIn2; - setupImagePointers(prhs[0],&imageIn1,&imageDims1); - setupImagePointers(prhs[1],&imageIn2,&imageDims2); - - if (imageDims1!=imageDims2) - mexErrMsgTxt("Image Dimensions Must Match!\n"); - - normCoVar = normalizedCovariance(imageIn1,imageIn2,imageDims1,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - plhs[0] = mxCreateDoubleScalar(normCoVar); -} - -std::string MexNormalizedCovariance::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims1 = mxGetNumberOfDimensions(prhs[0]); - if (numDims1>3) - return "Image can have a maximum of three dimensions!"; - - size_t numDims2= mxGetNumberOfDimensions(prhs[1]); - if (numDims2>3) - return "Image can have a maximum of three dimensions!"; - - if (numDims1!=numDims2) - return "Images must have the same dimensions!"; - - return ""; -} - -void MexNormalizedCovariance::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn1"); - inArgs.push_back("imageIn2"); -inArgs.push_back("device"); -outArgs.push_back("normalizedCovariance"); -} - -void MexNormalizedCovariance::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tThis will calculate how similar the images are to one another.\n"; -//\ msg += "\tThe return value will be between [-1,1]. Where 1 is exactly the same and -1 is exactly the opposite.\n"; -//\ msg += "\tImages must match in dimension.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexNormalizedHistogram.cpp b/src/c/Mex/MexNormalizedHistogram.cpp deleted file mode 100644 index ff06ddd84872382ab4cd37af82cbe2b82c5c0c37..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexNormalizedHistogram.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexNormalizedHistogram::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>4) - device = mat_to_c((int)mxGetScalar(prhs[4])); - - unsigned int arraySize = (unsigned int)mxGetScalar(prhs[1]); - double* hist; - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned char mn = std::numeric_limits<unsigned char>::lowest(); - unsigned char mx = std::numeric_limits<unsigned char>::max(); - - if (nrhs>2) - mn = MAX(mn,(unsigned char)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(unsigned char)mxGetScalar(prhs[3])); - - hist = normalizeHistogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned short mn = std::numeric_limits<unsigned short>::lowest(); - unsigned short mx = std::numeric_limits<unsigned short>::max(); - - if (nrhs>2) - mn = MAX(mn,(unsigned short)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(unsigned short)mxGetScalar(prhs[3])); - - hist = normalizeHistogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - short mn = std::numeric_limits<short>::lowest(); - short mx = std::numeric_limits<short>::max(); - - if (nrhs>2) - mn = MAX(mn,(short)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(short)mxGetScalar(prhs[3])); - - hist = normalizeHistogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - unsigned int mn = std::numeric_limits<unsigned int>::lowest(); - unsigned int mx = std::numeric_limits<unsigned int>::max(); - - if (nrhs>2) - mn = MAX(mn,(unsigned int)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(unsigned int)mxGetScalar(prhs[3])); - - hist = normalizeHistogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - int mn = std::numeric_limits<int>::lowest(); - int mx = std::numeric_limits<int>::max(); - - if (nrhs>2) - mn = MAX(mn,(int)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(int)mxGetScalar(prhs[3])); - - hist = normalizeHistogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - float mn = std::numeric_limits<float>::lowest(); - float mx = std::numeric_limits<float>::max(); - - if (nrhs>2) - mn = MAX(mn,(float)mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,(float)mxGetScalar(prhs[3])); - - hist = normalizeHistogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - double mn = std::numeric_limits<double>::lowest(); - double mx = std::numeric_limits<double>::max(); - - if (nrhs>2) - mn = MAX(mn,mxGetScalar(prhs[2])); - - if (nrhs>3) - mx = MIN(mx,mxGetScalar(prhs[3])); - - hist = normalizeHistogram(imageIn,imageDims,arraySize,mn,mx,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - return; - } - - const mwSize DIM = arraySize; - plhs[0] = mxCreateNumericArray(1,&DIM,mxDOUBLE_CLASS,mxREAL); - double* histPr = mxGetPr(plhs[0]); - - for (unsigned int i=0; i<arraySize; ++i) - histPr[i] = hist[i]; - - delete[] hist; -} - -std::string MexNormalizedHistogram::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>5) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one outputs!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - return ""; -} - -void MexNormalizedHistogram::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("numBins"); - inArgs.push_back("min"); - inArgs.push_back("max"); -inArgs.push_back("device"); -outArgs.push_back("histogram"); -} - -void MexNormalizedHistogram::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tCreates a histogram array with numBins bins\n"; -//\ msg += "\tIf min/max is not provided, the min/max of the type is used."; -//\ msg += "\tEach bin is normalized over the total number of pixel/voxels.\n"; -//\ msg = "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexOtsuThresholdFilter.cpp b/src/c/Mex/MexOtsuThresholdFilter.cpp deleted file mode 100644 index 4cafea9debe6f59be772442134dcf101b6a203b7..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexOtsuThresholdFilter.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexOtsuThresholdFilter::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double alpha = 1.0; - if (nrhs==2) - alpha = mxGetScalar(prhs[1]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - otsuThresholdFilter(imageIn,imageDims,alpha,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - otsuThresholdFilter(imageIn,imageDims,alpha,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - otsuThresholdFilter(imageIn,imageDims,alpha,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - otsuThresholdFilter(imageIn,imageDims,alpha,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - otsuThresholdFilter(imageIn,imageDims,alpha,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - otsuThresholdFilter(imageIn,imageDims,alpha,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - otsuThresholdFilter(imageIn,imageDims,alpha,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexOtsuThresholdFilter::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<1 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - if (nrhs==2) - if (!mxIsDouble(prhs[1])) - return "Alpha needs to be a single double!"; - - return ""; -} - -void MexOtsuThresholdFilter::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("alpha"); -inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexOtsuThresholdFilter::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tCalculates a two class threshold using Otsu's method.\n"; -//\ msg += "\tEach pixel/voxel >= the threshold is set to the max value of the image space."; -//\ msg += "\tAll other values will be set at the minimum of the image space.\n"; -//\ msg += "\n"; -//\ return msg; -} - diff --git a/src/c/Mex/MexOtsuThresholdValue.cpp b/src/c/Mex/MexOtsuThresholdValue.cpp deleted file mode 100644 index dafa2aeea36fd996822f6f47026b611b49f7c368..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexOtsuThresholdValue.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - - void MexOtsuThresholdValue::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - int device = 0; - - if (nrhs>1) - device = mat_to_c((int)mxGetScalar(prhs[1])); - - double thresh = 0.0; - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - thresh = otsuThresholdValue(imageIn,imageDims,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - thresh = otsuThresholdValue(imageIn,imageDims,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - thresh = otsuThresholdValue(imageIn,imageDims,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - thresh = otsuThresholdValue(imageIn,imageDims,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - thresh = otsuThresholdValue(imageIn,imageDims,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - thresh = otsuThresholdValue(imageIn,imageDims,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - thresh = otsuThresholdValue(imageIn,imageDims,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - plhs[0] = mxCreateDoubleScalar(thresh); - } - - std::string MexOtsuThresholdValue::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const - { - if (nrhs<1 || nrhs>2) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - return ""; - } - - void MexOtsuThresholdValue::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const - { - inArgs.push_back("imageIn"); - -inArgs.push_back("device"); -outArgs.push_back("threshold"); - } - - void MexOtsuThresholdValue::help(std::vector<std::string>& helpLines) const - { -//\ std::string msg = "\tCalculates the optimal two class threshold using Otsu's method.\n"; -//\ msg += "\n"; -//\ return msg; - } diff --git a/src/c/Mex/MexRegionGrowing.cpp b/src/c/Mex/MexRegionGrowing.cpp deleted file mode 100644 index 1398de27a15eaec35999b5debc03f83aaf97593b..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexRegionGrowing.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexRegionGrowing::execute(int nlhs,mxArray* plhs[],int nrhs,const mxArray* prhs[]) const -{ - int device = 0; - bool allowConnection = true; - - if(nrhs>5) - device = mat_to_c((int)mxGetScalar(prhs[5])); - - if(nrhs>4) - allowConnection = mxGetScalar(prhs[4])>0; - - size_t numDims = mxGetNumberOfDimensions(prhs[1]); - const mwSize* DIMS = mxGetDimensions(prhs[1]); - - Vec<size_t> kernDims; - - if(numDims>2) - kernDims.z = (size_t)DIMS[2]; - else - kernDims.z = 1; - - if(numDims>1) - kernDims.y = (size_t)DIMS[1]; - else - kernDims.y = 1; - - if(numDims>0) - kernDims.x = (size_t)DIMS[0]; - else - return; - - double* matKernel; - matKernel = (double*)mxGetData(prhs[1]); - - float* kernel = new float[kernDims.product()]; - for(int i=0; i<kernDims.product(); ++i) - kernel[i] = (float)matKernel[i]; - - const mwSize* MASK_DIMS = mxGetDimensions(prhs[2]); - bool* maskIn = (bool*)mxGetData(prhs[2]); - - plhs[0] = mxCreateLogicalArray(numDims,MASK_DIMS); - bool* maskOut = (bool*)mxGetData(plhs[0]); - size_t numEl = mxGetNumberOfElements(prhs[2]); - double threshold = mxGetScalar(prhs[3]); - - memcpy(maskOut,maskIn,sizeof(bool)*numEl); - - Vec<size_t> imageDims; - if(mxIsUint8(prhs[0])) - { - unsigned char* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - regionGrowing(imageIn,imageDims,kernDims,kernel,maskOut,threshold,allowConnection,device); - } else if(mxIsUint16(prhs[0])) - { - unsigned short* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - regionGrowing(imageIn,imageDims,kernDims,kernel,maskOut,threshold,allowConnection,device); - } else if(mxIsInt16(prhs[0])) - { - short* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - regionGrowing(imageIn,imageDims,kernDims,kernel,maskOut,threshold,allowConnection,device); - } else if(mxIsUint32(prhs[0])) - { - unsigned int* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - regionGrowing(imageIn,imageDims,kernDims,kernel,maskOut,threshold,allowConnection,device); - } else if(mxIsInt32(prhs[0])) - { - int* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - regionGrowing(imageIn,imageDims,kernDims,kernel,maskOut,threshold,allowConnection,device); - } else if(mxIsSingle(prhs[0])) - { - float* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - regionGrowing(imageIn,imageDims,kernDims,kernel,maskOut,threshold,allowConnection,device); - } else if(mxIsDouble(prhs[0])) - { - double* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - regionGrowing(imageIn,imageDims,kernDims,kernel,maskOut,threshold,allowConnection,device); - } else - { - mexErrMsgTxt("Image type not supported!"); - } - - delete[] kernel; -} - -std::string MexRegionGrowing::check(int nlhs,mxArray* plhs[],int nrhs,const mxArray* prhs[]) const -{ - if(nrhs<4 || nrhs>6) - return "Incorrect number of inputs!"; - - if(nlhs!=1) - return "Requires one output!"; - - size_t imgNumDims = mxGetNumberOfDimensions(prhs[0]); - if(imgNumDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t kernDims = mxGetNumberOfDimensions(prhs[1]); - if(kernDims<1 || kernDims>3) - return "Kernel can only be either 1-D, 2-D, or 3-D!"; - - size_t maskDims = mxGetNumberOfDimensions(prhs[2]); - if(maskDims!=imgNumDims) - return "Mask must be the same dimension as the image!"; - - if(!mxIsLogical(prhs[2])) - return "Mask must be of logical type!"; - - return ""; -} - -void MexRegionGrowing::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("kernel"); - inArgs.push_back("mask"); - inArgs.push_back("threshold"); - inArgs.push_back("allowConnections"); - inArgs.push_back("device"); - outArgs.push_back("maskOut"); -} - -void MexRegionGrowing::help(std::vector<std::string>& helpLines) const -{ - helpLines.push_back("This will create a mask that grows by a delta value. If a neighboring voxel is masked and the current voxel intensity is +/- delta from the masked intensity, then the current voxel is added to the mask."); - - helpLines.push_back("\tImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tKernel -- this "); - - helpLines.push_back(""); -//\ std::string msg = "\tThis will return a mask that has grown by the kernal shape for any pixels that are within a threshold of the current mask.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexResize.cpp b/src/c/Mex/MexResize.cpp deleted file mode 100644 index 9b57b9819d7fb730d5161b341fd5f9fc816eb89b..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexResize.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" -#include "Defines.h" - -void MexResize::execute(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - Vec<size_t> imageInDims(0, 0, 0); - setupDims(prhs[0], &imageInDims); - Vec<double> reductionFactors(0.0, 0.0, 0.0); - if(!mxIsEmpty(prhs[1])) - { - double* reductionD = (double*)mxGetData(prhs[1]); - reductionFactors = Vec<double>(reductionD[0], reductionD[1], reductionD[2]); - } - - Vec<size_t> imageOutDims(0, 0, 0); - if(!mxIsEmpty(prhs[2])) - { - double* outDim = (double*)mxGetData(prhs[2]); - imageOutDims = Vec<size_t>(outDim[0], outDim[1], outDim[2]); - - reductionFactors = Vec<double>(imageOutDims)/Vec<double>(imageInDims); - } - - char method[36]; - ReductionMethods mthd = REDUC_MEAN; - mxGetString(prhs[3], method, 255); - if(_strcmpi(method, "mean")==0) - mthd = REDUC_MEAN; - else if(_strcmpi(method, "median")==0) - mthd = REDUC_MEDIAN; - else if(_strcmpi(method, "min")==0) - mthd = REDUC_MIN; - else if(_strcmpi(method, "max")==0) - mthd = REDUC_MAX; - else if(_strcmpi(method, "gaussian")==0) - mthd = REDUC_GAUS; - else - mexErrMsgTxt("Method of resize not supported!"); - - int device = 0; - if(nrhs>4) - device = mat_to_c((int)mxGetScalar(prhs[4])); - - imageOutDims = Vec<size_t>((Vec<double>(imageInDims)*reductionFactors).floor()); - - if(mxIsLogical(prhs[0])) - { - bool* imageIn, *imageOut; - setupInputPointers(prhs[0], &imageInDims, &imageIn); - setupOutputPointers(&(plhs[0]), imageOutDims, &imageOut); - - resize(imageIn, imageInDims, reductionFactors, imageOutDims, mthd, &imageOut, device); - } else if(mxIsUint8(prhs[0])) - { - unsigned char* imageIn, *imageOut; - setupInputPointers(prhs[0], &imageInDims, &imageIn); - setupOutputPointers(&(plhs[0]), imageOutDims, &imageOut); - - resize(imageIn, imageInDims, reductionFactors, imageOutDims, mthd, &imageOut, device); - } else if(mxIsUint16(prhs[0])) - { - unsigned short* imageIn, *imageOut; - setupInputPointers(prhs[0], &imageInDims, &imageIn); - setupOutputPointers(&(plhs[0]), imageOutDims, &imageOut); - - resize(imageIn, imageInDims, reductionFactors, imageOutDims, mthd, &imageOut, device); - } else if(mxIsInt16(prhs[0])) - { - short* imageIn, *imageOut; - setupInputPointers(prhs[0], &imageInDims, &imageIn); - setupOutputPointers(&(plhs[0]), imageOutDims, &imageOut); - - resize(imageIn, imageInDims, reductionFactors, imageOutDims, mthd, &imageOut, device); - } else if(mxIsUint32(prhs[0])) - { - unsigned int* imageIn, *imageOut; - setupInputPointers(prhs[0], &imageInDims, &imageIn); - setupOutputPointers(&(plhs[0]), imageOutDims, &imageOut); - - resize(imageIn, imageInDims, reductionFactors, imageOutDims, mthd, &imageOut, device); - } else if(mxIsInt32(prhs[0])) - { - int* imageIn, *imageOut; - setupInputPointers(prhs[0], &imageInDims, &imageIn); - setupOutputPointers(&(plhs[0]), imageOutDims, &imageOut); - - resize(imageIn, imageInDims, reductionFactors, imageOutDims, mthd, &imageOut, device); - } else if(mxIsSingle(prhs[0])) - { - float* imageIn, *imageOut; - setupInputPointers(prhs[0], &imageInDims, &imageIn); - setupOutputPointers(&(plhs[0]), imageOutDims, &imageOut); - - resize(imageIn, imageInDims, reductionFactors, imageOutDims, mthd, &imageOut, device); - } else if(mxIsDouble(prhs[0])) - { - double* imageIn, *imageOut; - setupInputPointers(prhs[0], &imageInDims, &imageIn); - setupOutputPointers(&(plhs[0]), imageOutDims, &imageOut); - - resize(imageIn, imageInDims, reductionFactors, imageOutDims, mthd, &imageOut, device); - } else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexResize::check(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - if (nrhs<3 || nrhs>5) - return "Incorrect number of inputs!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if(numDims>3||numDims<2) - return "Image can only be either 2D or 3D!"; - - size_t numElFac = mxGetNumberOfElements(prhs[1]); - size_t numElSize = mxGetNumberOfElements(prhs[2]); - - if(numElFac==0&&numElSize==0) - return "Either ResizeFactor of ExplicitSize must be set."; - - if(!mxIsEmpty(prhs[1]) && (numElFac!=3||!mxIsDouble(prhs[1]))) - return "Resize amounts have to be an array of three doubles!"; - - if(!mxIsEmpty(prhs[2]) &&(numElSize!=3||!mxIsDouble(prhs[2]))) - return "ExplicitSize amounts have to be an array of three doubles!"; - - Vec<double> reductionFactors(0.0, 0.0, 0.0); - if(!mxIsEmpty(prhs[1])) - { - double* reductionD = (double*)mxGetData(prhs[1]); - reductionFactors = Vec<double>(reductionD[0], reductionD[1], reductionD[2]); - - if(reductionFactors.maxValue()>1) - return "Enlarging any dimension is currently not implemented!"; - } - - if(!mxIsEmpty(prhs[2])) - { - Vec<size_t> imageOutDims(0, 0, 0); - double* outDim = (double*)mxGetData(prhs[2]); - imageOutDims = Vec<size_t>(outDim[0], outDim[1], outDim[2]); - - Vec<size_t> imageInDims(0, 0, 0); - double* inDim = (double*)mxGetData(prhs[0]); - imageInDims = Vec<size_t>(inDim[0], inDim[1], inDim[2]); - - if (imageInDims>imageOutDims) - return "Enlarging any dimension is currently not implemented!"; - } - - return ""; -} - -void MexResize::usage(std::vector<std::string>& outArgs, std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("resizeFactor"); - inArgs.push_back("explicitSize"); - inArgs.push_back("method"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); -} - -void MexResize::help(std::vector<std::string>& helpLines) const -{ - helpLines.push_back("Resizes image using various methods."); - - helpLines.push_back("\tImageIn -- can be an image up to three dimensions and of type (logical,uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tResizeFactor_rcz -- This represents the output size relative to input (r,c,z). Values less than one but greater than zero will reduce the image."); - helpLines.push_back("\t\tValues greater than one will enlarge the image. If this is an empty array, it will be calculated from the explicit resize."); - helpLines.push_back("\t\t\tIf both resizeFactor and explicitSize are both set, the explicitSize will be used."); - helpLines.push_back("\tExplicitSize_rcz -- This is the size that the output should be (r,c,z). If this is an empty array, then the resize factor is used."); - helpLines.push_back("\t\t\tIf both resizeFactor and explicitSize are both set, the explicitSize will be used."); - helpLines.push_back("\tMethod -- This is the neighborhood operation to apply when resizing (mean, median, min, max, gaussian)."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\tImageOut -- This will be a resize image the same type as the input image."); -} diff --git a/src/c/Mex/MexSegment.cpp b/src/c/Mex/MexSegment.cpp deleted file mode 100644 index bf48399cb4fca2acb382de7c9abd273b0c456be9..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexSegment.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" -#include "CHelpers.h" - -void MexSegment::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>3) - device = mat_to_c((int)mxGetScalar(prhs[3])); - - double alpha = mxGetScalar(prhs[1]); - double* radiusMex = (double*)mxGetData(prhs[2]); - Vec<size_t> radius((size_t)radiusMex[0],(size_t)radiusMex[1],(size_t)radiusMex[2]); - - Vec<size_t> kernDims; - float* kern = createEllipsoidKernel(radius,kernDims); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - segment(imageIn,imageDims,alpha,kernDims,kern,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - segment(imageIn,imageDims,alpha,kernDims,kern,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - segment(imageIn,imageDims,alpha,kernDims,kern,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - segment(imageIn,imageDims,alpha,kernDims,kern,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - segment(imageIn,imageDims,alpha,kernDims,kern,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - segment(imageIn,imageDims,alpha,kernDims,kern,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - segment(imageIn,imageDims,alpha,kernDims,kern,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexSegment::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<3 || nrhs>4) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - if (!mxIsDouble(prhs[1])) - return "Alpha has to be a single double!"; - - size_t numEl = mxGetNumberOfElements(prhs[2]); - if (numEl!=3 || !mxIsDouble(prhs[2])) - return "Median neighborhood has to be an array of three doubles!"; - - return ""; -} - -void MexSegment::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("alpha"); - inArgs.push_back("MorphClosure"); - inArgs.push_back("device"); - outArgs.push_back("imageOut"); -} - -void MexSegment::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tSegmentaion is done by applying an Otsu adaptive threshold (which can be modified by the alpha multiplier).\n"; -//\ msg += "\tA morphological closing is then applied using a ellipsoid neighborhood with the MorphClosure dimensions.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexStdFilter.cpp b/src/c/Mex/MexStdFilter.cpp deleted file mode 100644 index 46c3a056f5b9b8be068885b3b7879e2449c60d09..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexStdFilter.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexStdFilter::execute(int nlhs,mxArray* plhs[],int nrhs,const mxArray* prhs[]) const -{ - int device = 0; - - if(nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double* neighborhoodD = (double*)mxGetData(prhs[1]); - Vec<size_t> neighborhood((size_t)neighborhoodD[1],(size_t)neighborhoodD[0],(size_t)neighborhoodD[2]); - - Vec<size_t> imageDims; - if(mxIsUint8(prhs[0])) - { - unsigned char* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - stdFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } else if(mxIsUint16(prhs[0])) - { - unsigned short* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - stdFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } else if(mxIsInt16(prhs[0])) - { - short* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - stdFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } else if(mxIsUint32(prhs[0])) - { - unsigned int* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - stdFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } else if(mxIsInt32(prhs[0])) - { - int* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - stdFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } else if(mxIsSingle(prhs[0])) - { - float* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - stdFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } else if(mxIsDouble(prhs[0])) - { - double* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - stdFilter(imageIn,imageDims,neighborhood,&imageOut,device); - } else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexStdFilter::check(int nlhs,mxArray* plhs[],int nrhs,const mxArray* prhs[]) const -{ - if(nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if(nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if(numDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl= mxGetNumberOfElements(prhs[1]); - if(numEl!=3 || !mxIsDouble(prhs[1])) - return "Neighborhood has to be an array of three doubles!"; - - return ""; -} - -void MexStdFilter::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - - inArgs.push_back("imageIn"); - inArgs.push_back("Neighborhood"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); -} - -void MexStdFilter::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tNeighborhoodX, NeighborhoodY, and NeighborhoodZ are the directions and area to look for a given pixel."; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexSumArray.cpp b/src/c/Mex/MexSumArray.cpp deleted file mode 100644 index 0789d31c807a0080eeb6ca0756dfc5544bf6b2a9..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexSumArray.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "MexCommand.h" -#include "CWrappers.h" -#include "Vec.h" - -void MexSumArray::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>1) - device = mat_to_c((int)mxGetScalar(prhs[1])); - - double sm; - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - sm = (double)sumArray(imageIn,imageDims.product(),device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - sm = (double)sumArray(imageIn,imageDims.product(),device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - sm = (double)sumArray(imageIn,imageDims.product(),device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - sm = (double)sumArray(imageIn,imageDims.product(),device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - sm = (double)sumArray(imageIn,imageDims.product(),device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - sm = sumArray(imageIn,imageDims.product(),device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - sm = sumArray(imageIn,imageDims.product(),device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - plhs[0] = mxCreateDoubleScalar(sm); -} - -std::string MexSumArray::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<1 || nrhs>2) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one outputs!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - return ""; -} - -void MexSumArray::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - -inArgs.push_back("device"); -outArgs.push_back("sum"); -} - -void MexSumArray::help(std::vector<std::string>& helpLines) const -{ -//\ std::string msg = "\tSums up all the values in the given image.\n"; -//\ msg += "\n"; -//\ return msg; -} diff --git a/src/c/Mex/MexThresholdFilter.cpp b/src/c/Mex/MexThresholdFilter.cpp deleted file mode 100644 index 6a7288fa7aa6087ef2b2e3455b4e4a4e5d121ddb..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexThresholdFilter.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "MexCommand.h" -#include "Vec.h" -#include "CWrappers.h" - -void MexThresholdFilter::execute( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - int device = 0; - - if (nrhs>2) - device = mat_to_c((int)mxGetScalar(prhs[2])); - - double thresh = mxGetScalar(prhs[1]); - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - thresholdFilter(imageIn,imageDims,(unsigned char)thresh,&imageOut,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - thresholdFilter(imageIn,imageDims,(unsigned short)thresh,&imageOut,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - thresholdFilter(imageIn,imageDims,(short)thresh,&imageOut,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - thresholdFilter(imageIn,imageDims,(unsigned int)thresh,&imageOut,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - thresholdFilter(imageIn,imageDims,(int)thresh,&imageOut,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - thresholdFilter(imageIn,imageDims,(float)thresh,&imageOut,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn,* imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - thresholdFilter(imageIn,imageDims,thresh,&imageOut,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexThresholdFilter::check( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) const -{ - if (nrhs<2 || nrhs>3) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - if (!mxIsDouble(prhs[1])) - return "Threshold needs to be a single double!"; - - return ""; -} - -void MexThresholdFilter::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("threshold"); - inArgs.push_back("device"); -outArgs.push_back("imageOut"); -} - -void MexThresholdFilter::help(std::vector<std::string>& helpLines) const -{ -// std::string msg = "\tMaps any value >= thresh to the max value of the image space."; -// msg += "\tAll other values will be set at the minimum of the image space.\n"; -// msg += "\n"; -// return msg; -} diff --git a/src/c/Mex/MexTileImage.cpp b/src/c/Mex/MexTileImage.cpp deleted file mode 100644 index 6eb18c14b51dae5994ae46a34e552f448bc50175..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexTileImage.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "MexCommand.h" -#include "CWrappers.h" -#include "Vec.h" - -void MexTileImage::execute(int nlhs,mxArray* plhs[],int nrhs,const mxArray* prhs[]) const -{ - int device = 0; - - if(nrhs>3) - device = mat_to_c((int)mxGetScalar(prhs[3])); - - double* startsMat = (double*)mxGetData(prhs[1]); - Vec<size_t> starts(size_t(mat_to_c(startsMat[1])),size_t(mat_to_c(startsMat[0])),size_t(mat_to_c(startsMat[2]))); - - double* sizesMat = (double*)mxGetData(prhs[2]); - Vec<size_t> sizes((size_t)sizesMat[1],(size_t)sizesMat[0],(size_t)sizesMat[2]); - - Vec<size_t> imageDims; - if(mxIsUint8(prhs[0])) - { - unsigned char* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - tileImage(imageIn,imageDims,starts,sizes,&imageOut,device); - } else if(mxIsUint16(prhs[0])) - { - unsigned short* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - tileImage(imageIn,imageDims,starts,sizes,&imageOut,device); - } else if(mxIsInt16(prhs[0])) - { - short* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - tileImage(imageIn,imageDims,starts,sizes,&imageOut,device); - } else if(mxIsUint32(prhs[0])) - { - unsigned int* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - tileImage(imageIn,imageDims,starts,sizes,&imageOut,device); - } else if(mxIsInt32(prhs[0])) - { - int* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - tileImage(imageIn,imageDims,starts,sizes,&imageOut,device); - } else if(mxIsSingle(prhs[0])) - { - float* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - tileImage(imageIn,imageDims,starts,sizes,&imageOut,device); - } else if(mxIsDouble(prhs[0])) - { - double* imageIn,*imageOut; - setupImagePointers(prhs[0],&imageIn,&imageDims,&plhs[0],&imageOut); - - tileImage(imageIn,imageDims,starts,sizes,&imageOut,device); - } else - { - mexErrMsgTxt("Image type not supported!"); - } -} - -std::string MexTileImage::check(int nlhs,mxArray* plhs[],int nrhs,const mxArray* prhs[]) const -{ - if(nrhs<3 || nrhs>4) - return "Incorrect number of inputs!"; - - if(nlhs!=1) - return "Requires one output!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if(numDims>3) - return "Image can have a maximum of three dimensions!"; - - size_t numEl = mxGetNumberOfElements(prhs[1]); - if(numEl!=3 || !mxIsDouble(prhs[1])) - return "Starts must be an array of three doubles!"; - - numEl = mxGetNumberOfElements(prhs[2]); - if(numEl!=3 || !mxIsDouble(prhs[2])) - return "Sizes must be an array of three doubles!"; - - return ""; -} - -void MexTileImage::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("roiStart"); - inArgs.push_back("roiSize"); - inArgs.push_back("device"); - - outArgs.push_back("imageOut"); -} - -void MexTileImage::help(std::vector<std::string>& helpLines) const -{ - helpLines.push_back("This will output an image that only consists of the region of interest indicated."); - - helpLines.push_back("\tImageIn -- can be an image up to three dimensions and of type (uint8,int8,uint16,int16,uint32,int32,single,double)."); - helpLines.push_back("\tRoiStart -- this is the location of the first voxel in the region of interest (starting from the origin). Must be the same dimension as imageIn."); - helpLines.push_back("\tRoiSize -- this is how many voxels to include starting from roiStart. Must be the same dimension as imageIn."); - helpLines.push_back("\tDevice -- this is an optional parameter that indicates which Cuda capable device to use."); - - helpLines.push_back("\tImageOut -- this will be an image that only contains the region of interest indicated."); -} diff --git a/src/c/Mex/MexVariance.cpp b/src/c/Mex/MexVariance.cpp deleted file mode 100644 index 6e6e117c883e0038bbf8e3a25111ac62247dd554..0000000000000000000000000000000000000000 --- a/src/c/Mex/MexVariance.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "MexCommand.h" -#include "CWrappers.h" -#include "Vec.h" - -void MexVariance::execute(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - int device = 0; - - if (nrhs>1) - device = mat_to_c((int)mxGetScalar(prhs[1])); - - double var; - - Vec<size_t> imageDims; - if (mxIsUint8(prhs[0])) - { - unsigned char* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - var = variance(imageIn,imageDims,device); - } - else if (mxIsUint16(prhs[0])) - { - unsigned short* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - var = variance(imageIn,imageDims,device); - } - else if (mxIsInt16(prhs[0])) - { - short* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - var = variance(imageIn,imageDims,device); - } - else if (mxIsUint32(prhs[0])) - { - unsigned int* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - var = variance(imageIn,imageDims,device); - } - else if (mxIsInt32(prhs[0])) - { - int* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - var = variance(imageIn,imageDims,device); - } - else if (mxIsSingle(prhs[0])) - { - float* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - var = variance(imageIn,imageDims,device); - } - else if (mxIsDouble(prhs[0])) - { - double* imageIn; - setupImagePointers(prhs[0],&imageIn,&imageDims); - - var = variance(imageIn,imageDims,device); - } - else - { - mexErrMsgTxt("Image type not supported!"); - } - - plhs[0] = mxCreateDoubleScalar(var); -} - -std::string MexVariance::check(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const -{ - if (nrhs<1 || nrhs>2) - return "Incorrect number of inputs!"; - - if (nlhs!=1) - return "Requires one outputs!"; - - size_t numDims = mxGetNumberOfDimensions(prhs[0]); - if (numDims>3) - return "Image can have a maximum of three dimensions!"; - - return ""; -} - -void MexVariance::usage(std::vector<std::string>& outArgs,std::vector<std::string>& inArgs) const -{ - inArgs.push_back("imageIn"); - inArgs.push_back("device"); - - outArgs.push_back("variance"); -} - -void MexVariance::help(std::vector<std::string>& helpLines) const -{ - helpLines.push_back("This will return the variance of an image."); -} \ No newline at end of file