21 #ifndef otbPhysicalToRPCSensorModelImageFilter_hxx
22 #define otbPhysicalToRPCSensorModelImageFilter_hxx
29 template <
class TImage>
38 m_GCPsToSensorModelFilter = GCPsToSensorModelType::New();
45 m_OutputInformationGenerated =
false;
48 template <
class TImage>
53 template <
class TImage>
56 Superclass::GenerateOutputInformation();
58 if (!m_OutputInformationGenerated)
67 rsTransform->SetInputImageMetadata(&(input->GetImageMetadata()));
68 rsTransform->InstantiateTransform();
71 typename ImageType::SizeType size = input->GetLargestPossibleRegion().GetSize();
72 double gridSpacingX = size[0] / m_GridSize[0];
73 double gridSpacingY = size[1] / m_GridSize[1];
75 for (
unsigned int px = 0; px < m_GridSize[0]; ++px)
77 for (
unsigned int py = 0; py < m_GridSize[1]; ++py)
79 PointType inputPoint = input->GetOrigin();
80 inputPoint[0] += (px * gridSpacingX + 0.5) * input->GetSignedSpacing()[0];
81 inputPoint[1] += (py * gridSpacingY + 0.5) * input->GetSignedSpacing()[1];
82 PointType outputPoint = rsTransform->TransformPoint(inputPoint);
83 m_GCPsToSensorModelFilter->AddGCP(inputPoint, outputPoint);
87 m_GCPsToSensorModelFilter->SetInput(input);
88 m_GCPsToSensorModelFilter->UpdateOutputInformation();
90 otbGenericMsgDebugMacro(<<
"RPC model estimated. RMS ground error: " << m_GCPsToSensorModelFilter->GetRMSGroundError()
91 <<
", Mean error: " << m_GCPsToSensorModelFilter->GetMeanError());
94 this->GetOutput()->SetImageMetadata(m_GCPsToSensorModelFilter->GetOutput()->GetImageMetadata());
97 m_OutputInformationGenerated =
true;
101 template <
class TImage>
104 Superclass::Modified();
105 m_OutputInformationGenerated =
false;
108 template <
class TImage>
111 Superclass::PrintSelf(os, indent);