23 class mitkCompressedImageContainerTestClass
32 if (image->
GetDimension() != uncompressedImage->GetDimension())
35 std::cerr <<
" (EE) Number of image dimensions wrong after uncompression (was: " << image->
GetDimension()
36 <<
", now: " << uncompressedImage->GetDimension() <<
")" << std::endl;
39 for (
unsigned int dim = 0; dim < image->
GetDimension(); ++dim)
41 if (image->
GetDimension(dim) != uncompressedImage->GetDimension(dim))
44 std::cerr <<
" (EE) Image dimension " << dim
45 <<
" differs after uncompression (was: " << image->
GetDimension(dim)
46 <<
", now: " << uncompressedImage->GetDimension(dim) <<
")" << std::endl;
51 if (image->
GetPixelType() != uncompressedImage->GetPixelType())
54 std::cerr <<
" (EE) Pixel type wrong after uncompression:" << std::endl;
57 std::cout <<
"Original pixel type:" << std::endl;
58 std::cout <<
" PixelType: " << m_PixelType.
GetTypeAsString() << std::endl;
59 std::cout <<
" BitsPerElement: " << m_PixelType.
GetBpe() << std::endl;
64 std::cout <<
"Uncompressed pixel type:" << std::endl;
65 std::cout <<
" PixelType: " << uncompressedImage->GetPixelType().GetTypeAsString() << std::endl;
66 std::cout <<
" BitsPerElement: " << uncompressedImage->GetPixelType().GetBpe() << std::endl;
67 std::cout <<
" NumberOfComponents: " << uncompressedImage->GetPixelType().GetNumberOfComponents() << std::endl;
68 std::cout <<
" BitsPerComponent: " << uncompressedImage->GetPixelType().GetBitsPerComponent() << std::endl;
73 unsigned long oneTimeStepSizeInBytes = m_PixelType.
GetBpe() >> 3;
74 for (
unsigned int dim = 0; dim < image->
GetDimension(); ++dim)
82 unsigned int numberOfTimeSteps(1);
88 for (
unsigned int timeStep = 0; timeStep < numberOfTimeSteps; ++timeStep)
93 unsigned char *originalData((
unsigned char *)origImgAcc.GetData());
94 unsigned char *uncompressedData((
unsigned char *)unCompImgAcc.GetData());
96 unsigned long difference(0);
97 for (
unsigned long byte = 0; byte < oneTimeStepSizeInBytes; ++byte)
99 if (originalData[byte] != uncompressedData[byte])
108 std::cerr <<
" (EE) Pixel data in timestep " << timeStep <<
" not identical after uncompression. "
109 << difference <<
" pixels different." << std::endl;
120 unsigned int numberFailed(0);
125 std::cerr <<
"No file specified [FAILED]" << std::endl;
134 std::cout <<
"Testing with parameter '" << argv[1] <<
"'" << std::endl;
139 std::cout <<
"File not an image - test will not be applied [PASSED]" << std::endl;
140 std::cout <<
"[TEST DONE]" << std::endl;
143 catch (itk::ExceptionObject &ex)
146 std::cerr <<
"Exception: " << ex <<
"[FAILED]" << std::endl;
150 std::cout <<
" (II) Could load image." << std::endl;
151 std::cout <<
"Testing instantiation" << std::endl;
155 if (container.IsNotNull())
157 std::cout <<
" (II) Instantiation works." << std::endl;
162 std::cout <<
"Test failed, and it's the ugliest one!" << std::endl;
167 mitkCompressedImageContainerTestClass::Test(container, image, numberFailed);
169 std::cout <<
"Testing destruction" << std::endl;
174 std::cout <<
" (II) Freeing works." << std::endl;
176 if (numberFailed > 0)
178 std::cerr << numberFailed <<
" tests failed." << std::endl;
183 std::cout <<
"PASSED all tests." << std::endl;
std::string GetTypeAsString() const
Returns a string representing the pixel type and pixel components.
itk::SmartPointer< Self > Pointer
void SetImage(Image *)
Creates a compressed version of the image.
vcl_size_t GetBitsPerComponent() const
Get the number of bits per components.
virtual ImageDataItemPointer GetVolumeData(int t=0, int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
Holds one (compressed) mitk::Image.
Image::Pointer GetImage()
Creates a full mitk::Image from its compressed version.
vcl_size_t GetBpe() const
Get the number of bits per element (of an element)
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Image class for storing images.
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
int mitkCompressedImageContainerTest(int argc, char *argv[])
ctest entry point
vcl_size_t GetNumberOfComponents() const
Get the number of components of which each element consists.
unsigned int GetDimension() const
Get dimension of the image.
ImageReadAccessor class to get locked read access for a particular image part.
static mitk::Image::Pointer LoadImage(const std::string &path)
LoadImage Convenience method to load an arbitrary mitkImage.
Class for defining the data type of pixels.