Hi !
I try to create & to write an image, but I have no data in output image and
the warning message :
"ImageFileWriter could not get the source process object. Progress report
might be buggy."
I want to create an image with same geo-metadata of an input vector image.
I fill all pixels to value 0, except for some (value 1).
Thanks for your help,
Best regards,
Maxime
My code :
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
const unsigned int Dimension = 2;
typedef float Pixel;
typedef otb::VectorImage<Pixel, Dimension> ImageIn;
typedef otb::Image<Pixel, Dimension> ImageOut;
typedef otb::ImageFileReader<ImageIn> ReaderType;
typedef otb::ImageFileWriter<ImageOut> WriterType;
int main(int argc, char *argv[]) {
const char * outputFilename = argv[1];
const char * inputFilename = argv[2];
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFilename);
reader->UpdateOutputInformation();
reader->Update();
ImageIn::Pointer imageIn = reader->GetOutput();
const ImageIn::SpacingType& inputSpacing = imageIn->GetSpacing();
const ImageIn::PointType& inputOrigin = imageIn->GetOrigin();
ImageIn::RegionType region = imageIn->GetLargestPossibleRegion();
ImageOut::Pointer imageOut = ImageOut::New();
imageOut->SetRegions(region);
imageOut->SetSpacing(inputSpacing);
imageOut->SetOrigin(inputOrigin);
imageOut->Allocate();
imageOut->FillBuffer(0);
while (/*some condition*/) {
float value = 1;
int x = // some value
int y = // some value
ImageOut::PixelType pixelValue = value;
ImageOut::IndexType pixelIndex;
pixelIndex[0] = x;
pixelIndex[1] = y;
imageOut->SetPixel(pixelIndex, pixelValue);
}
writer->SetFileName(outputFilename);
writer->SetInput(imageOut);
try {
writer->Update();
}
catch (itk::ExceptionObject& e) {
std::cerr << e << std::endl;
}
return EXIT_SUCCESS;
}
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups
"otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.