13 #ifndef ML_SIMILAR_VECTOR_DIRECTIONS_CLUSTER_ALGORITHM_H
14 #define ML_SIMILAR_VECTOR_DIRECTIONS_CLUSTER_ALGORITHM_H
45 const MLDataType inputDataType = _parameters.contentImage->getDataType();
46 const bool isFloatVector = isFloatVectorType(inputDataType);
48 const size_t numVectorComponents = getNumVectorComponents(inputDataType);
55 _numVectorComponents =
static_cast<int>(numVectorComponents);
56 _isFloatVector = isFloatVector;
81 const float* inFloat1Ptr =
reinterpret_cast<const float*
>(vec1Ptr);
82 const float* inFloat2Ptr =
reinterpret_cast<const float*
>(vec2Ptr);
83 for (
size_t i = 0u; i < static_cast<std::size_t>(_numVectorComponents); ++i)
85 result += inFloat1Ptr[i] * inFloat2Ptr[i];
90 const double* inDouble1Ptr =
reinterpret_cast<const double*
>(vec1Ptr);
91 const double* inDouble2Ptr =
reinterpret_cast<const double*
>(vec2Ptr);
92 for (
size_t i = 0u; i < static_cast<std::size_t>(_numVectorComponents); ++i)
94 result += inDouble1Ptr[i] * inDouble2Ptr[i];
105 double dotProduct = calcDotProduct(currentValue, neighborValue);
106 return std::abs(dotProduct) > _parameters.similarityToleranceVectors;
146 static_cast<size_t>(0);
149 int _numVectorComponents;
Type specific implementations of the interface class for clustering algorithms.
Structure computes and holds all cluster information. For internal use.
Implementation of a clustering algorithm for vector data types.
ML_FORCE_INLINE bool isInTolerance(SimilarVectorDirectionsClusterVoxelType neighborValue, SimilarVectorDirectionsClusterVoxelType currentValue)
Tolerance calculation for vector images.
static ML_FORCE_INLINE SimilarVectorDirectionsClusterVoxelType getVoxel(void *position)
Get the typed voxel value for current position.
SimilarVectorDirectionsClusterAlgorithm(const ComputeClusterParameters ¶meters, Clusters *clusters)
Constructor.
ClusterAlgorithm< const void *, SimilarVectorDirectionsClusterAlgorithm >::ClusterVoxelType SimilarVectorDirectionsClusterVoxelType
Voxel type to be used for the VectorClusterAlgorithm.
static ML_FORCE_INLINE const void * convertBackgroundValue(MLdouble)
ML_FORCE_INLINE double calcDotProduct(SimilarVectorDirectionsClusterVoxelType vec1Ptr, SimilarVectorDirectionsClusterVoxelType vec2Ptr)
Calculates the dot product of two n-dimensional vectors.
static ML_FORCE_INLINE MLdouble getVoxelAsDouble(void *)
MLErrorCode runClustering()
MLint32 MLDataType
MLDataType.
MLEXPORT MLDataType MLDataTypeFromName(const char *const name)
Returns the ID of the data type with name name.
#define ML_BAD_DATA_TYPE
A wrong or unexpected data type has been passed to an algorithm, which often is a programming error.
MLint32 MLErrorCode
Type of an ML Error code.
#define ML_RESULT_OK
No error. Everything seems to be okay.
#define ML_FORCE_INLINE
Forcing the use of 'inline' for methods.
Structure to hold parameters for cluster computation.