Skip to content
Snippets Groups Projects
Commit ba9a1993 authored by Patrick Imbo's avatar Patrick Imbo
Browse files

No commit message

No commit message
parent dbe3cac9
No related branches found
No related tags found
No related merge requests found
......@@ -270,8 +270,10 @@ void LineDetectorImageFilterBase< TInputImage, TOutputImage, InterpolatorType>
// Loop on the region
//for (i = 0; i < neighborhoodSize; ++i)
for (int i = 0; i < m_Radius[0]; ++i)
for (int j = 0; j < m_Radius[1]; ++j)
// for (int i = 0; i < m_Radius[0]; ++i)
// for (int j = 0; j < m_Radius[1]; ++j)
for (int i = 0; i < m_Radius[0]; i++)
for (int j = 0; j < m_Radius[1]; j++)
{
off[0]=i-m_Radius[0]/2;
......
......@@ -52,6 +52,7 @@ ONERAImageIO::ONERAImageIO()
m_Origin[0] = 0.0;
m_Origin[1] = 0.0;
m_FlagWriteImageInformation = true;
}
......@@ -451,32 +452,63 @@ bool ONERAImageIO::CanWriteFile( const char* FileNameToWrite )
void ONERAImageIO::Write(const void* buffer)
{
if( m_FlagWriteImageInformation == true )
{
otbMsgDevMacro(<<"ONERAImageIO::Write() m_FlagWriteImageInformation : " <<m_FlagWriteImageInformation );
this->WriteImageInformation();
m_FlagWriteImageInformation = false;
}
unsigned long step = this->GetNumberOfComponents();
unsigned long step = this->GetNumberOfComponents();
const unsigned long numberOfBytes = this->GetImageSizeInBytes();
const unsigned long numberOfComponents = this->GetImageSizeInComponents();
char *tempmemory = new char[numberOfBytes];
memcpy(tempmemory,buffer,numberOfBytes);
int lNbLignes = this->GetIORegion().GetSize()[1];
int lNbColonnes = this->GetIORegion().GetSize()[0];
int lPremiereLigne = this->GetIORegion().GetIndex()[1] ; // [1... ]
int lPremiereColonne = this->GetIORegion().GetIndex()[0] ; // [1... ]
unsigned long numberOfBytesPerLines = step * lNbColonnes * m_NbOctetPixel;
unsigned long headerLength = ONERA_HEADER_LENGTH + 4 + numberOfBytesPerLines;
unsigned long offset;
unsigned long numberOfBytesToBeWrite = step * m_NbOctetPixel *lNbColonnes;
unsigned long numberOfBytesRegion = step * m_NbOctetPixel *lNbColonnes *lNbLignes;
unsigned long numberOfBytesWrite;
char *tempmemory = new char[numberOfBytesRegion];
memcpy(tempmemory,buffer,numberOfBytesRegion);
if(this->GetComponentType() == FLOAT)
{
itk::ByteSwapper<float>::SwapRangeFromSystemToLittleEndian(
reinterpret_cast<float *>(tempmemory), numberOfComponents );
reinterpret_cast<float *>(tempmemory), numberOfBytesRegion );
}
int lNbLignes = this->GetIORegion().GetSize()[1];
int lNbColonnes = this->GetIORegion().GetSize()[0];
char* value = new char[numberOfBytesToBeWrite];
unsigned long cpt = 0;
for(int LineNo = lPremiereLigne;LineNo <lPremiereLigne + lNbLignes; LineNo++ )
{
for( unsigned long i=0 ; i < numberOfBytesToBeWrite ; i = i+ 2 * m_NbOctetPixel )
{
memcpy((void*)(&(value[i])),(const void*)(&(tempmemory[cpt])),(size_t)( 2* m_NbOctetPixel) );
cpt += 2*m_NbOctetPixel;
}
unsigned long numberOfBytesPerLines = 2 * lNbColonnes * m_NbOctetPixel;
unsigned long headerLength = ONERA_HEADER_LENGTH + 4 + numberOfBytesPerLines;
unsigned long offset;
offset = headerLength + numberOfBytesPerLines * LineNo;
offset += m_NbOctetPixel * lPremiereColonne;
m_Datafile.seekg(offset, std::ios::beg);
m_Datafile.write( static_cast<char *>( value ), numberOfBytesToBeWrite );
numberOfBytesWrite = m_Datafile.gcount();
m_Datafile.seekg(offset, std::ios::end);
}
offset = headerLength + numberOfBytesPerLines;
m_Datafile.seekg(offset, std::ios::beg);
m_Datafile.write( static_cast<const char *>(tempmemory) , numberOfBytes );
delete [] value;
delete [] tempmemory;
}
void ONERAImageIO::WriteImageInformation()
......@@ -504,7 +536,7 @@ void ONERAImageIO::WriteImageInformation()
m_Headerfile << "# [dans ordre LSBfirst = big-endian]" << std::endl;
std::string sPixelType("cmplx_real_4");
if(m_PixelType == COMPLEX && m_ComponentType == FLOAT)
if( (this->GetPixelType() == COMPLEX) && (m_ComponentType == FLOAT) )
{
sPixelType = "cmplx_real_4";
}
......
......@@ -128,7 +128,8 @@ private:
/** Nombre d'octets par pixel */
int m_NbOctetPixel;
int m_NbOctetPixel;
bool m_FlagWriteImageInformation;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment