diff --git a/Code/IO/otbCAIImageIO.cxx b/Code/IO/otbCAIImageIO.cxx index 15e62eea38ffcb8366011951713fd42ba9bcec9b..ee9c7d46d69557fd618974dd1424e84aea4c9f85 100755 --- a/Code/IO/otbCAIImageIO.cxx +++ b/Code/IO/otbCAIImageIO.cxx @@ -417,7 +417,6 @@ bool CAIImageIO::CanWriteFile( const char * filename ) NbColonnes, NbLignes, "LABEL"); - if (lCai == NULL) { formatFound = false; @@ -455,7 +454,7 @@ void CAIImageIO::Read(void* buffer) unsigned long lTailleBuffer = (unsigned long)(m_NbOctetPixel)*lNbPixels; unsigned char* value = new unsigned char[lTailleBuffer]; -otbMsgDebugMacro( << "CAIImageIO::Read() IORegion Start["<<this->GetIORegion().GetIndex()[0]<<","<<this->GetIORegion().GetIndex()[1]<<"] Size ["<<this->GetIORegion().GetSize()[0]<<","<<this->GetIORegion().GetSize()[1]<<"] on Image size ["<<m_Dimensions[0]<<","<<m_Dimensions[1]<<"]"); +otbMsgDevMacro( << "CAIImageIO::Read() IORegion Start["<<this->GetIORegion().GetIndex()[0]<<","<<this->GetIORegion().GetIndex()[1]<<"] Size ["<<this->GetIORegion().GetSize()[0]<<","<<this->GetIORegion().GetSize()[1]<<"] on Image size ["<<m_Dimensions[0]<<","<<m_Dimensions[1]<<"]"); // Mise a jour du step step = step * (unsigned long)(m_NbOctetPixel); @@ -574,9 +573,10 @@ void CAIImageIO::ReadImageInformation() } otbMsgDebugMacro( << "Driver: CAI - "<<CaiFormat); -otbMsgDebugMacro(<< " Use files : "<< m_FileName.c_str()<<" ("<<CaiFileName.c_str()<<")."); -otbMsgDebugMacro( <<" Size : "<<m_Dimensions[0]<<","<<m_Dimensions[1]); -otbMsgDebugMacro( <<" ComponentType : "<<this->GetComponentType() ); +otbMsgDebugMacro(<< " Use files : "<< m_FileName.c_str()<<" ("<<CaiFileName.c_str()<<")."); +otbMsgDebugMacro( <<" Size : "<<m_Dimensions[0]<<","<<m_Dimensions[1]); +otbMsgDebugMacro( <<" ComponentType : "<<this->GetComponentType() ); +otbMsgDebugMacro( <<" SetNumberOfComponents : "<<this->GetNumberOfComponents() ); //Stock le pointer CAI @@ -585,6 +585,17 @@ otbMsgDebugMacro( <<" ComponentType : "<<this->GetComponentType() ); void CAIImageIO::WriteImageInformation(void) { + +} + +void CAIImageIO::OpenCAIFileForWriting() +{ + CAI_IMAGE * lCai = NULL; + //Recupere pointeur sur structure CAI_IMAGE + lCai = (CAI_IMAGE *)m_ptrCai; + if(lCai == NULL) + { + int NbCanaux; /* Nombre de canaux de l'image */ int NbLignes; /* Nombre de lignes de l'image */ int NbColonnes; /* Nombre de colonnes de l'image */ @@ -635,8 +646,9 @@ void CAIImageIO::WriteImageInformation(void) NbLignes = m_Dimensions[1]; NbCanaux = this->GetNumberOfComponents(); NbOctetPixel = m_NbOctetPixel; - CAI_IMAGE * lCai = NULL; -otbMsgDebugMacro( << "CAIImageIO::WriteImageInformation() : Dimensions de l'image cree : "<<m_Dimensions[0]<<","<<m_Dimensions[1]); + +otbMsgDevMacro( << "CAIImageIO::OpenCAIFileForWriting() : Dimensions de l'image cree : "<<m_Dimensions[0]<<","<<m_Dimensions[1]); +otbMsgDevMacro( << "CAIImageIO::OpenCAIFileForWriting() : NbCanaux : "<<NbCanaux); lCai = cai_ouvre_creation_image( (char *)CaiFileName.c_str(), (char *)CaiFormat.c_str(), // Detection automatique @@ -645,20 +657,22 @@ otbMsgDebugMacro( << "CAIImageIO::WriteImageInformation() : Dimensions de l'imag NbColonnes, NbLignes, "CAI Image generate by OTB"); + if (lCai == NULL) { itkExceptionMacro(<< "Impossible d'ecrire les informations sur l'image (cai_ouvre_creation_image) " << m_FileName.c_str() <<" ("<<CaiFileName.c_str()<<";"<<CaiFormat.c_str()<<") : ("<<CAI_ERREUR<<")."); } //Stock le pointer CAI m_ptrCai = (char*)lCai; + } } /** The write function is not implemented */ void CAIImageIO::Write( const void* buffer) { - // Création de l'image avant -// this->WriteImageInformation(); + // checking if the Data file is open + this->OpenCAIFileForWriting(); const unsigned char * p = static_cast<const unsigned char *>(buffer); unsigned long l=0; @@ -678,7 +692,7 @@ void CAIImageIO::Write( const void* buffer) lPremiereLigne = 1; } -otbMsgDebugMacro( << "CAIImageIO::Write() IORegion Start["<<this->GetIORegion().GetIndex()[0]<<","<<this->GetIORegion().GetIndex()[1]<<"] Size ["<<this->GetIORegion().GetSize()[0]<<","<<this->GetIORegion().GetSize()[1]<<"] on Image size ["<<m_Dimensions[0]<<","<<m_Dimensions[1]<<"]"); +otbMsgDevMacro( << "CAIImageIO::Write() IORegion Start["<<this->GetIORegion().GetIndex()[0]<<","<<this->GetIORegion().GetIndex()[1]<<"] Size ["<<this->GetIORegion().GetSize()[0]<<","<<this->GetIORegion().GetSize()[1]<<"] on Image size ["<<m_Dimensions[0]<<","<<m_Dimensions[1]<<"]"); unsigned long lNbPixels = (unsigned long)(lNbColonnes*lNbLignes); unsigned long lTailleBuffer = (unsigned long)(m_NbOctetPixel)*lNbPixels; @@ -695,6 +709,10 @@ otbMsgDebugMacro( << "CAIImageIO::Write() IORegion Start["<<this->GetIORegion(). for ( int nbComponents = 0 ; nbComponents < this->GetNumberOfComponents() ; nbComponents++) { // Recopie dans le buffer +otbMsgDevMacro( << "CAIImageIO::Write() nbComponents "<<nbComponents << " / "<< this->GetNumberOfComponents()); +otbMsgDevMacro( << "CAIImageIO::Write() lPremiereLigne "<<lPremiereLigne ); +otbMsgDevMacro( << "CAIImageIO::Write() lNbLignes "<<lNbLignes ); +otbMsgDevMacro( << "CAIImageIO::Write() lNbColonnes "<<lNbColonnes ); unsigned long cpt(0); cpt = (unsigned long )(nbComponents)* (unsigned long)(m_NbOctetPixel); for ( unsigned long i=0 ; i < lTailleBuffer ; i = i+m_NbOctetPixel ) diff --git a/Code/IO/otbCAIImageIO.h b/Code/IO/otbCAIImageIO.h index 44aa6a0fb45da9c2bac7cdfbc13dcf0c90997591..b7d6a32887ba10f96b0040dcfd2dedac46bbab45 100755 --- a/Code/IO/otbCAIImageIO.h +++ b/Code/IO/otbCAIImageIO.h @@ -100,6 +100,8 @@ private: bool DetermineFormatSpot (char typspot, const char * str_repertoire , char * str_debut ); + void OpenCAIFileForWriting(); + /** Pointer sur la structure CAI */ char * m_ptrCai; /** Nombre d'octets par pixel */ diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt index ad2bacf42f18caff55904405f64ac06e2d376d0c..f727ea12ce260f1309df9064d46e0a0135e308f6 100644 --- a/Testing/Code/Common/CMakeLists.txt +++ b/Testing/Code/Common/CMakeLists.txt @@ -152,7 +152,7 @@ ADD_TEST(coTvMultiChannelROI_3c_BSQ ${COMMON_TESTS} --compare-binary ${BASELINE}/coMultiChannelExtractROI_RGB2NG_PNG_poupees_303_2_134_330_channels_345.c1 ${TEMP}/coMultiChannelExtractROI_RGB2NG_PNG_poupees_303_2_134_330_channels_345.c1 otbMultiChannelExtractROI - ${TEMP}/coMultiChannelExtractROI_RGB2NG_PNG_poupees_303_2_134_330_channels_1232.hd + ${TEMP}/coMultiChannelExtractROI_RGB2NG_PNG_poupees_303_2_134_330_channels_12321.hd ${TEMP}/coMultiChannelExtractROI_RGB2NG_PNG_poupees_303_2_134_330_channels_345.hd -startX 0 -startY 0 -sizeX 134 -sizeY 330 -channels 3 4 5 ) diff --git a/Testing/Code/Common/otbMultiChannelExtractROI.cxx b/Testing/Code/Common/otbMultiChannelExtractROI.cxx index d80f6eba11c0be733282e773fc2efa7b6b788ef4..ee76a810def612e58b1c3076a982124a082cd8a7 100755 --- a/Testing/Code/Common/otbMultiChannelExtractROI.cxx +++ b/Testing/Code/Common/otbMultiChannelExtractROI.cxx @@ -104,6 +104,7 @@ int generic_otbMultiChannelExtractROI( int argc, char ** argv, const char * inpu reader->Update(); //Necessaire pour connaitre le nombre de canaux dans l'image writer->SetFileName( outputFilename ); extractROIFilter->SetInput( reader->GetOutput() ); + extractROIFilter->Update(); writer->SetInput( extractROIFilter->GetOutput() ); writer->Update(); diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index 2b930fe9a87d79b9ac2d18a85213684f8b5acc9f..4aea89f9a380d4a6fff1c4234646d12d93a6e4fd 100755 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -394,9 +394,9 @@ ADD_TEST(ioTvMultiChannelROI_QuickbirdPAN2PNG ${COMMON_TESTS} # ${TEMP}/ioExtractROI_QuickbirdPAN2PNG_100_100_77_300.png otbMultiChannelExtractROI ${IMAGEDATA}/TOULOUSE/QuickBird/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF - ${TEMP}/ioExtractROI_QuickbirdPAN2PNG_100_100_77_300.png + ${TEMP}/ioExtractROI_QuickbirdXS2PNG_100_100_77_300.png -startX 100 -startY 100 -sizeX 77 -sizeY 300 - -channels 1) + -channels 1 2 3) # --- Quickbird XS --- ADD_TEST(ioTvMultiChannelROI_QuickbirdXS2PNG ${COMMON_TESTS}