MeVisLab Toolbox Reference
mlReleaseToolsMisc.h
Go to the documentation of this file.
1// Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2// **InsertLicense** code
3//----------------------------------------------------------------------------------
5
10//----------------------------------------------------------------------------------
11#pragma once
12
13// Local includes
15
16// For StringVector.
17#include "mlDirectoryMatching.h"
18
19// ML includes
20#include <mlModuleIncludes.h>
21
22ML_START_NAMESPACE
23
24//----------------------------------------------------------------------------------
26//----------------------------------------------------------------------------------
28
30MLRELEASE_TOOLS_EXPORT extern const std::string LineSeparator;
31
38 const std::string &sep = LineSeparator);
39
58 const ReleaseToolsIO::StringVector &regExpressionsVec,
59 std::vector<size_t> *matchedRegExIdxVec=nullptr);
60
64 const std::string &regEx);
65
68MLRELEASE_TOOLS_EXPORT std::string filterLinesWithRegEx(const std::string &str,
69 const std::string &regEx,
70 const std::string &sep=LineSeparator);
71
107 const bool useRegularExpression,
108 const std::string &firstExpression,
109 const std::string &lineEnd,
110 const MLint index,
111 std::string *errorInfos=nullptr);
112
140 const std::vector<SubImage> &frameSubImgs,
141 MLint zTranslate = 0,
142 MLuint8 value = 1,
143 bool orValue = false);
144
148MLRELEASE_TOOLS_EXPORT bool isEquidistant(const std::vector<double> &dblVec, double eps=10e-5);
149
161
164MLRELEASE_TOOLS_EXPORT int getMonotonicProperties(const std::vector<double> &dblVec, double eps=10e-5);
165
178 const SubImage &subImg2,
179 double &avrOfSumOfSquaredDiffs);
180
181
185template <typename DT1, typename DT2>
187 TSubImage<DT2> &img2,
188 SubImageBox box)
189 {
190 double avrOfSumOfSquaredDifferences = -1.;
191 box = box.intersect(img1.getBox().intersect(img2.getBox()));
192 if (!box.isEmpty()){
193 avrOfSumOfSquaredDifferences = 0.;
194 ImageVector p;
195 for (p.u = box.v1.u; p.u <= box.v2.u; ++p.u){
196 for (p.t = box.v1.t; p.t <= box.v2.t; ++p.t){
197 for (p.c = box.v1.c; p.c <= box.v2.c; ++p.c){
198 for (p.z = box.v1.z; p.z <= box.v2.z; ++p.z){
199 for (p.y = box.v1.y; p.y <= box.v2.y; ++p.y){
200 // Get pointers to row starts.
201 p.x = box.v1.x;
202 const DT1 *v1 = img1.getImagePointer(p);
203 const DT2 *v2 = img2.getImagePointer(p);
204 for (; p.x <= box.v2.x; ++p.x, ++v1, ++v2){
205 // Determine difference between both voxels and sum up squares.
206 const double diff = static_cast<double>(*v1) - static_cast<double>(*v2);
207 avrOfSumOfSquaredDifferences += diff*diff;
208 }
209 }
210 }
211 }
212 }
213 }
214 // Calculate the average of all of sum of squared differences.
215 avrOfSumOfSquaredDifferences /= static_cast<double>(box.getNumVoxels());
216 }
217 return avrOfSumOfSquaredDifferences;
218 }
219
222MLRELEASE_TOOLS_EXPORT std::string toBase64(const std::string &inString);
223
226MLRELEASE_TOOLS_EXPORT std::string fromBase64(const std::string &inString);
227
235MLRELEASE_TOOLS_EXPORT std::string createHashFromBytes(const unsigned char *data, size_t numBytes, const std::string &hashAlgorithm="SHA1");
236
237};
238
239ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLRELEASE_TOOLS_EXPORT
DLL export macro definition.
const SubImageBox & getBox() const
Returns the box describing the origin/extent of the subimage.
Definition mlSubImage.h:230
static TSubImageBox< intT > intersect(const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
intT getNumVoxels() const
bool isEmpty() const
const DATATYPE * getImagePointer(const ImageVector &position) const
ComponentType c
Color component of the vector.
ComponentType t
Time component of the vector.
ComponentType u
Unit/Modality/User component of the vector.
ComponentType z
Z component of the vector.
ComponentType x
X component of the vector.
ComponentType y
Y component of the vector.
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:715
Tool function(s) to determine translation information from one directory to another.
unsigned char MLuint8
Definition mlTypeDefs.h:108
MLint64 MLint
Definition mlTypeDefs.h:489
std::vector< std::string > StringVector
Define often used string vector types.
A collection of miscellaneous tool functions.
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector split(const std::string &value, const std::string &sep=LineSeparator)
MLRELEASE_TOOLS_EXPORT std::string toBase64(const std::string &inString)
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector filterWithRegExVector(const ReleaseToolsIO::StringVector &strVec, const ReleaseToolsIO::StringVector &regExpressionsVec, std::vector< size_t > *matchedRegExIdxVec=nullptr)
MLRELEASE_TOOLS_EXPORT const std::string LineSeparator
The default line separator used for line endings.
MLRELEASE_TOOLS_EXPORT bool isEquidistant(const std::vector< double > &dblVec, double eps=10e-5)
MonotonicTypes
An enumerator describing whether elements of a vector have a monotonic order.
@ StrictlyMonotonicIncreasing
v[0] < v[1] < ... < v[N-1], N = v.size(), N > 1
@ MonotonicDecreasing
v[0] >= v[1] >= ... >= v[N-1], N = v.size(), N > 1
@ StrictlyMonotonicDecreasing
v[0] > v[1] > ... > v[N-1], N = v.size(), N > 1
@ Irregular
Nothing else: not empty, not singular, not uniform, and not monotonic.
@ Uniform
All elements are within an epsilon sized interval.
@ MonotonicIncreasing
v[0] <= v[1] <= ... <= v[N-1], N = v.size(), N > 1
MLRELEASE_TOOLS_EXPORT std::string filterLinesWithRegEx(const std::string &str, const std::string &regEx, const std::string &sep=LineSeparator)
MLRELEASE_TOOLS_EXPORT int getMonotonicProperties(const std::vector< double > &dblVec, double eps=10e-5)
MLRELEASE_TOOLS_EXPORT std::string createHashFromBytes(const unsigned char *data, size_t numBytes, const std::string &hashAlgorithm="SHA1")
MLRELEASE_TOOLS_EXPORT MLErrorCode calculateAverageOfSumOfSquaredDifferences(const SubImage &subImg1, const SubImage &subImg2, double &avrOfSumOfSquaredDiffs)
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector filterLines(const ReleaseToolsIO::StringVector &inLines, const bool useRegularExpression, const std::string &firstExpression, const std::string &lineEnd, const MLint index, std::string *errorInfos=nullptr)
MLRELEASE_TOOLS_EXPORT std::string fromBase64(const std::string &inString)
MLRELEASE_TOOLS_EXPORT MLErrorCode copyBitSubImagesToUInt8SubImage(SubImage &outSubImage, const std::vector< SubImage > &frameSubImgs, MLint zTranslate=0, MLuint8 value=1, bool orValue=false)
TSubImageBox< MLint > SubImageBox
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...
TImageVector< MLint > ImageVector
Defines the standard ImageVector type that is used by the ML for indexing and coordinates.