MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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#include <FMEThirdPartyWarningsDisable.h>
17#include <string>
18#include <FMEThirdPartyWarningsRestore.h>
19
20
21// For StringVector.
22#include "mlDirectoryMatching.h"
23
24// ML includes
25#include <mlModuleIncludes.h>
26
28
29//----------------------------------------------------------------------------------
31//----------------------------------------------------------------------------------
32namespace ReleaseToolsMisc {
33
35MLRELEASE_TOOLS_EXPORT extern const std::string LineSeparator;
36
43 const std::string &sep = LineSeparator);
44
64 std::vector<size_t> *matchedRegExIdxVec=nullptr);
65
69 const std::string &regEx);
70
73MLRELEASE_TOOLS_EXPORT std::string filterLinesWithRegEx(const std::string &str,
74 const std::string &regEx,
75 const std::string &sep=LineSeparator);
76
112 const bool useRegularExpression,
113 const std::string &firstExpression,
114 const std::string &lineEnd,
115 const MLint index,
116 std::string *errorInfos=nullptr);
117
145 const std::vector<SubImage> &frameSubImgs,
146 MLint zTranslate = 0,
147 MLuint8 value = 1,
148 bool orValue = false);
149
156
160MLRELEASE_TOOLS_EXPORT bool isEquidistant(const std::vector<double> &dblVec, double eps=10e-5);
161
173
176MLRELEASE_TOOLS_EXPORT int getMonotonicProperties(const std::vector<double> &dblVec, double eps=10e-5);
177
190 const SubImage &subImg2,
191 double &avrOfSumOfSquaredDiffs);
192
193
197template <typename DT1, typename DT2>
200 SubImageBox box)
201 {
202 double avrOfSumOfSquaredDifferences = -1.;
203 box = box.intersect(img1.getBox().intersect(img2.getBox()));
204 if (!box.isEmpty()){
206 ImageVector p;
207 for (p.u = box.v1.u; p.u <= box.v2.u; ++p.u){
208 for (p.t = box.v1.t; p.t <= box.v2.t; ++p.t){
209 for (p.c = box.v1.c; p.c <= box.v2.c; ++p.c){
210 for (p.z = box.v1.z; p.z <= box.v2.z; ++p.z){
211 for (p.y = box.v1.y; p.y <= box.v2.y; ++p.y){
212 // Get pointers to row starts.
213 p.x = box.v1.x;
214 const DT1 *v1 = img1.getImagePointer(p);
215 const DT2 *v2 = img2.getImagePointer(p);
216 for (; p.x <= box.v2.x; ++p.x, ++v1, ++v2){
217 // Determine difference between both voxels and sum up squares.
218 const double diff = static_cast<double>(*v1) - static_cast<double>(*v2);
220 }
221 }
222 }
223 }
224 }
225 }
226 // Calculate the average of all of sum of squared differences.
227 avrOfSumOfSquaredDifferences /= static_cast<double>(box.getNumVoxels());
228 }
230 }
231
234MLRELEASE_TOOLS_EXPORT std::string toBase64(const std::string &inString);
235
238MLRELEASE_TOOLS_EXPORT std::string fromBase64(const std::string &inString);
239
247MLRELEASE_TOOLS_EXPORT std::string createHashFromBytes(const unsigned char *data, size_t numBytes, const std::string &hashAlgorithm="SHA1");
248
249};
250
Project global and OS specific declarations.
#define MLRELEASE_TOOLS_EXPORT
DLL export macro definition.
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
This class manages/represents a rectangular 6D image region that 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 that is organized line...
Definition mlTSubImage.h:99
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:772
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:489
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...
MLRELEASE_TOOLS_EXPORT std::string getSubImageFromPagedImage(PagedImage &inputPagedImage, SubImage &subImage)
Try to load full image from inputPagedImage into subImage and return "" on success,...