Skip to content
Snippets Groups Projects
Commit a93f4c3d authored by Julien Michel's avatar Julien Michel
Browse files

Maj disparity map: correction de l'exemple et des baselines

parent a4f1c308
Branches
Tags
No related merge requests found
......@@ -152,7 +152,7 @@ DisparityMapEstimationMethod<TFixedImage,TMovingImage,TPointSet>
PointsIterator end = points->End();
unsigned int dataId = 0;
otbMsgDebugMacro(<<"Starting registration");
otbMsgDevMacro(<<"Starting registration");
/// Iterate through the point set
while(pointIterator!= end)
......@@ -170,19 +170,25 @@ DisparityMapEstimationMethod<TFixedImage,TMovingImage,TPointSet>
fixedExtractor->SetStartY(static_cast<unsigned long>(p[1]-m_ExploSize[1]));
fixedExtractor->SetSizeX(static_cast<unsigned long>(2*m_ExploSize[0]+1));
fixedExtractor->SetSizeY(static_cast<unsigned long>(2*m_ExploSize[1]+1));
otbMsgDebugMacro(<<"Point id: "<<dataId);
otbMsgDebugMacro(<<"Fixed region: origin("<<p[0]-m_ExploSize[0]<<", "<<p[1]-m_ExploSize[1]<<") size("<<2*m_ExploSize[0]+1<<", "<<2*m_ExploSize[1]+1<<")");
otbMsgDevMacro(<<"Point id: "<<dataId);
otbMsgDevMacro(<<"Fixed region: origin("<<p[0]-m_ExploSize[0]<<", "<<p[1]-m_ExploSize[1]<<") size("<<2*m_ExploSize[0]+1<<", "<<2*m_ExploSize[1]+1<<")");
// Moving extractor setup
movingExtractor->SetStartX(static_cast<unsigned long>(p[0]-m_WinSize[0]));
movingExtractor->SetStartY(static_cast<unsigned long>(p[1]-m_WinSize[1]));
movingExtractor->SetSizeX(static_cast<unsigned long>(2*m_WinSize[0]+1));
movingExtractor->SetSizeY(static_cast<unsigned long>(2*m_WinSize[1]+1));
otbMsgDebugMacro(<<"Moving region: origin("<<p[0]-m_WinSize[0]<<", "<<p[1]-m_WinSize[1]<<") size("<<2*m_WinSize[0]+1<<", "<<2*m_WinSize[1]+1<<")");
otbMsgDevMacro(<<"Moving region: origin("<<p[0]-m_WinSize[0]<<", "<<p[1]-m_WinSize[1]<<") size("<<2*m_WinSize[0]+1<<", "<<2*m_WinSize[1]+1<<")");
// update the extractors
fixedExtractor->Update();
movingExtractor->Update();
// std::cout<<"Fixed extract origin: "<<fixedExtractor->GetOutput()->GetOrigin()<<std::endl;
// std::cout<<"Fixed extract spacing: "<<fixedExtractor->GetOutput()->GetSpacing()<<std::endl;
// std::cout<<"Moving extract origin: "<<movingExtractor->GetOutput()->GetOrigin()<<std::endl;
// std::cout<<"Moving extract spacing: "<<movingExtractor->GetOutput()->GetSpacing()<<std::endl;
// typedef otb::StreamingImageFileWriter<FixedImageType> FixedWriterType;
// typedef otb::StreamingImageFileWriter<FixedImageType> FixedWriterType;
// typedef otb::StreamingImageFileWriter<MovingImageType> MovingWriterType;
// typename FixedWriterType::Pointer fwriter = FixedWriterType::New();
......@@ -225,18 +231,21 @@ DisparityMapEstimationMethod<TFixedImage,TMovingImage,TPointSet>
// Computing moving image point
typename FixedImageType::PointType inputPoint,outputPoint;
typename FixedImageType::IndexType inputIndex;
// ensure that we have the right coord rep type
inputPoint[0] = static_cast<double>(p[0]);
inputPoint[1] = static_cast<double>(p[1]);
inputIndex[0] = static_cast<unsigned int>(p[0]);
inputIndex[1] = static_cast<unsigned int>(p[1]);
fixed->TransformIndexToPhysicalPoint(inputIndex,inputPoint);
m_Transform->SetParameters(finalParameters);
outputPoint = m_Transform->TransformPoint(inputPoint);
otbMsgDebugMacro(<<"Metric value: "<<value);
otbMsgDebugMacro(<<"Transform parameters: "<<finalParameters);
otbMsgDebugMacro(<<"Deformation: ("<<outputPoint[0]-inputPoint[0]<<", "<<outputPoint[1]-inputPoint[1]<<")");
otbMsgDebugMacro(<<"Final parameters: "<<finalParameters);
otbMsgDevMacro(<<"Metric value: "<<value);
otbMsgDevMacro(<<"Transform parameters: "<<finalParameters);
otbMsgDevMacro(<<"Deformation: ("<<outputPoint[0]-inputPoint[0]<<", "<<outputPoint[1]-inputPoint[1]<<")");
otbMsgDevMacro(<<"Final parameters: "<<finalParameters);
ParametersType data(finalParameters.GetSize()+3);
......
......@@ -107,6 +107,7 @@ PointSetToDeformationFieldGenerator<TPointSet, TDeformationField>
p[1]=it.Value()[1];
if(vcl_abs(this->GetPointSet()->GetPointData()->GetElement(j)[0])>=m_MetricThreshold)
{
distanceVector.push_back(EuclideanDistance(index,p));
sortVector.push_back(i);
indexVector.push_back(j);
......@@ -114,10 +115,9 @@ PointSetToDeformationFieldGenerator<TPointSet, TDeformationField>
}
++j;
}
ComparisonFunctorType comp;
comp.SetDistanceVector(distanceVector);
comp.SetDistanceVector(distanceVector);
sort(sortVector.begin(),sortVector.end(),comp);
// building output vector
......
File added
File added
......@@ -24,12 +24,12 @@ ADD_TEST(SimpleDisparityMapEstimationExampleTest ${EXE_TESTS}
${BASELINE}/deformationFieldOutput.png
${TEMP}/deformationFieldOutput.png
${BASELINE}/resampledMovingOutput.png
${TEMP}/resampledFixedOutput.png
${TEMP}/resampledMovingOutput.png
SimpleDisparityMapEstimationExampleTest
${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif
${INPUTDATA}/ROI_IKO_PAN_LesHalles_warped.tif
${INPUTDATA}/ROI_IKO_PAN_LesHalles_pos_spacing.tif
${INPUTDATA}/ROI_IKO_PAN_LesHalles_warped_pos_spacing.tif
${TEMP}/deformationFieldOutput.png
${TEMP}/resampledMovingOutput.png
${TEMP}/resampledMovingOutput.png
100 10 15 10 10 250 0.9
)
......
......@@ -195,6 +195,7 @@ int main (int argc, char* argv[])
typedef otb::DisparityMapEstimationMethod<ImageType,
ImageType,PointSetType> DMEstimationType;
typedef DMEstimationType::SizeType SizeType;
// Software Guide : EndCodeSnippet
......@@ -236,15 +237,15 @@ int main (int argc, char* argv[])
// Software Guide : BeginCodeSnippet
ImageType::SizeType fixedSize =
SizeType fixedSize =
fixedReader->GetOutput()->GetLargestPossibleRegion().GetSize();
unsigned int NumberOfXNodes = (fixedSize[0]-2*atoi(argv[6])-1)
unsigned int NumberOfXNodes = (fixedSize[0]-2*atoi(argv[7])-1)
/atoi(argv[5]);
unsigned int NumberOfYNodes = (fixedSize[1]-2*atoi(argv[6])-1)
unsigned int NumberOfYNodes = (fixedSize[1]-2*atoi(argv[7])-1)
/atoi(argv[6]);
ImageType::IndexType firstNodeIndex;
firstNodeIndex[0] = atoi(argv[7]);
firstNodeIndex[0] = atoi(argv[7]);
firstNodeIndex[1] = atoi(argv[7]);
PointSetType::Pointer nodes = PointSetType::New();
......@@ -316,6 +317,13 @@ int main (int argc, char* argv[])
dmestimator->SetInterpolator(interpolator);
dmestimator->SetMetric(metric);
SizeType windowSize, explorationSize;
explorationSize.Fill(atoi(argv[7]));
windowSize.Fill(atoi(argv[8]));
dmestimator->SetWinSize(windowSize);
dmestimator->SetExploSize(explorationSize);
// Software Guide : EndCodeSnippet
......@@ -483,6 +491,8 @@ int main (int argc, char* argv[])
warper->SetInput(movingReader->GetOutput());
warper->SetDeformationField(generator->GetOutput());
warper->SetOutputOrigin(fixedReader->GetOutput()->GetOrigin());
warper->SetOutputSpacing(fixedReader->GetOutput()->GetSpacing());
// Software Guide : EndCodeSnippet
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment