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
23
24//----------------------------------------------------------------------------------
26//----------------------------------------------------------------------------------
27namespace ReleaseToolsMisc {
28
30MLRELEASE_TOOLS_EXPORT extern const std::string LineSeparator;
31
38 const std::string &sep = LineSeparator);
39
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>
188 SubImageBox box)
189 {
190 double avrOfSumOfSquaredDifferences = -1.;
191 box = box.intersect(img1.getBox().intersect(img2.getBox()));
192 if (!box.isEmpty()){
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);
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 }
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
Project global and OS specific declarations.
#define MLRELEASE_TOOLS_EXPORT
DLL export macro definition.
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
Definition mlSubImage.h:75
VectorType v1
Corner v1 of the subimage region (included in region).
static TSubImageBox< intT > intersect(const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
Returns the overlapping region of subimage regions box1 and box2.
VectorType v2
Corner v2 of the subimage region (also included in region!).
intT getNumVoxels() const
Returns number of voxels in the subimage region, i.e., the product of all extents if this is not empt...
bool isEmpty() const
Returns true if subimage region is empty, i.e., if any of the components of v1 is greater than the co...
This template class manages/represents a rectangular 6d image region in memory which is organized lin...
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:716
Tool function(s) to determine translation information from one directory to another.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
unsigned char MLuint8
Definition mlTypeDefs.h:109
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:490
std::vector< std::string > StringVector
Define often used string vector types.
MLRELEASE_TOOLS_EXPORT std::string toBase64(const std::string &inString)
Converts inString including the terminating null character to a Base64 coded string,...
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector filterWithRegExVector(const ReleaseToolsIO::StringVector &strVec, const ReleaseToolsIO::StringVector &regExpressionsVec, std::vector< size_t > *matchedRegExIdxVec=nullptr)
Filter list of strings in strVec by regular expressions in regExpressionsVec and return list of match...
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)
Returns true if the number of elements in dblVec is <= 1 or if each dblVec[i]-dblVec[i-1] equals dblV...
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)
Decompose str into lines with split(str, sep), filter them with filterWithRegExVector(strLines,...
MLRELEASE_TOOLS_EXPORT int getMonotonicProperties(const std::vector< double > &dblVec, double eps=10e-5)
Returns a bit mask contains bits defined in MonotonicTypes which describe properties of the elements ...
MLRELEASE_TOOLS_EXPORT std::string createHashFromBytes(const unsigned char *data, size_t numBytes, const std::string &hashAlgorithm="SHA1")
Creates a hash string for the numBytes bytes data pointed to by data; nullptr data and numBytes == 0 ...
MLRELEASE_TOOLS_EXPORT MLErrorCode calculateAverageOfSumOfSquaredDifferences(const SubImage &subImg1, const SubImage &subImg2, double &avrOfSumOfSquaredDiffs)
Determines the average of pixel-wise sum of squared differences between the overlapping regions of su...
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)
Searches lines in inLines which match given strings/expression to extract string value(s).
MLRELEASE_TOOLS_EXPORT std::string fromBase64(const std::string &inString)
Converts inString from a Base64 coded string to a decoded original string, assuming that the string h...
MLRELEASE_TOOLS_EXPORT MLErrorCode copyBitSubImagesToUInt8SubImage(SubImage &outSubImage, const std::vector< SubImage > &frameSubImgs, MLint zTranslate=0, MLuint8 value=1, bool orValue=false)
Decompose packed bit data from packed single pixel data in frameSubImgs to a normal MLuint8Type'd sub...