Commit 8c75db89 authored by Eric Wait's avatar Eric Wait

Bare bones Cuda compile. Removed all of the Mex/Matlab functions to be rewritten

parent c3a355f0
% 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
% 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
% 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
% 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
% EntropyFilter - imageOut = EntropyFilter(imageIn,kernel,device)
function imageOut = EntropyFilter(imageIn,kernel,device)
[imageOut] = ImProc.Cuda.Mex('EntropyFilter',imageIn,kernel,device);
end
% 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
% 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
% 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
% LinearUnmixing - imageOut = LinearUnmixing(mixedImages,unmixMatrix,device)
function imageOut = LinearUnmixing(mixedImages,unmixMatrix,device)
[imageOut] = ImProc.Cuda.Mex('LinearUnmixing',mixedImages,unmixMatrix,device);
end
% 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
% MarkovRandomFieldDenoiser - imageOut = MarkovRandomFieldDenoiser(imageIn,maxIterations,device)
function imageOut = MarkovRandomFieldDenoiser(imageIn,maxIterations,device)
[imageOut] = ImProc.Cuda.Mex('MarkovRandomFieldDenoiser',imageIn,maxIterations,device);
end
% MaxFilterEllipsoid - imageOut = MaxFilterEllipsoid(imageIn,radius,device)
function imageOut = MaxFilterEllipsoid(imageIn,radius,device)
[imageOut] = ImProc.Cuda.Mex('MaxFilterEllipsoid',imageIn,radius,device);
end
% MaxFilterKernel - imageOut = MaxFilterKernel(imageIn,kernel,device)
function imageOut = MaxFilterKernel(imageIn,kernel,device)
[imageOut] = ImProc.Cuda.Mex('MaxFilterKernel',imageIn,kernel,device);
end
% MaxFilterNeighborhood - imageOut = MaxFilterNeighborhood(imageIn,Neighborhood,device)
function imageOut = MaxFilterNeighborhood(imageIn,Neighborhood,device)
[imageOut] = ImProc.Cuda.Mex('MaxFilterNeighborhood',imageIn,Neighborhood,device);
end
% MeanFilter - imageOut = MeanFilter(imageIn,Neighborhood,device)
function imageOut = MeanFilter(imageIn,Neighborhood,device)
[imageOut] = ImProc.Cuda.Mex('MeanFilter',imageIn,Neighborhood,device);
end
% MedianFilter - imageOut = MedianFilter(imageIn,Neighborhood,device)
function imageOut = MedianFilter(imageIn,Neighborhood,device)
[imageOut] = ImProc.Cuda.Mex('MedianFilter',imageIn,Neighborhood,device);
end
% MinFilterEllipsoid - imageOut = MinFilterEllipsoid(imageIn,radius,device)
function imageOut = MinFilterEllipsoid(imageIn,radius,device)
[imageOut] = ImProc.Cuda.Mex('MinFilterEllipsoid',imageIn,radius,device);
end
% MinFilterKernel - imageOut = MinFilterKernel(imageIn,kernel,device)
function imageOut = MinFilterKernel(imageIn,kernel,device)
[imageOut] = ImProc.Cuda.Mex('MinFilterKernel',imageIn,kernel,device);
end
% MinFilterNeighborhood - imageOut = MinFilterNeighborhood(imageIn,Neighborhood,device)
function imageOut = MinFilterNeighborhood(imageIn,Neighborhood,device)
[imageOut] = ImProc.Cuda.Mex('MinFilterNeighborhood',imageIn,Neighborhood,device);
end
% MinMax - [min,max] = MinMax(imageIn,device)
function [min,max] = MinMax(imageIn,device)
[min,max] = ImProc.Cuda.Mex('MinMax',imageIn,device);
end
% MorphologicalClosure - imageOut = MorphologicalClosure(imageIn,kernel,device)
function imageOut = MorphologicalClosure(imageIn,kernel,device)
[imageOut] = ImProc.Cuda.Mex('MorphologicalClosure',imageIn,kernel,device);
end
% MorphologicalOpening - imageOut = MorphologicalOpening(imageIn,kernel,device)
function imageOut = MorphologicalOpening(imageIn,kernel,device)
[imageOut] = ImProc.Cuda.Mex('MorphologicalOpening',imageIn,kernel,device);
end
% MultiplyImage - imageOut = MultiplyImage(imageIn,multiplier,device)
function imageOut = MultiplyImage(imageIn,multiplier,device)
[imageOut] = ImProc.Cuda.Mex('MultiplyImage',imageIn,multiplier,device);
end
% MultiplyTwoImages - imageOut = MultiplyTwoImages(imageIn1,imageIn2,factor,device)
function imageOut = MultiplyTwoImages(imageIn1,imageIn2,factor,device)
[imageOut] = ImProc.Cuda.Mex('MultiplyTwoImages',imageIn1,imageIn2,factor,device);
end
% NeighborhoodSum - imageOut = NeighborhoodSum(imageIn,Neighborhood,device)
function imageOut = NeighborhoodSum(imageIn,Neighborhood,device)
[imageOut] = ImProc.Cuda.Mex('NeighborhoodSum',imageIn,Neighborhood,device);
end
% NormalizedCovariance - normalizedCovariance = NormalizedCovariance(imageIn1,imageIn2,device)
function normalizedCovariance = NormalizedCovariance(imageIn1,imageIn2,device)
[normalizedCovariance] = ImProc.Cuda.Mex('NormalizedCovariance',imageIn1,imageIn2,device);
end
% 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
% OtsuThresholdFilter - imageOut = OtsuThresholdFilter(imageIn,alpha,device)
function imageOut = OtsuThresholdFilter(imageIn,alpha,device)
[imageOut] = ImProc.Cuda.Mex('OtsuThresholdFilter',imageIn,alpha,device);
end
% OtsuThresholdValue - threshold = OtsuThresholdValue(imageIn,device)
function threshold = OtsuThresholdValue(imageIn,device)
[threshold] = ImProc.Cuda.Mex('OtsuThresholdValue',imageIn,device);
end
% 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
% 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
% Segment - imageOut = Segment(imageIn,alpha,MorphClosure,device)
function imageOut = Segment(imageIn,alpha,MorphClosure,device)
[imageOut] = ImProc.Cuda.Mex('Segment',imageIn,alpha,MorphClosure,device);
end
% StdFilter - imageOut = StdFilter(imageIn,Neighborhood,device)
function imageOut = StdFilter(imageIn,Neighborhood,device)
[imageOut] = ImProc.Cuda.Mex('StdFilter',imageIn,Neighborhood,device);
end
% SumArray - sum = SumArray(imageIn,device)
function sum = SumArray(imageIn,device)
[sum] = ImProc.Cuda.Mex('SumArray',imageIn,device);
end
% ThresholdFilter - imageOut = ThresholdFilter(imageIn,threshold,device)
function imageOut = ThresholdFilter(imageIn,threshold,device)
[imageOut] = ImProc.Cuda.Mex('ThresholdFilter',imageIn,threshold,device);
end
% 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
% 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
% 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
% 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
% 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
% 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
% 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
% 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
% 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
% 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
% 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
% LoG - Smooths image using a Gaussian kernel.