Skip to content
Snippets Groups Projects
Commit f021d7ae authored by Mathieu Deltorre's avatar Mathieu Deltorre
Browse files

*Ajout static cast pour convertir un pixel 1 composante vers 1 pixel 3 composantes (RGB)

parent dec1c08a
Branches
Tags
No related merge requests found
...@@ -92,39 +92,36 @@ int otbImageToSIFTKeyPointSetFilter(int argc, char * argv[]) ...@@ -92,39 +92,36 @@ int otbImageToSIFTKeyPointSetFilter(int argc, char * argv[])
ImageType::IndexType index = iterOutput.GetIndex(); ImageType::IndexType index = iterOutput.GetIndex();
ImageType::PixelType grayPix = reader->GetOutput()->GetPixel(index); ImageType::PixelType grayPix = reader->GetOutput()->GetPixel(index);
OutputImageType::PixelType rgbPixel; OutputImageType::PixelType rgbPixel;
rgbPixel.SetRed( grayPix ); rgbPixel.SetRed( static_cast<unsigned char>(grayPix) );
rgbPixel.SetGreen( grayPix ); rgbPixel.SetGreen( static_cast<unsigned char>(grayPix) );
rgbPixel.SetBlue( grayPix ); rgbPixel.SetBlue( static_cast<unsigned char>(grayPix) );
iterOutput.Set(rgbPixel); iterOutput.Set(rgbPixel);
} }
if( filter->GetOutput()->GetNumberOfPoints()>0 ) PointsIteratorType pIt = filter->GetOutput()->GetPoints()->Begin();
PointDataIteratorType pdIt = filter->GetOutput()->GetPointData()->Begin();
while( pIt!=filter->GetOutput()->GetPoints()->End() &&
pdIt!=filter->GetOutput()->GetPointData()->End() )
{ {
PointsIteratorType pIt = filter->GetOutput()->GetPoints()->Begin(); ImageType::IndexType index;
PointDataIteratorType pdIt = filter->GetOutput()->GetPointData()->Begin(); reader->GetOutput()->TransformPhysicalPointToIndex(pIt.Value(),index);
while( pIt!=filter->GetOutput()->GetPoints()->End() && outfile<<"Point: "<<pIt.Value()<<", Index: "<<index \
pdIt!=filter->GetOutput()->GetPointData()->End() ) << " Octave: " << pdIt.Value()[0] \
{ << " Scale: " << pdIt.Value()[1] << std::endl;
ImageType::IndexType index;
reader->GetOutput()->TransformPhysicalPointToIndex(pIt.Value(),index); OutputImageType::PixelType keyPixel;
outfile<<"Point: "<<pIt.Value()<<", Index: "<<index \ keyPixel.SetRed(0);
<< " Octave: " << pdIt.Value()[0] \ keyPixel.SetGreen(255);
<< " Scale: " << pdIt.Value()[1] << std::endl; keyPixel.SetBlue(0);
OutputImageType::PixelType keyPixel; outputImage->SetPixel(index,keyPixel);
keyPixel.SetRed(0); outputImage->SetPixel(index+t,keyPixel);
keyPixel.SetGreen(255); outputImage->SetPixel(index+b,keyPixel);
keyPixel.SetBlue(0); outputImage->SetPixel(index+l,keyPixel);
outputImage->SetPixel(index+r,keyPixel);
outputImage->SetPixel(index,keyPixel); ++pIt;
outputImage->SetPixel(index+t,keyPixel); ++pdIt;
outputImage->SetPixel(index+b,keyPixel);
outputImage->SetPixel(index+l,keyPixel);
outputImage->SetPixel(index+r,keyPixel);
++pIt;
++pdIt;
}
} }
outfile.close(); outfile.close();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment