19 class mitkCompressedImageContainerTestClass
28 if (image->
GetDimension() != uncompressedImage->GetDimension())
31 std::cerr <<
" (EE) Number of image dimensions wrong after uncompression (was: " << image->
GetDimension()
32 <<
", now: " << uncompressedImage->GetDimension() <<
")" << std::endl;
35 for (
unsigned int dim = 0; dim < image->
GetDimension(); ++dim)
37 if (image->
GetDimension(dim) != uncompressedImage->GetDimension(dim))
40 std::cerr <<
" (EE) Image dimension " << dim
41 <<
" differs after uncompression (was: " << image->
GetDimension(dim)
42 <<
", now: " << uncompressedImage->GetDimension(dim) <<
")" << std::endl;
47 if (image->
GetPixelType() != uncompressedImage->GetPixelType())
50 std::cerr <<
" (EE) Pixel type wrong after uncompression:" << std::endl;
53 std::cout <<
"Original pixel type:" << std::endl;
54 std::cout <<
" PixelType: " << m_PixelType.
GetTypeAsString() << std::endl;
55 std::cout <<
" BitsPerElement: " << m_PixelType.
GetBpe() << std::endl;
60 std::cout <<
"Uncompressed pixel type:" << std::endl;
61 std::cout <<
" PixelType: " << uncompressedImage->GetPixelType().GetTypeAsString() << std::endl;
62 std::cout <<
" BitsPerElement: " << uncompressedImage->GetPixelType().GetBpe() << std::endl;
63 std::cout <<
" NumberOfComponents: " << uncompressedImage->GetPixelType().GetNumberOfComponents() << std::endl;
64 std::cout <<
" BitsPerComponent: " << uncompressedImage->GetPixelType().GetBitsPerComponent() << std::endl;
69 unsigned long oneTimeStepSizeInBytes = m_PixelType.
GetBpe() >> 3;
70 for (
unsigned int dim = 0; dim < image->
GetDimension(); ++dim)
78 unsigned int numberOfTimeSteps(1);
84 for (
unsigned int timeStep = 0; timeStep < numberOfTimeSteps; ++timeStep)
89 auto *originalData((
unsigned char *)origImgAcc.GetData());
90 auto *uncompressedData((
unsigned char *)unCompImgAcc.GetData());
92 unsigned long difference(0);
93 for (
unsigned long byte = 0; byte < oneTimeStepSizeInBytes; ++byte)
95 if (originalData[byte] != uncompressedData[byte])
104 std::cerr <<
" (EE) Pixel data in timestep " << timeStep <<
" not identical after uncompression. " 105 << difference <<
" pixels different." << std::endl;
116 unsigned int numberFailed(0);
121 std::cerr <<
"No file specified [FAILED]" << std::endl;
130 std::cout <<
"Testing with parameter '" << argv[1] <<
"'" << std::endl;
131 image = mitk::IOUtil::Load<mitk::Image>(argv[1]);
135 std::cout <<
"File not an image - test will not be applied [PASSED]" << std::endl;
136 std::cout <<
"[TEST DONE]" << std::endl;
139 catch (itk::ExceptionObject &ex)
142 std::cerr <<
"Exception: " << ex <<
"[FAILED]" << std::endl;
146 std::cout <<
" (II) Could load image." << std::endl;
147 std::cout <<
"Testing instantiation" << std::endl;
151 if (container.IsNotNull())
153 std::cout <<
" (II) Instantiation works." << std::endl;
158 std::cout <<
"Test failed, and it's the ugliest one!" << std::endl;
163 mitkCompressedImageContainerTestClass::Test(container, image, numberFailed);
165 std::cout <<
"Testing destruction" << std::endl;
170 std::cout <<
" (II) Freeing works." << std::endl;
172 if (numberFailed > 0)
174 std::cerr << numberFailed <<
" tests failed." << std::endl;
179 std::cout <<
"PASSED all tests." << std::endl;
vcl_size_t GetBitsPerComponent() const
Get the number of bits per components.
std::string GetTypeAsString() const
Returns a string representing the pixel type and pixel components.
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
vcl_size_t GetNumberOfComponents() const
Get the number of components of which each element consists.
void SetImage(Image *)
Creates a compressed version of the image.
Holds one (compressed) mitk::Image.
vcl_size_t GetBpe() const
Get the number of bits per element (of an element)
Image::Pointer GetImage()
Creates a full mitk::Image from its compressed version.
unsigned int GetDimension() const
Get dimension of the image.
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
virtual ImageDataItemPointer GetVolumeData(int t=0, int n=0, void *data=nullptr, ImportMemoryManagementType importMemoryManagement=CopyMemory) const
Image class for storing images.
int mitkCompressedImageContainerTest(int argc, char *argv[])
ctest entry point
mitk::Image::Pointer image
ImageReadAccessor class to get locked read access for a particular image part.
Class for defining the data type of pixels.