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

First binary build

parent 6c34d960
No related branches found
Tags Release-0.0.3a
No related merge requests found
File added
File added
No preview for this file type
#pragma once
#include "Vec.h"
#include <memory.h>
#include <complex>
#ifdef IMAGE_PROCESSOR_DLL
#ifdef IMAGE_PROCESSOR_INTERNAL
#define IMAGE_PROCESSOR_API __declspec(dllexport)
#else
#define IMAGE_PROCESSOR_API __declspec(dllimport)
#endif // IMAGE_PROCESSOR_INTERNAL
#else
#define IMAGE_PROCESSOR_API
#endif // IMAGE_PROCESSOR_DLL
IMAGE_PROCESSOR_API float* createEllipsoidKernel(Vec<size_t> radii, Vec<size_t>& kernelDims);
IMAGE_PROCESSOR_API int calcOtsuThreshold(const double* normHistogram, int numBins);
This diff is collapsed.
#pragma once
#define NUM_BINS (256)
#define MAX_KERNEL_DIM (25)
#define SQR(x) ((x)*(x))
#define MAX(x,y) ((x>y)?(x):(y))
#define MIN(x,y) ((x<y)?(x):(y))
#define mat_to_c(x) (x-1)
#define c_to_mat(x) (x+1)
//Percent of memory that can be used on the device
const double MAX_MEM_AVAIL = 0.95;
enum ReductionMethods
{
REDUC_MEAN, REDUC_MEDIAN, REDUC_MIN, REDUC_MAX
};
\ No newline at end of file
#ifndef HOST_VEC_ONCE
#define HOST_VEC_ONCE
#define DEVICE_PREFIX
#define INCLUDE_VEC
#define VEC_THIS_CLASS Vec
#define VEC_EXTERN_CLASS DeviceVec
#elif defined(DEVICE_VEC) && !defined(DEVICE_VEC_ONCE)
#define DEVICE_VEC_ONCE
#define DEVICE_PREFIX __device__
#define INCLUDE_VEC
#define VEC_THIS_CLASS DeviceVec
#define VEC_EXTERN_CLASS Vec
#endif
#ifdef INCLUDE_VEC
#include "Defines.h"
template<typename T> class VEC_EXTERN_CLASS;
template<typename T>
class VEC_THIS_CLASS
{
public:
T x;
T y;
T z;
DEVICE_PREFIX VEC_THIS_CLASS(){x=0; y=0; z=0;};
template<typename U>
DEVICE_PREFIX VEC_THIS_CLASS(VEC_THIS_CLASS<U> other)
{
this->x = static_cast<T>(other.x);
this->y = static_cast<T>(other.y);
this->z = static_cast<T>(other.z);
}
DEVICE_PREFIX VEC_THIS_CLASS(T x, T y, T z)
{
this->x = x;
this->y = y;
this->z = z;
}
// Negates each element
DEVICE_PREFIX VEC_THIS_CLASS<T> operator- () const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = -x;
outVec.y = -y;
outVec.z = -z;
return outVec;
}
// Adds each element by adder
template<typename d>
DEVICE_PREFIX VEC_THIS_CLASS<T> operator+ (d adder) const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = (T)(x+adder);
outVec.y = (T)(y+adder);
outVec.z = (T)(z+adder);
return outVec;
}
// Subtracts each element by subtractor
template<typename d>
DEVICE_PREFIX VEC_THIS_CLASS<T> operator- (d subtractor) const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = (T)(x-subtractor);
outVec.y = (T)(y-subtractor);
outVec.z = (T)(z-subtractor);
return outVec;
}
// Divides each element by divisor
template<typename d>
DEVICE_PREFIX VEC_THIS_CLASS<T> operator/ (d divisor) const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = (T)(x/divisor);
outVec.y = (T)(y/divisor);
outVec.z = (T)(z/divisor);
return outVec;
}
// Multiplies each element by mult
template<typename d>
DEVICE_PREFIX VEC_THIS_CLASS<T> operator* (d mult) const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = (T)(x*mult);
outVec.y = (T)(y*mult);
outVec.z = (T)(z*mult);
return outVec;
}
// Raises each element to the pwr
template<typename d>
DEVICE_PREFIX VEC_THIS_CLASS<T> pwr (d pw) const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = (T)(pow((double)x,pw));
outVec.y = (T)(pow((double)y,pw));
outVec.z = (T)(pow((double)z,pw));
return outVec;
}
// Returns the product of x*y*z
DEVICE_PREFIX T product() const
{
return x*y*z;
}
// Returns the sum of x+y+z
DEVICE_PREFIX T sum() const
{
return x+y+z;
}
// Returns the max value of x,y,z
DEVICE_PREFIX T maxValue() const
{
return (x>y) ? ((x>z)?(x):(z)) : ((y>z)?(y):(z));
}
// Returns the min value of x,y,z
DEVICE_PREFIX T minValue() const
{
return (x<y) ? ((x<z)?(x):(z)) : ((y<z)?(y):(z));
}
DEVICE_PREFIX static VEC_THIS_CLASS<T> min(VEC_THIS_CLASS<T> a, VEC_THIS_CLASS<T> b)
{
VEC_THIS_CLASS<T> outVec;
outVec.x = MIN(a.x, b.x);
outVec.y = MIN(a.y, b.y);
outVec.z = MIN(a.z, b.z);
return outVec;
}
DEVICE_PREFIX static VEC_THIS_CLASS<T> max(VEC_THIS_CLASS<T> a, VEC_THIS_CLASS<T> b)
{
VEC_THIS_CLASS<T> outVec;
outVec.x = MAX(a.x, b.x);
outVec.y = MAX(a.y, b.y);
outVec.z = MAX(a.z, b.z);
return outVec;
}
DEVICE_PREFIX VEC_THIS_CLASS<T> saturate(VEC_THIS_CLASS<T> maxVal)
{
VEC_THIS_CLASS<T> outVec;
outVec.x = (x<maxVal.x) ? (x) : (maxVal.x);
outVec.y = (y<maxVal.y) ? (y) : (maxVal.y);
outVec.z = (z<maxVal.z) ? (z) : (maxVal.z);
return outVec;
}
DEVICE_PREFIX VEC_THIS_CLASS<T> clamp(VEC_THIS_CLASS<T> minVal, VEC_THIS_CLASS<T> maxVal)
{
VEC_THIS_CLASS<T> outVec;
outVec.x = (x<maxVal.x) ? ((x>minVal.x) ? (x) : (minVal.x)) : (maxVal.x);
outVec.y = (y<maxVal.y) ? ((x>minVal.y) ? (y) : (minVal.y)) : (maxVal.y);
outVec.z = (z<maxVal.z) ? ((x>minVal.z) ? (z) : (minVal.z)) : (maxVal.z);
return outVec;
}
#define EXTERN_TYPE VEC_THIS_CLASS
#include "VecFuncs.h"
#undef EXTERN_TYPE
#define EXTERN_TYPE VEC_EXTERN_CLASS
#include "VecFuncs.h"
#undef EXTERN_TYPE
};
#undef INCLUDE_VEC
#undef VEC_THIS_CLASS
#undef VEC_EXTERN_CLASS
#undef DEVICE_PREFIX
#endif
\ No newline at end of file
#ifdef EXTERN_TYPE
DEVICE_PREFIX VEC_THIS_CLASS(const EXTERN_TYPE<T>& other)
{
this->x = other.x;
this->y = other.y;
this->z = other.z;
}
DEVICE_PREFIX VEC_THIS_CLASS& operator= (const EXTERN_TYPE<T>& other)
{
this->x = other.x;
this->y = other.y;
this->z = other.z;
return *this;
}
DEVICE_PREFIX VEC_THIS_CLASS<T> operator+ (const EXTERN_TYPE<T>& other) const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = x + other.x;
outVec.y = y + other.y;
outVec.z = z + other.z;
return outVec;
}
DEVICE_PREFIX VEC_THIS_CLASS<T> operator- (const EXTERN_TYPE<T>& other) const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = x - other.x;
outVec.y = y - other.y;
outVec.z = z - other.z;
return outVec;
}
DEVICE_PREFIX VEC_THIS_CLASS<T> operator/ (const EXTERN_TYPE<T>& other) const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = x / other.x;
outVec.y = y / other.y;
outVec.z = z / other.z;
return outVec;
}
DEVICE_PREFIX VEC_THIS_CLASS<T> operator* (const EXTERN_TYPE<T>& other) const
{
VEC_THIS_CLASS<T> outVec;
outVec.x = x * other.x;
outVec.y = y * other.y;
outVec.z = z * other.z;
return outVec;
}
// Adds each element by other
template<typename d>
DEVICE_PREFIX VEC_THIS_CLASS<T>& operator+= (const EXTERN_TYPE<T>& other) const
{
x += other.x;
y += other.y;
z += other.z;
return this;
}
// Subtracts each element by other
template<typename d>
DEVICE_PREFIX VEC_THIS_CLASS<T>& operator-= (const EXTERN_TYPE<T>& other) const
{
x -= other.x;
y -= other.y;
z -= other.z;
return this;
}
// Are all the values less then the passed in values
DEVICE_PREFIX bool operator< (const EXTERN_TYPE<T>& inVec)
{
return x<inVec.x && y<inVec.y && z<inVec.z;
}
DEVICE_PREFIX bool operator<= (const EXTERN_TYPE<T>& inVec)
{
return x<=inVec.x && y<=inVec.y && z<=inVec.z;
}
// Are all the values greater then the passed in values
DEVICE_PREFIX bool operator> (const EXTERN_TYPE<T>& inVec)
{
return x>inVec.x && y>inVec.y && z>inVec.z;
}
DEVICE_PREFIX bool operator>= (const EXTERN_TYPE<T>& inVec)
{
return x>=inVec.x && y>=inVec.y && z>=inVec.z;
}
DEVICE_PREFIX bool operator== (const EXTERN_TYPE<T>& inVec)
{
return x==inVec.x && y==inVec.y && z==inVec.z;
}
DEVICE_PREFIX bool operator!= (const EXTERN_TYPE<T>& inVec)
{
return x!=inVec.x || y!=inVec.y || z!=inVec.z;
}
// Returns the linear memory map if this is the dimensions and the passed in Vec is the coordinate
DEVICE_PREFIX size_t linearAddressAt(const EXTERN_TYPE<T>& coordinate, bool columnMajor=false) const
{
if (columnMajor)
return coordinate.y + coordinate.x*y + coordinate.z*x*y;
return coordinate.x + coordinate.y*x + coordinate.z*y*x;
}
DEVICE_PREFIX double EuclideanDistanceTo(const EXTERN_TYPE<T>& other)
{
return sqrt((double)(SQR(x-other.x) + SQR(y-other.y) + SQR(z-other.z)));
}
#endif
\ No newline at end of file
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment