MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlImageFormatTools.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_IMAGE_FORMAT_TOOLS_H
14#define ML_IMAGE_FORMAT_TOOLS_H
15
19
20// Resolve platform independencies.
22
23#include "mlModuleIncludes.h"
25#include <mlTimeCounter.h>
26
27// Implement everything in ML namespace.
29
31class MLImageFormatInfos;
32class DataCompressor;
33class MLImageFormatIdxTable;
34
35//----------------------------------------------------------------------
38//----------------------------------------------------------------------
40{
41
42public:
43 friend class MLImageFormatSaveHandler;
44
47 DefaultSaveMode = 0,
48 AllowPartialPages = 1,
50 SaveOnlyDefaultValue = 2
53 };
54
55 //--------------------------------------------------------------------------------
58 //--------------------------------------------------------------------------------
59 typedef void MLImageFormatNotifyCB(double progress,
60 void* usrData
61 );
62
63
64 //--------------------------------------------------------------------------------
69 //--------------------------------------------------------------------------------
70 static const std::string ML_FILE_VERSION_STRING;
71
72 //--------------------------------------------------------------------------------
76 //--------------------------------------------------------------------------------
77 static const std::string ML_FILE_VERSION_STRING_EXT;
78
79 //--------------------------------------------------------------------------------
82 //--------------------------------------------------------------------------------
84
85 //----------------------------------------------------------------------
86 //
89 //
90 //----------------------------------------------------------------------
91
127 static MLErrorCode
128 open(MLImageFormatInfos*& infos, const std::string& fileName, bool truncate = false,
129 const std::string& compressorName = "",
130 const MLImageFormatTagList& compressionTagList = MLImageFormatTagList::getDefaultEmptyTagList(),
131 const MLImageFormatTagList& userTagList = MLImageFormatTagList::getDefaultEmptyTagList(),
132 const MLImageFormatTagList& privateTagList = MLImageFormatTagList::getDefaultEmptyTagList(),
133 const std::string& defaultVoxelValue = "0", bool rewritable = true, bool suppressReadCheckSumTests = false);
134
138 static MLErrorCode
139 open(MLImageFormatInfos*& infos, MLImageFormatAbstractFileHandle* fileHandle, bool truncate = false,
140 const std::string& compressorName = "",
141 const MLImageFormatTagList& compressionTagList = MLImageFormatTagList::getDefaultEmptyTagList(),
142 const MLImageFormatTagList& userTagList = MLImageFormatTagList::getDefaultEmptyTagList(),
143 const MLImageFormatTagList& privateTagList = MLImageFormatTagList::getDefaultEmptyTagList(),
144 const std::string& defaultVoxelValue = "0", bool rewritable = true, bool suppressReadCheckSumTests = false);
145
152
181 MLImageFormatNotifyCB* callback = nullptr, void* userData = nullptr,
183 MLuint32 saveModeBits = DefaultSaveMode, MLdouble* saveTime = nullptr,
184 MLdouble* prepTime = nullptr);
185
186
203
204
231 MLImageFormatNotifyCB* callback, void* userData, const ScaleShiftData& scaleShiftData,
232 MLuint32 saveModeBits = DefaultSaveMode, MLdouble* saveTime = nullptr,
233 MLdouble* prepTime = nullptr);
234
257 static MLErrorCode overwrite(MLImageFormatInfos& infos, const SubImage& inputSubImg, MLImageFormatNotifyCB* callback,
258 void* userData, const ScaleShiftData& scaleShiftData,
259 MLuint32 saveModeBits = DefaultSaveMode, MLdouble* saveTime = nullptr,
260 MLdouble* prepTime = nullptr);
261
297
298
309 static MLuint32 calcCheckSum(const void* dataPtr, size_t numBytes, size_t voxSize);
310
320 static void setDICOMTreeSourceFileName(PagedImage& outImg, const std::string& fileName);
321
322
323protected:
331
336
348
360 const size_t expectedSizeInBytes, MLuint8*& loadedPage, bool& isLossy);
361
406 MLImageFormatNotifyCB* callback, void* userData,
409 MLdouble* prepTime = nullptr);
410
442
457};
458
460
461#endif // of __mlImageFormatTools_H
#define MLIMAGEFORMATBASE_EXPORT
Abstract base class for ML data compression algorithms.
A base class for abstract read/write access of the MLImageFileFormat.
A internal structure containing information about an opened file.
Class defining a list of tags used in the MLImageFormat class.
Basic tool functions used to store, load, and modify a PagedImage in a file, used by the MLImageForma...
static MLErrorCode _decompressPageData(const MLImageFormatInfos &infos, const size_t savedPageSizeInBytes, const size_t expectedSizeInBytes, MLuint8 *&loadedPage, bool &isLossy)
Decompresses and replaces data given as pointer in loadedPage.
static const std::string ML_FILE_VERSION_STRING
Basic file version string used for MeVisLab release 1.5.
static MLErrorCode open(MLImageFormatInfos *&infos, const std::string &fileName, bool truncate=false, const std::string &compressorName="", const MLImageFormatTagList &compressionTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &userTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &privateTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const std::string &defaultVoxelValue="0", bool rewritable=true, bool suppressReadCheckSumTests=false)
Opens a file in binary mode returning a descriptor for the opened file.
static MLErrorCode overwrite(MLImageFormatInfos &infos, const SubImage &inputSubImg, MLImageFormatNotifyCB *callback, void *userData, const ScaleShiftData &scaleShiftData, MLuint32 saveModeBits=DefaultSaveMode, MLdouble *saveTime=nullptr, MLdouble *prepTime=nullptr)
Overwrites a region in a file that has been written before (with save).
static MLErrorCode close(MLImageFormatInfos *&infos)
Closes an open file.
static MLErrorCode overwrite(MLImageFormatInfos &infos, PagedImage &inputPagedImg, const SubImageBox &box, MLImageFormatNotifyCB *callback, void *userData, const ScaleShiftData &scaleShiftData, MLuint32 saveModeBits=DefaultSaveMode, MLdouble *saveTime=nullptr, MLdouble *prepTime=nullptr)
Overwrites a region in a file that has been written before (with save).
static MLuint32 calcCheckSum(const void *dataPtr, size_t numBytes, size_t voxSize)
Calculates a 24 bit checksum for the data given by dataPtr.
static const std::string ML_FILE_VERSION_STRING_EXT
Basic file version string used for MeVisLab release 1.5 plus addOns.
static MLErrorCode save(MLImageFormatInfos &infos, PagedImage &inputPagedImg, const SubImageBox &box=SubImageBox(), MLImageFormatNotifyCB *callback=nullptr, void *userData=nullptr, const ScaleShiftData &scaleShiftData=ScaleShiftData(), MLuint32 saveModeBits=DefaultSaveMode, MLdouble *saveTime=nullptr, MLdouble *prepTime=nullptr)
Saves the data of the paged image inputPagedImg from the region given by box in the file.
void MLImageFormatNotifyCB(double progress, void *usrData)
Callback type that can be registered in save and overwrite functions to interrupt processing and to g...
static MLErrorCode _destroyFileProperties(MLImageFormatInfos *&infos)
Destroys the MLImageFileInfo object and resets the pointer to NULL.
static MLErrorCode open(MLImageFormatInfos *&infos, MLImageFormatAbstractFileHandle *fileHandle, bool truncate=false, const std::string &compressorName="", const MLImageFormatTagList &compressionTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &userTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const MLImageFormatTagList &privateTagList=MLImageFormatTagList::getDefaultEmptyTagList(), const std::string &defaultVoxelValue="0", bool rewritable=true, bool suppressReadCheckSumTests=false)
Overload of open() with a virtual file handle, have a look at open(..., filename, ....
SaveModeBits
Mode bits describing special save options.
static const size_t ML_MAX_VERSION_AND_FIRST_PAIR_SIZE
Number of characters that will not be exceeded by version string and first tag pair.
static MLErrorCode _saveIndexTableAndPages(MLImageFormatInfos &infos, const SubImageBox &box, PagedImage *inputPagedImg, const SubImage *inputSubImg, MLImageFormatNotifyCB *callback, void *userData, const ScaleShiftData &scaleShiftData, bool replaceAreaToSave, MLuint32 saveModeBits, MLdouble *saveTime=nullptr, MLdouble *prepTime=nullptr)
Saves or overwrites pages overlapping areaToSave of inputPagedImg.
static MLErrorCode _loadPage(const MLImageFormatInfos &infos, MLint pageId, SubImage &pageBuf)
Reads page given by ID pageId into memory handled by pageBuf.
static void setDICOMTreeSourceFileName(PagedImage &outImg, const std::string &fileName)
If the paged image has DicomTreeImagePropertyExtensions, then set their file names,...
static MLErrorCode overwriteHeaderAndPageList(const MLImageFormatInfos &infos, MLuint32 saveModeBits)
Saves the file header information a second time over the already written file.
static MLErrorCode getTile(const MLImageFormatInfos &infos, SubImage &subImgToFill, bool useFileDataType, bool useFileRegion, const ScaleShiftData &scaleShiftData)
Loads a subimage from the specified file and returns an MLErrorCode describing success or failure.
static MLErrorCode _savePage(MLImageFormatInfos &infos, const MLint pageId, const bool isOutsideAreaToSave, const MLTypeData *defaultVoxelPtr, const SubImage &subImgToSave, const bool replaceOnlyWrittenPageIds, const MLuint32 saveModeBits, TimeCounter &saveTimer, MLdouble &saveTime, TimeCounter &calcTimer, MLdouble &calcTime)
Stores the page subImgToSave in file given by infos and updates the corresponding entry in the index ...
static MLErrorCode _compressPageData(DataCompressor *compressor, SubImage &dataSubImg, MLint &dstBufSize)
Compresses data of a subimage.
static MLErrorCode _loadFileProperties(MLImageFormatInfos &infos)
Reads all information from the file given by fileHandle in infos and stores it in the returned inform...
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
Class to measure precise time intervals.
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:772
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
unsigned int MLuint32
Definition mlTypeDefs.h:185
unsigned char MLuint8
Definition mlTypeDefs.h:109
double MLdouble
Definition mlTypeDefs.h:217
unsigned char MLTypeData
This is the pointer type used to point to the data of MLType data instances.
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