Page MenuHomePhabricator

offset_correction.patch

Authored By
ritter
Aug 12 2010, 10:14 AM
Size
9 KB
Referenced Files
None
Subscribers
None

offset_correction.patch

Index: Modules/MitkExt/Algorithms/mitkContourUtils.cpp
===================================================================
--- Modules/MitkExt/Algorithms/mitkContourUtils.cpp (revision 25419)
+++ Modules/MitkExt/Algorithms/mitkContourUtils.cpp (working copy)
@@ -47,7 +47,7 @@
for (int i = 0; i < 3; ++i) currentPointIn3D[i] = currentPointIn3DITK[i];
Point3D projectedPointIn2D;
- projectedPointIn2D.Fill(0.5);
+ projectedPointIn2D.Fill(0.0);
sliceGeometry->WorldToIndex( currentPointIn3D, projectedPointIn2D );
MITK_DEBUG << "world point " << currentPointIn3D << " in index is " << projectedPointIn2D;
@@ -104,8 +104,8 @@
iter != pointsIn2D->end();
++iter, ++index )
{
- picContour[ 2 * index + 0 ] = static_cast<mitkIpInt4_t>( (*iter)[0] );
- picContour[ 2 * index + 1 ] = static_cast<mitkIpInt4_t>( (*iter)[1] );
+ picContour[ 2 * index + 0 ] = static_cast<mitkIpInt4_t>( (*iter)[0] + 0.5);
+ picContour[ 2 * index + 1 ] = static_cast<mitkIpInt4_t>( (*iter)[1] + 0.5);
MITK_DEBUG << "mitk 2d [" << (*iter)[0] << ", " << (*iter)[1] << "] pic [" << picContour[ 2*index+0] << ", " << picContour[ 2*index+1] << "]";
}
Index: Modules/MitkExt/Algorithms/mitkCorrectorAlgorithm.cpp
===================================================================
--- Modules/MitkExt/Algorithms/mitkCorrectorAlgorithm.cpp (revision 25419)
+++ Modules/MitkExt/Algorithms/mitkCorrectorAlgorithm.cpp (working copy)
@@ -154,8 +154,8 @@
iter != pointsIn2D->end();
++iter, ++index )
{
- _points[ 2 * index + 0 ] = static_cast<mitkIpInt4_t>( (*iter)[0] - 0.5);
- _points[ 2 * index + 1 ] = static_cast<mitkIpInt4_t>( (*iter)[1] - 0.5);
+ _points[ 2 * index + 0 ] = static_cast<mitkIpInt4_t>( (*iter)[0] + 1.0 );
+ _points[ 2 * index + 1 ] = static_cast<mitkIpInt4_t>( (*iter)[1] + 1.0 );
}
// store ofsets of the drawn line in array
Index: Modules/MitkExt/Interactions/mitkPaintbrushTool.cpp
===================================================================
--- Modules/MitkExt/Interactions/mitkPaintbrushTool.cpp (revision 25419)
+++ Modules/MitkExt/Interactions/mitkPaintbrushTool.cpp (working copy)
@@ -143,7 +143,7 @@
newPoint[2] = 0.0;
MITK_DEBUG << "(" << newPoint[0] << ", " << newPoint[1] << ")" << std::endl;
- contourInImageIndexCoordinates->AddVertex( newPoint + 0.5 );
+ contourInImageIndexCoordinates->AddVertex( newPoint );
}
free(contourPoints);
@@ -210,8 +210,8 @@
Point3D worldCoordinates = positionEvent->GetWorldPosition();
Point3D indexCoordinates;
image->GetGeometry()->WorldToIndex( worldCoordinates, indexCoordinates );
- MITK_DEBUG << "Mouse at W " << worldCoordinates << std::endl;
- MITK_DEBUG << "Mouse at I " << indexCoordinates << std::endl;
+ MITK_INFO << "Mouse at W " << worldCoordinates << std::endl;
+ MITK_INFO << "Mouse at I " << indexCoordinates << std::endl;
unsigned int firstDimension(0);
unsigned int secondDimension(1);
@@ -235,13 +235,13 @@
// round to nearest voxel center (abort if this hasn't changed)
if ( m_Size % 2 == 0 ) // even
{
- indexCoordinates[firstDimension] = ROUND( indexCoordinates[firstDimension] );
- indexCoordinates[secondDimension] = ROUND( indexCoordinates[secondDimension] );
+ indexCoordinates[firstDimension] = ROUND( indexCoordinates[firstDimension] + 0.5 );
+ indexCoordinates[secondDimension] = ROUND( indexCoordinates[secondDimension] + 0.5 );
}
else // odd
{
- indexCoordinates[firstDimension] = ROUND( indexCoordinates[firstDimension] - 0.5 ) + 0.5;
- indexCoordinates[secondDimension] = ROUND( indexCoordinates[secondDimension] - 0.5 ) + 0.5;
+ indexCoordinates[firstDimension] = ROUND( indexCoordinates[firstDimension] ) ;//+ 0.5;
+ indexCoordinates[secondDimension] = ROUND( indexCoordinates[secondDimension] );// + 0.5;
}
static Point3D lastPos; // uninitialized: if somebody finds out how this can be initialized in a one-liner, tell me
@@ -257,11 +257,11 @@
}
else
{
- MITK_DEBUG << "." << std::flush;
+ MITK_INFO << "." << std::flush;
return false;
}
- MITK_DEBUG << "Mouse at C " << indexCoordinates;
+ MITK_INFO << "Mouse at C " << indexCoordinates;
Contour::Pointer contour = Contour::New();
contour->Initialize();
@@ -271,7 +271,7 @@
point[0] += indexCoordinates[ firstDimension ];
point[1] += indexCoordinates[ secondDimension ];
- MITK_DEBUG << "Contour point " << point;
+ MITK_INFO << "Contour point " << point;
contour->AddVertex( point );
}
@@ -298,6 +298,11 @@
for (unsigned int index = 0; index < contour->GetNumberOfPoints(); ++index)
{
Point3D point = contour->GetPoints()->ElementAt(index);
+ if ( m_Size % 2 != 0 ) // even
+ {
+ point[0] += 0.5;
+ point[1] += 0.5;
+ }
displayContour->AddVertex( point );
}
Index: Modules/MitkExt/Interactions/mitkRegionGrowingTool.cpp
===================================================================
--- Modules/MitkExt/Interactions/mitkRegionGrowingTool.cpp (revision 25419)
+++ Modules/MitkExt/Interactions/mitkRegionGrowingTool.cpp (working copy)
@@ -524,7 +524,7 @@
newPoint[1] = contourPoints[ 2 * index + 1];
newPoint[2] = 0;
- contourInImageIndexCoordinates->AddVertex( newPoint + 0.5 );
+ contourInImageIndexCoordinates->AddVertex( newPoint );
}
free(contourPoints);
Index: Modules/MitkExt/Interactions/mitkSegTool2D.cpp
===================================================================
--- Modules/MitkExt/Interactions/mitkSegTool2D.cpp (revision 25419)
+++ Modules/MitkExt/Interactions/mitkSegTool2D.cpp (working copy)
@@ -140,7 +140,7 @@
Point3D indexPoint;
imageGeometry->WorldToIndex( projectedPoint, indexPoint );
- affectedSlice = ROUND( indexPoint[affectedDimension]-0.5 );
+ affectedSlice = ROUND( indexPoint[affectedDimension] );
MITK_DEBUG << "indexPoint " << indexPoint << " affectedDimension " << affectedDimension << " affectedSlice " << affectedSlice;
// check if this index is still within the image
Index: Modules/MitkExt/Interactions/mitkSetRegionTool.cpp
===================================================================
--- Modules/MitkExt/Interactions/mitkSetRegionTool.cpp (revision 25419)
+++ Modules/MitkExt/Interactions/mitkSetRegionTool.cpp (working copy)
@@ -59,17 +59,14 @@
// if click was outside the image, don't continue
const Geometry3D* sliceGeometry = workingSlice->GetGeometry();
- Point3D mprojectedPointIn2D;
- sliceGeometry->WorldToIndex( positionEvent->GetWorldPosition(), mprojectedPointIn2D );
- if ( !sliceGeometry->IsIndexInside( mprojectedPointIn2D ) )
+ itk::Index<2> projectedPointIn2D;
+ sliceGeometry->WorldToIndex( positionEvent->GetWorldPosition(), projectedPointIn2D );
+ if ( !sliceGeometry->IsIndexInside( projectedPointIn2D ) )
{
MITK_ERROR << "point apparently not inside segmentation slice" << std::endl;
return false; // can't use that as a seed point
}
- itk::Index<2> projectedPointIn2D;
- projectedPointIn2D[0] = static_cast<int>( mprojectedPointIn2D[0] - 0.5 );
- projectedPointIn2D[1] = static_cast<int>( mprojectedPointIn2D[1] - 0.5 );
-
+
// Convert to ipMITKSegmentationTYPE (because ipMITKSegmentationGetContour8N relys on that data type)
itk::Image< ipMITKSegmentationTYPE, 2 >::Pointer correctPixelTypeImage;
CastToItkImage( workingSlice, correctPixelTypeImage );
@@ -191,7 +188,7 @@
newPoint[1] = contourPoints[ 2 * index + 1];
newPoint[2] = 0;
- contourInImageIndexCoordinates->AddVertex( newPoint + 0.5 );
+ contourInImageIndexCoordinates->AddVertex( newPoint );
}
m_SegmentationContourInWorldCoordinates = FeedbackContourTool::BackProjectContourFrom2DSlice( workingSlice, contourInImageIndexCoordinates, true ); // true, correct the result from ipMITKSegmentationGetContour8N
@@ -209,14 +206,14 @@
Contour::Pointer contourInImageIndexCoordinates = Contour::New();
contourInImageIndexCoordinates->Initialize();
Point3D newPoint;
- newPoint[0] = 0; newPoint[1] = 0; newPoint[2] = 0.5;
- contourInImageIndexCoordinates->AddVertex( newPoint + 0.5 );
- newPoint[0] = originalPicSlice->n[0]; newPoint[1] = 0; newPoint[2] = 0.5;
- contourInImageIndexCoordinates->AddVertex( newPoint + 0.5 );
- newPoint[0] = originalPicSlice->n[0]; newPoint[1] = originalPicSlice->n[1]; newPoint[2] = 0.5;
- contourInImageIndexCoordinates->AddVertex( newPoint + 0.5 );
- newPoint[0] = 0; newPoint[1] = originalPicSlice->n[1]; newPoint[2] = 0.5;
- contourInImageIndexCoordinates->AddVertex( newPoint + 0.5 );
+ newPoint[0] = 0; newPoint[1] = 0; newPoint[2] = 0.0;
+ contourInImageIndexCoordinates->AddVertex( newPoint );
+ newPoint[0] = originalPicSlice->n[0]; newPoint[1] = 0; newPoint[2] = 0.0;
+ contourInImageIndexCoordinates->AddVertex( newPoint );
+ newPoint[0] = originalPicSlice->n[0]; newPoint[1] = originalPicSlice->n[1]; newPoint[2] = 0.0;
+ contourInImageIndexCoordinates->AddVertex( newPoint );
+ newPoint[0] = 0; newPoint[1] = originalPicSlice->n[1]; newPoint[2] = 0.0;
+ contourInImageIndexCoordinates->AddVertex( newPoint );
m_WholeImageContourInWorldCoordinates = FeedbackContourTool::BackProjectContourFrom2DSlice( workingSlice, contourInImageIndexCoordinates, true ); // true, correct the result from ipMITKSegmentationGetContour8N

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
552
Default Alt Text
offset_correction.patch (9 KB)