diff --git a/src/TNL/Images/DicomHeader.h b/src/TNL/Images/DicomHeader.h index 009d29919594c03505a23447b2ef18b7455731cb..44905b1dff574fb9c0bdb3a12d54fe2ea33ed6df 100644 --- a/src/TNL/Images/DicomHeader.h +++ b/src/TNL/Images/DicomHeader.h @@ -4,7 +4,7 @@ // // SPDX-License-Identifier: MIT -#pragma once +#pragma once #ifdef HAVE_DCMTK_H #define HAVE_CONFIG_H @@ -27,40 +27,39 @@ class DicomImageInfo; class DicomHeader { public: - + inline DicomHeader(); - + inline virtual ~DicomHeader(); #ifdef HAVE_DCMTK_H inline DcmFileFormat &getFileFormat(); #endif - + inline DicomImageInfo &getImageInfo(); - + inline DicomPatientInfo &getPatientInfo(); - + inline DicomSeriesInfo &getSeriesInfo(); inline bool loadFromFile( const String& fileName ); protected: - + DicomImageInfo *imageInfoObj; - + DicomPatientInfo *patientInfoObj; - + DicomSeriesInfo *seriesInfoObj; #ifdef HAVE_DCMTK_H DcmFileFormat *fileFormat; #endif - + bool isLoaded; }; } // namespace Images } // namespace TNL -#include <TNL/Images//DicomHeader_impl.h> - +#include <TNL/Images/DicomHeader_impl.h> diff --git a/src/TNL/Images/DicomHeader_impl.h b/src/TNL/Images/DicomHeader_impl.h index 59e30aa24aa8109dbea56f3dfbbe55b03a61e4c3..13257439c8b1188358c0d37887c7dbfab7547bb5 100644 --- a/src/TNL/Images/DicomHeader_impl.h +++ b/src/TNL/Images/DicomHeader_impl.h @@ -6,10 +6,10 @@ #pragma once -#include <TNL/Images//DicomHeader.h> -#include <TNL/Images//DicomSeriesInfo.h> -#include <TNL/Images//DicomPatientInfo.h> -#include <TNL/Images//DicomImageInfo.h> +#include <TNL/Images/DicomHeader.h> +#include <TNL/Images/DicomImageInfo.h> +#include <TNL/Images/DicomPatientInfo.h> +#include <TNL/Images/DicomSeriesInfo.h> namespace TNL { namespace Images { diff --git a/src/TNL/Images/DicomImageInfo.h b/src/TNL/Images/DicomImageInfo.h index c8820503279edceee23758d3fbb4bd76a528da2c..0b6362830fa7c097280f53b8e469de016e937486 100644 --- a/src/TNL/Images/DicomImageInfo.h +++ b/src/TNL/Images/DicomImageInfo.h @@ -13,7 +13,7 @@ #endif namespace TNL { -namespace Images { +namespace Images { class DicomHeader; @@ -44,48 +44,47 @@ struct PixelSpacing class DicomImageInfo { public: - + inline DicomImageInfo( DicomHeader &DicomHeader); - + inline virtual ~DicomImageInfo(); inline ImagePositionToPatient getImagePositionToPatient(); - + inline ImageOrientationToPatient getImageOrientationToPatient(); - + inline double getSliceThickness(); - + inline double getSliceLocation(); - + inline PixelSpacing getPixelSpacing(); - + inline int getNumberOfSlices(); private: - + DicomHeader &dicomHeader; - + bool retrieveInfo(); - + bool isObjectRetrieved; double sliceLocation; - + double sliceThickness; - + ImagePositionToPatient imagePositionToPatient; - + ImageOrientationToPatient imageOrientationToPatient; - + PixelSpacing pixelSpacing; - + int numberOfSlices; - + int width, height, depth; }; } // namespace Images } // namespace TNL -#include <TNL/Images//DicomImageInfo_impl.h> - +#include <TNL/Images/DicomImageInfo_impl.h> diff --git a/src/TNL/Images/DicomImageInfo_impl.h b/src/TNL/Images/DicomImageInfo_impl.h index 67ce1c7e7559a238511746c5085b3d1251ac19b3..6c709c16618fb4e4ca1d1842ff91acd0217ed4d5 100644 --- a/src/TNL/Images/DicomImageInfo_impl.h +++ b/src/TNL/Images/DicomImageInfo_impl.h @@ -6,11 +6,11 @@ #pragma once -#include <TNL/Images//DicomImageInfo.h> -#include <TNL/Images//DicomHeader.h> +#include <TNL/Images/DicomHeader.h> +#include <TNL/Images/DicomImageInfo.h> namespace TNL { -namespace Images { +namespace Images { inline DicomImageInfo::DicomImageInfo( DicomHeader& dicomHeader ) : dicomHeader( dicomHeader ) diff --git a/src/TNL/Images/DicomPatientInfo.h b/src/TNL/Images/DicomPatientInfo.h index 3c83da47e6980442f110b71c4f9894d77f57463b..73894bbc08c7cb4976e1d6898cf65ac6137c48ec 100644 --- a/src/TNL/Images/DicomPatientInfo.h +++ b/src/TNL/Images/DicomPatientInfo.h @@ -17,7 +17,7 @@ #endif namespace TNL { -namespace Images { +namespace Images { class DicomHeader; @@ -28,21 +28,21 @@ class DicomHeader; class DicomPatientInfo { public: - + inline DicomPatientInfo(DicomHeader &aDicomHeader); - + inline virtual ~DicomPatientInfo(); inline const String& getName(); - + inline const String& getSex(); - + inline const String& getID(); - + inline const String& getWeight(); - + inline const String& getPosition(); - + inline const String& getOrientation(); private: @@ -67,5 +67,4 @@ class DicomPatientInfo } // namespace Images } // namespace TNL -#include <TNL/Images//DicomPatientInfo_impl.h> - +#include <TNL/Images/DicomPatientInfo_impl.h> diff --git a/src/TNL/Images/DicomSeries.h b/src/TNL/Images/DicomSeries.h index f02930a5334a37fe4f2662582932d10c36fc2247..f6005751ac31a8466fa45a929452db1edbdff9f1 100644 --- a/src/TNL/Images/DicomSeries.h +++ b/src/TNL/Images/DicomSeries.h @@ -11,11 +11,12 @@ #include <TNL/Containers/Array.h> #include <TNL/String.h> #include <TNL/TypeInfo.h> -#include <TNL/Images//Image.h> -#include <TNL/Images//DicomHeader.h> -#include <TNL/Images//RegionOfInterest.h> #include <TNL/Meshes/Grid.h> +#include <TNL/Images/DicomHeader.h> +#include <TNL/Images/Image.h> +#include <TNL/Images/RegionOfInterest.h> + #ifdef HAVE_DCMTK_H #define USING_STD_NAMESPACE #include <dcmtk/config/osconfig.h> @@ -49,15 +50,15 @@ struct ImagesInfo class DicomSeries : public Image< int > { public: - + typedef int IndexType; - + inline DicomSeries( const String& filePath ); - + inline virtual ~DicomSeries(); inline int getImagesCount(); - + template< typename Real, typename Device, typename Index, @@ -66,52 +67,51 @@ class DicomSeries : public Image< int > const Meshes::Grid< 2, Real, Device, Index >& grid, const RegionOfInterest< int > roi, Vector& vector ); - + #ifdef HAVE_DCMTK_H inline const Uint16 *getData( int imageNumber = 0 ); #endif - + inline int getColorCount(); - + inline int getBitsPerSampleCount(); - + inline int getMinColorValue(); - + inline WindowCenterWidth getWindowDefaults(); - + inline int getMaxColorValue(); - + inline void freeData(); - + inline DicomHeader &getHeader(int image); - + inline bool isDicomSeriesLoaded(); private: - + bool loadDicomSeries( const String& filePath ); - + bool retrieveFileList( const String& filePath ); - + bool loadImage( const String& filePath, int number ); std::list< String > fileList; - + Containers::Array<DicomHeader *,Devices::Host,int> dicomSeriesHeaders; bool isLoaded; - + #ifdef HAVE_DCMTK_H DicomImage *dicomImage; - + Uint16 *pixelData; #endif - + ImagesInfo imagesInfo; }; } // namespace Images } // namespace TNL -#include <TNL/Images//DicomSeries_impl.h> - +#include <TNL/Images/DicomSeries_impl.h> diff --git a/src/TNL/Images/DicomSeriesInfo.h b/src/TNL/Images/DicomSeriesInfo.h index 312a40299847b18cc28e09f427f9b7748452968c..c630b299e38deafa1ba5a302e139ed4e6cada1db 100644 --- a/src/TNL/Images/DicomSeriesInfo.h +++ b/src/TNL/Images/DicomSeriesInfo.h @@ -17,7 +17,7 @@ #endif namespace TNL { -namespace Images { +namespace Images { class DicomHeader; @@ -28,41 +28,41 @@ class DicomHeader; class DicomSeriesInfo { public: - + inline DicomSeriesInfo( DicomHeader &dicomHeader ); - + inline virtual ~DicomSeriesInfo(); inline const String& getModality(); - + inline const String& getStudyInstanceUID(); - + inline const String& getSeriesInstanceUID(); - + inline const String& getSeriesDescription(); - + inline const String& getSeriesNumber(); - + inline const String& getSeriesDate(); - + inline const String& getSeriesTime(); - + inline const String& getPerformingPhysiciansName(); - + inline const String& getPerformingPhysicianIdentificationSequence(); - + inline const String& getOperatorsName(); - + inline const String& getOperatorIdentificationSequence(); - + inline const String& getAcquisitionTime(); - + private: - + DicomHeader &dicomHeader; - + bool retrieveInfo(); - + bool isObjectRetrieved; String modality; @@ -101,5 +101,4 @@ class DicomSeriesInfo } // namespace Images } // namespace TNL -#include <TNL/Images//DicomSeriesInfo_impl.h> - +#include <TNL/Images/DicomSeriesInfo_impl.h> diff --git a/src/TNL/Images/DicomSeriesInfo_impl.h b/src/TNL/Images/DicomSeriesInfo_impl.h index 34648101894027f8f8afd2705f7526a8f62acfc1..6a90666ec7a1e94280a64f828260d1288cb39ca8 100644 --- a/src/TNL/Images/DicomSeriesInfo_impl.h +++ b/src/TNL/Images/DicomSeriesInfo_impl.h @@ -6,12 +6,13 @@ #pragma once -#include <TNL/Images//DicomSeriesInfo.h> -#include <TNL/Images//DicomHeader.h> #include <stdio.h> +#include <TNL/Images/DicomHeader.h> +#include <TNL/Images/DicomSeriesInfo.h> + namespace TNL { -namespace Images { +namespace Images { inline DicomSeriesInfo::DicomSeriesInfo( DicomHeader &dicomHeader) : dicomHeader( dicomHeader ) @@ -29,49 +30,49 @@ inline bool DicomSeriesInfo::retrieveInfo() OFString str; dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_Modality, str ); this->modality = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_StudyInstanceUID, str ); this->studyInstanceUID = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_SeriesInstanceUID, str ); this->seriesInstanceUID = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_SeriesNumber, str ); this->seriesNumber = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_SeriesDescription, str ); this->seriesDescription = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_SeriesDate, str ); this->seriesDate = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_SeriesTime, str ); this->seriesTime = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_PerformingPhysicianName, str ); this->performingPhysiciansName = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_PerformingPhysicianIdentificationSequence, str ); this->performingPhysicianIdentificationSequence = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_OperatorsName, str ); this->operatorsName = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_OperatorIdentificationSequence, str ); this->operatorIdentificationSequence = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_FrameAcquisitionDuration, str ); this->frameTime = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_FrameAcquisitionDateTime, str ); this->faDateTime = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_FrameReferenceTime, str ); this->faRefTime = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_ActualFrameDuration, str ); this->AFD = str.data(); - + dicomHeader.getFileFormat().getDataset()->findAndGetOFString( DCM_AcquisitionTime, str ); this->acquisitionTime = str.data(); diff --git a/src/TNL/Images/DicomSeries_impl.h b/src/TNL/Images/DicomSeries_impl.h index a90c5c93696242895737254f7006180b7d36a6ea..b6253a5baaa23f5c036806438823f9cbac508b51 100644 --- a/src/TNL/Images/DicomSeries_impl.h +++ b/src/TNL/Images/DicomSeries_impl.h @@ -6,12 +6,13 @@ #pragma once -#include <TNL/Images//DicomSeries.h> -#include <TNL/Images//DicomSeriesInfo.h> #include <dirent.h> +#include <TNL/Images/DicomSeries.h> +#include <TNL/Images/DicomSeriesInfo.h> + namespace TNL { -namespace Images { +namespace Images { int findLastIndexOf(String &str, const char* c) { @@ -83,7 +84,7 @@ getImage( const int imageIdx, const Uint16* imageData = this->getData( imageIdx ); typedef Meshes::Grid< 2, Real, Device, Index > GridType; typename GridType::Cell cell( grid ); - + Index i, j; int position( 0 ); for( i = 0; i < this->height; i ++ ) diff --git a/src/TNL/Images/JPEGImage.h b/src/TNL/Images/JPEGImage.h index 92b64468e34ca6807081fe362f611b1561ae7984..ce08b43b186078c39bce20eb95e34daf30bd9f2d 100644 --- a/src/TNL/Images/JPEGImage.h +++ b/src/TNL/Images/JPEGImage.h @@ -23,56 +23,56 @@ struct my_error_mgr #endif namespace TNL { -namespace Images { +namespace Images { template< typename Index = int > class JPEGImage : public Image< Index > { public: - + typedef Index IndexType; - + JPEGImage(); - + bool openForRead( const String& fileName ); - + template< typename MeshReal, typename Device, typename Real > bool read( const RegionOfInterest< Index > roi, Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index >, 2, Real >& function ); - - + + template< typename Real, typename Device > bool openForWrite( const String& fileName, Meshes::Grid< 2, Real, Device, Index >& grid ); - + // TODO: Obsolete template< typename Real, typename Device, typename Vector > bool write( const Meshes::Grid< 2, Real, Device, Index >& grid, Vector& vector ); - + template< typename MeshReal, typename Device, typename Real > bool write( const Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index >, 2, Real >& function ); - - + + void close(); - + ~JPEGImage(); - + protected: - + bool readHeader(); - + template< typename Real, typename Device > bool writeHeader( const Meshes::Grid< 2, Real, Device, Index >& grid ); - + FILE* file; bool fileOpen; @@ -89,5 +89,4 @@ class JPEGImage : public Image< Index > } // namespace Images } // namespace TNL -#include <TNL/Images//JPEGImage_impl.h> - +#include <TNL/Images/JPEGImage_impl.h> diff --git a/src/TNL/Images/JPEGImage_impl.h b/src/TNL/Images/JPEGImage_impl.h index 7b89d5d0ca863bb2537fc43567b1365b16502851..cc94c1f7cbc0886a9c3f4cb0c0e52b7df2f431d7 100644 --- a/src/TNL/Images/JPEGImage_impl.h +++ b/src/TNL/Images/JPEGImage_impl.h @@ -6,11 +6,12 @@ #pragma once -#include <TNL/Images//JPEGImage.h> #include <setjmp.h> +#include <TNL/Images/JPEGImage.h> + namespace TNL { -namespace Images { +namespace Images { #ifdef HAVE_JPEG_H inline void my_error_exit( j_common_ptr cinfo ) @@ -42,7 +43,7 @@ readHeader() #ifdef HAVE_JPEG_H this->decinfo.err = jpeg_std_error(&jerr.pub); this->jerr.pub.error_exit = my_error_exit; - + /*** * Prepare the long jump back from libjpeg. */ @@ -55,7 +56,7 @@ readHeader() jpeg_destroy_decompress( &this->decinfo ); return false; } - + jpeg_create_decompress( &this->decinfo ); jpeg_stdio_src( &this->decinfo, this->file ); if( jpeg_read_header( &this->decinfo, true ) != JPEG_HEADER_OK ) @@ -103,7 +104,7 @@ read( const RegionOfInterest< Index > roi, typedef Meshes::Grid< 2, Real, Device, Index > GridType; const GridType& grid = function.getMesh(); typename GridType::Cell cell( grid ); - + /*** * Prepare the long jump back from libjpeg. */ @@ -116,14 +117,14 @@ read( const RegionOfInterest< Index > roi, jpeg_destroy_decompress( &this->decinfo ); return false; } - + jpeg_start_decompress( &this->decinfo ); int row_stride = this->decinfo.output_width * this->decinfo.output_components; JSAMPARRAY row = ( *( this->decinfo.mem->alloc_sarray ) )( ( j_common_ptr ) &this->decinfo, JPOOL_IMAGE, row_stride, - 1 ); - + 1 ); + Index i( 0 ), j; while( this->decinfo.output_scanline < this->decinfo.output_height) { @@ -132,7 +133,7 @@ read( const RegionOfInterest< Index > roi, { if( !roi.isIn( i, j ) ) continue; - + cell.getCoordinates().x() = j - roi.getLeft(); cell.getCoordinates().y() = roi.getBottom() - 1 - i; //Index cellIndex = grid.getCellIndex( CoordinatesType( j - roi.getLeft(), @@ -296,7 +297,7 @@ write( const Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index > return true; #else return false; -#endif +#endif } diff --git a/src/TNL/Images/PGMImage.h b/src/TNL/Images/PGMImage.h index baad1e299d94af3da75c71b1096a4a63ccbb9e97..e8a6adc4b09567bfedd2f16ecfcdd54933490393 100644 --- a/src/TNL/Images/PGMImage.h +++ b/src/TNL/Images/PGMImage.h @@ -4,33 +4,35 @@ // // SPDX-License-Identifier: MIT -#pragma once +#pragma once -#include <TNL/String.h> -#include <TNL/Images//Image.h> -#include <TNL/Images//RegionOfInterest.h> #include <fstream> +#include <TNL/String.h> + +#include <TNL/Images/Image.h> +#include <TNL/Images/RegionOfInterest.h> + namespace TNL { -namespace Images { +namespace Images { template< typename Index = int > class PGMImage : public Image< Index > { public: - + typedef Index IndexType; - + PGMImage(); - + bool openForRead( const String& fileName ); - + template< typename MeshReal, typename Device, typename Real > bool read( const RegionOfInterest< Index > roi, Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index >, 2, Real >& function ); - + template< typename Real, typename Device > bool openForWrite( const String& fileName, @@ -43,37 +45,35 @@ class PGMImage : public Image< Index > typename Vector > bool write( const Meshes::Grid< 2, Real, Device, Index >& grid, Vector& vector ); - + template< typename MeshReal, typename Device, typename Real > bool write( const Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index >, 2, Real >& function ); - + void close(); - + ~PGMImage(); - + protected: - + bool readHeader(); - + template< typename Real, typename Device > bool writeHeader( const Meshes::Grid< 2, Real, Device, Index >& grid, bool binary ); - + bool binary; - + IndexType maxColors; - + std::fstream file; - + bool fileOpen; }; } // namespace Images } // namespace TNL -#include <TNL/Images//PGMImage_impl.h> - - +#include <TNL/Images/PGMImage_impl.h> diff --git a/src/TNL/Images/PGMImage_impl.h b/src/TNL/Images/PGMImage_impl.h index d3023d4dd363bb3b22966bcc42f40ee230baab9d..7dc64823392f24910ac25d2231da9fd193de8fed 100644 --- a/src/TNL/Images/PGMImage_impl.h +++ b/src/TNL/Images/PGMImage_impl.h @@ -4,13 +4,14 @@ // // SPDX-License-Identifier: MIT -#pragma once +#pragma once #include <cstring> -#include <TNL/Images//PGMImage.h> + +#include <TNL/Images/PGMImage.h> namespace TNL { -namespace Images { +namespace Images { template< typename Index > PGMImage< Index >:: @@ -34,7 +35,7 @@ readHeader() if( magicNumber != "P5" && magicNumber != "P2" ) return false; - + if( magicNumber == "P5" ) this->binary = true; @@ -48,7 +49,7 @@ readHeader() this->file.get( character ); } this->file.unget(); - + this->file >> this->width >> this->height >> this->maxColors; return true; } @@ -164,7 +165,7 @@ write( const Meshes::Grid< 2, Real, Device, Index >& grid, { typedef Meshes::Grid< 2, Real, Device, Index > GridType; typename GridType::Cell cell( grid ); - + Index i, j; for( i = 0; i < grid.getDimensions().y(); i ++ ) { @@ -173,7 +174,7 @@ write( const Meshes::Grid< 2, Real, Device, Index >& grid, cell.getCoordinates().x() = j; cell.getCoordinates().y() = grid.getDimensions().y() - 1 - i; cell.refresh(); - + //Index cellIndex = grid.getCellIndex( CoordinatesType( j, // grid.getDimensions().y() - 1 - i ) ); @@ -185,7 +186,7 @@ write( const Meshes::Grid< 2, Real, Device, Index >& grid, this->file << ' '; } else this->file << color; - } + } if ( ! this->binary ) this->file << '\n'; } @@ -203,7 +204,7 @@ write( const Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index > typedef Meshes::Grid< 2, Real, Device, Index > GridType; const GridType& grid = function.getMesh(); typename GridType::Cell cell( grid ); - + Index i, j; for( i = 0; i < grid.getDimensions().y(); i ++ ) { @@ -212,7 +213,7 @@ write( const Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index > cell.getCoordinates().x() = j; cell.getCoordinates().y() = grid.getDimensions().y() - 1 - i; cell.refresh(); - + //Index cellIndex = grid.getCellIndex( CoordinatesType( j, // grid.getDimensions().y() - 1 - i ) ); @@ -224,7 +225,7 @@ write( const Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index > this->file << ' '; } else this->file << color; - } + } if ( ! this->binary ) this->file << '\n'; } diff --git a/src/TNL/Images/PNGImage.h b/src/TNL/Images/PNGImage.h index ec03126f9abc9efce0eccd80b30a181671f70734..16ae7a0ebaadda432b19fbf1b132e58d38924834 100644 --- a/src/TNL/Images/PNGImage.h +++ b/src/TNL/Images/PNGImage.h @@ -16,25 +16,25 @@ #include <TNL/Functions/MeshFunction.h> namespace TNL { -namespace Images { +namespace Images { template< typename Index = int > class PNGImage : public Image< Index > { public: - + using IndexType = Index; - + PNGImage(); - + bool openForRead( const String& fileName ); - + template< typename MeshReal, typename Device, typename Real > bool read( const RegionOfInterest< Index > roi, Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index >, 2, Real >& function ); - + template< typename Real, typename Device > bool openForWrite( const String& fileName, @@ -46,25 +46,25 @@ class PNGImage : public Image< Index > typename Vector > bool write( const Meshes::Grid< 2, Real, Device, Index >& grid, Vector& vector ); - + template< typename MeshReal, typename Device, typename Real > bool write( const Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index >, 2, Real >& function ); - - + + void close(); - + ~PNGImage(); - + protected: - + bool readHeader(); - + template< typename Real, typename Device > bool writeHeader( const Meshes::Grid< 2, Real, Device, Index >& grid ); - + FILE* file; bool fileOpen; @@ -73,7 +73,7 @@ class PNGImage : public Image< Index > png_structp png_ptr; png_infop info_ptr, end_info; - + png_byte color_type, bit_depth; #endif }; @@ -81,5 +81,4 @@ class PNGImage : public Image< Index > } // namespace Images } // namespace TNL -#include <TNL/Images//PNGImage_impl.h> - +#include <TNL/Images/PNGImage_impl.h> diff --git a/src/TNL/Images/PNGImage_impl.h b/src/TNL/Images/PNGImage_impl.h index 3f1140e4f09baa43eb187e1af0c16827c5685438..b75528ee651218eba2d1fe300aa2fface630d5dd 100644 --- a/src/TNL/Images/PNGImage_impl.h +++ b/src/TNL/Images/PNGImage_impl.h @@ -4,12 +4,12 @@ // // SPDX-License-Identifier: MIT -#pragma once +#pragma once -#include <TNL/Images//PNGImage.h> +#include <TNL/Images/PNGImage.h> namespace TNL { -namespace Images { +namespace Images { template< typename Index > PNGImage< Index >:: @@ -37,7 +37,7 @@ readHeader() bool isPNG = !png_sig_cmp( header, 0, headerSize ); if( ! isPNG ) return false; - + /**** * Allocate necessary memory */ @@ -78,7 +78,7 @@ readHeader() } png_init_io( this->png_ptr, this->file ); png_set_sig_bytes( this->png_ptr, headerSize ); - + /**** * Read the header */ @@ -126,7 +126,7 @@ read( const RegionOfInterest< Index > roi, typedef Meshes::Grid< 2, MeshReal, Device, Index > GridType; const GridType& grid = function.getMesh(); typename GridType::Cell cell( grid ); - + /*** * Prepare the long jump back from libpng. */ @@ -137,9 +137,9 @@ read( const RegionOfInterest< Index > roi, &this->end_info ); return false; } - + png_bytepp row_pointers = png_get_rows( this->png_ptr, this->info_ptr ); - + Index i, j; for( i = 0; i < this->height; i ++ ) { @@ -147,7 +147,7 @@ read( const RegionOfInterest< Index > roi, { if( !roi.isIn( i, j ) ) continue; - + cell.getCoordinates().x() = j - roi.getLeft(); cell.getCoordinates().y() = roi.getBottom() - 1 - i; cell.refresh(); @@ -232,7 +232,7 @@ writeHeader( const Meshes::Grid< 2, Real, Device, Index >& grid ) NULL); return false; } - + /*** * Prepare the long jump back from libpng. */ @@ -248,7 +248,7 @@ writeHeader( const Meshes::Grid< 2, Real, Device, Index >& grid ) * Set the zlib compression level */ //png_set_compression_level( this->png_ptr, Z_BEST_COMPRESSION ); - + //const int bitDepth( 8 ); png_set_IHDR( this->png_ptr, this->info_ptr, @@ -301,7 +301,7 @@ write( const Meshes::Grid< 2, Real, Device, Index >& grid, #ifdef HAVE_PNG_H typedef Meshes::Grid< 2, Real, Device, Index > GridType; typename GridType::Cell cell( grid ); - + /*** * Prepare the long jump back from libpng. */ @@ -312,7 +312,7 @@ write( const Meshes::Grid< 2, Real, Device, Index >& grid, &this->end_info ); return false; } - + Index i, j; png_bytep row = new png_byte[ 3 * grid.getDimensions().x() ]; for( i = 0; i < grid.getDimensions().y(); i ++ ) @@ -348,7 +348,7 @@ write( const Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index > typedef Meshes::Grid< 2, Real, Device, Index > GridType; const GridType& grid = function.getMesh(); typename GridType::Cell cell( grid ); - + /*** * Prepare the long jump back from libpng. */ @@ -359,7 +359,7 @@ write( const Functions::MeshFunction< Meshes::Grid< 2, MeshReal, Device, Index > &this->end_info ); return false; } - + Index i, j; png_bytep row = new png_byte[ 3 * grid.getDimensions().x() ]; for( i = 0; i < grid.getDimensions().y(); i ++ ) diff --git a/src/TNL/Images/RegionOfInterest.h b/src/TNL/Images/RegionOfInterest.h index 87e1f89cde02d15e7468c72dfcdb13fccbd5cd9a..4fc399b34622551579ad9703f8b1e740a7f06b66 100644 --- a/src/TNL/Images/RegionOfInterest.h +++ b/src/TNL/Images/RegionOfInterest.h @@ -7,50 +7,48 @@ #pragma once #include <TNL/Config/ParameterContainer.h> +#include <TNL/Images/Image.h> #include <TNL/Meshes/Grid.h> -#include <TNL/Images//Image.h> namespace TNL { -namespace Images { +namespace Images { template< typename Index = int > class RegionOfInterest { public: - + RegionOfInterest(); - + bool setup( const Config::ParameterContainer& parameters, const Image< Index >* image ); - + bool check( const Image< Index >* image ) const; - + Index getTop() const; - + Index getBottom() const; - + Index getLeft() const; - + Index getRight() const; - + Index getWidth() const; - + Index getHeight() const; - + template< typename Grid > bool setGrid( Grid& grid, bool verbose = false ); - + bool isIn( const Index row, const Index column ) const; - + protected: - + Index top, bottom, left, right; }; } // namespace Images } // namespace TNL -#include <TNL/Images//RegionOfInterest_impl.h> - - +#include <TNL/Images/RegionOfInterest_impl.h>