Page MenuHomePhabricator

Patch_GeometriesAndSegmentationTools.patch

Authored By
graser
Nov 4 2010, 3:39 PM
Size
12 KB
Referenced Files
None
Subscribers
None

Patch_GeometriesAndSegmentationTools.patch

This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
Index: Core/Code/DataManagement/mitkGeometry3D.cpp
===================================================================
--- Core/Code/DataManagement/mitkGeometry3D.cpp (revision 26530)
+++ Core/Code/DataManagement/mitkGeometry3D.cpp (working copy)
@@ -623,3 +623,39 @@
mitk::Geometry3D::ResetSubTransforms()
{
}
+
+void
+mitk::Geometry3D::ChangeImageGeometry( const bool isAnImageGeometry )
+{
+ // If Geometry is switched to ImageGeometry, you have to put an offset to the origin, because
+ // imageGeometries origins are pixel-center-based
+ // ... and remove the offset, if you switch an imageGeometry back to a normal geometry
+
+ if(m_ImageGeometry == isAnImageGeometry)
+ return;
+
+ const BoundingBox::BoundsArrayType& boundsarray =
+ this->GetBoundingBox()->GetBounds();
+
+ Point3D originIndex;
+ FillVector3D(originIndex, boundsarray[0], boundsarray[2], boundsarray[4]);
+
+ if(isAnImageGeometry == true)
+ FillVector3D( originIndex,
+ originIndex[0] + 0.5,
+ originIndex[1] + 0.5,
+ originIndex[2] + 0.5 );
+ else
+ FillVector3D( originIndex,
+ originIndex[0] - 0.5,
+ originIndex[1] - 0.5,
+ originIndex[2] - 0.5 );
+
+ Point3D originWorld;
+ originWorld = GetIndexToWorldTransform()
+ ->TransformPoint( originIndex );
+
+ SetOrigin(originWorld);
+
+ this->SetImageGeometry(isAnImageGeometry);
+}
\ No newline at end of file
Index: Core/Code/DataManagement/mitkGeometry3D.h
===================================================================
--- Core/Code/DataManagement/mitkGeometry3D.h (revision 26530)
+++ Core/Code/DataManagement/mitkGeometry3D.h (working copy)
@@ -145,6 +145,11 @@
//## @brief Set the bounding box (in index/unit coordinates) via a double array
virtual void SetFloatBounds(const double bounds[6]);
+
+ /// Changes Geometry Origin, if switching from imageGeometry to normal Geometry (and the other way around)
+ virtual void ChangeImageGeometry( const bool isAnImageGeometry );
+
+
//##Documentation
//## @brief Get the time bounds (in ms)
itkGetConstReferenceMacro(TimeBounds, TimeBounds);
Index: Core/Code/DataManagement/mitkImage.cpp
===================================================================
--- Core/Code/DataManagement/mitkImage.cpp (revision 26530)
+++ Core/Code/DataManagement/mitkImage.cpp (working copy)
@@ -765,6 +765,7 @@
TimeSlicedGeometry::Pointer timeSliceGeometry = TimeSlicedGeometry::New();
timeSliceGeometry->InitializeEvenlyTimed(slicedGeometry, m_Dimensions[3]);
+ timeSliceGeometry->ImageGeometryOn();
SetGeometry(timeSliceGeometry);
@@ -997,6 +998,7 @@
TimeSlicedGeometry::Pointer timeSliceGeometry = TimeSlicedGeometry::New();
timeSliceGeometry->InitializeEvenlyTimed(slicedGeometry, m_Dimensions[3]);
+ timeSliceGeometry->ImageGeometryOn();
SetGeometry(timeSliceGeometry);
@@ -1168,8 +1170,46 @@
void mitk::Image::SetGeometry(Geometry3D* aGeometry3D)
{
- Superclass::SetGeometry(aGeometry3D);
- GetTimeSlicedGeometry()->ImageGeometryOn();
+ /*
+ // Brauch ich nich!! die abfrage wird auch in Geometry3D::ChangeImageGeometry gemacht...
+ if(aGeometry3D->GetImageGeometry())
+ {
+ Superclass::SetGeometry(aGeometry3D);
+ }
+ else
+ {
+ */
+
+ Geometry3D::Pointer geometry3D = static_cast<Geometry3D*>(aGeometry3D->Clone().GetPointer());
+ geometry3D->ChangeImageGeometry(true);
+ Superclass::SetGeometry(geometry3D);
+ assert(GetTimeSlicedGeometry()->GetImageGeometry()==true);
+
+ /*
+ //Das Folgende ist:
+ //virtual void Geometry3D::ChangeImageGeometry(bool);
+ // ChangeImageGeometry(bool) überschrieben in TimeSlicedGeometry und SlicedBasedGeometry:
+ // dort an enthaltene Geometries weiterpropagieren parallel zu SetImageGeometry
+ const BoundingBox::BoundsArrayType& boundsarray =
+ geometry3D->GetBoundingBox()->GetBounds();
+
+ Point3D originIndex;
+ FillVector3D(originIndex, boundsarray[0], boundsarray[2], boundsarray[4]);
+ FillVector3D( originIndex,
+ originIndex[0] + 0.5,
+ originIndex[1] + 0.5,
+ originIndex[2] + 0.5 );
+
+ Point3D originWorld;
+ originWorld = geometry3D->GetIndexToWorldTransform()
+ ->TransformPoint( originIndex );
+
+ geometry3D->SetOrigin(originWorld);
+ geometry3D->ImageGeometryOn();
+ //end of ChangeImageGeometry
+ */
+
+
}
const mitk::Image::HistogramType* mitk::Image::GetScalarHistogram(int t) const
Index: Core/Code/DataManagement/mitkSlicedGeometry3D.cpp
===================================================================
--- Core/Code/DataManagement/mitkSlicedGeometry3D.cpp (revision 26530)
+++ Core/Code/DataManagement/mitkSlicedGeometry3D.cpp (working copy)
@@ -459,6 +459,25 @@
}
}
+void
+mitk::SlicedGeometry3D::ChangeImageGeometry( const bool isAnImageGeometry )
+{
+ Superclass::ChangeImageGeometry( isAnImageGeometry );
+
+ mitk::Geometry3D* geometry;
+
+ unsigned int s;
+ for ( s = 0; s < m_Slices; ++s )
+ {
+ geometry = m_Geometry2Ds[s];
+ if ( geometry!=NULL )
+ {
+ geometry->ChangeImageGeometry( isAnImageGeometry );
+ }
+ }
+}
+
+
bool
mitk::SlicedGeometry3D::IsValidSlice( int s ) const
{
Index: Core/Code/DataManagement/mitkSlicedGeometry3D.h
===================================================================
--- Core/Code/DataManagement/mitkSlicedGeometry3D.h (revision 26530)
+++ Core/Code/DataManagement/mitkSlicedGeometry3D.h (working copy)
@@ -112,6 +112,9 @@
*/
virtual bool SetGeometry2D( mitk::Geometry2D *geometry2D, int s );
+ /// Changes Geometry Origin, if switching from imageGeometry to normal Geometry (and the other way around)
+ virtual void ChangeImageGeometry( const bool isAnImageGeometry );
+
virtual void SetTimeBounds( const mitk::TimeBounds& timebounds );
Index: Core/Code/DataManagement/mitkTimeSlicedGeometry.cpp
===================================================================
--- Core/Code/DataManagement/mitkTimeSlicedGeometry.cpp (revision 26530)
+++ Core/Code/DataManagement/mitkTimeSlicedGeometry.cpp (working copy)
@@ -313,6 +313,22 @@
}
}
+
+void mitk::TimeSlicedGeometry::ChangeImageGeometry(const bool isAnImageGeometry)
+{
+ Superclass::ChangeImageGeometry(isAnImageGeometry);
+
+ mitk::Geometry3D* geometry3d;
+ unsigned int t;
+ for(t=0; t<m_TimeSteps; ++t)
+ {
+ geometry3d = m_Geometry3Ds[t];
+ if(geometry3d!=NULL)
+ geometry3d->ChangeImageGeometry(isAnImageGeometry);
+ }
+}
+
+
void mitk::TimeSlicedGeometry::SetEvenlyTimed(bool on)
{
m_EvenlyTimed = on;
Index: Core/Code/DataManagement/mitkTimeSlicedGeometry.h
===================================================================
--- Core/Code/DataManagement/mitkTimeSlicedGeometry.h (revision 26530)
+++ Core/Code/DataManagement/mitkTimeSlicedGeometry.h (working copy)
@@ -78,6 +78,9 @@
//## @brief Set the Geometry3D for time @a t
virtual bool SetGeometry3D(mitk::Geometry3D* geometry3D, int t);
+ /// Changes Geometry Origin, if switching from imageGeometry to normal Geometry (and the other way around)
+ virtual void ChangeImageGeometry( const bool isAnImageGeometry );
+
//##Documentation
//## @brief Get the Geometry3D at time @a t
virtual mitk::Geometry3D* GetGeometry3D(int t) const;
Index: Modules/MitkExt/Algorithms/mitkContourUtils.cpp
===================================================================
--- Modules/MitkExt/Algorithms/mitkContourUtils.cpp (revision 26530)
+++ Modules/MitkExt/Algorithms/mitkContourUtils.cpp (working copy)
@@ -49,7 +49,7 @@
Point3D projectedPointIn2D;
projectedPointIn2D.Fill(0.0);
sliceGeometry->WorldToIndex( currentPointIn3D, projectedPointIn2D );
- MITK_DEBUG << "world point " << currentPointIn3D << " in index is " << projectedPointIn2D;
+ MITK_INFO << "world point " << currentPointIn3D << " in index is " << projectedPointIn2D;
if ( !sliceGeometry->IsIndexInside( projectedPointIn2D ) && constrainToInside )
{
@@ -81,7 +81,7 @@
Point3D worldPointIn3D;
worldPointIn3D.Fill(0.0);
sliceGeometry->IndexToWorld( currentPointIn2D, worldPointIn3D );
- MITK_DEBUG << "index " << currentPointIn2D << " world " << worldPointIn3D << std::endl;
+ MITK_INFO << "index " << currentPointIn2D << " world " << worldPointIn3D << std::endl;
worldContour->AddVertex( worldPointIn3D );
}
@@ -104,9 +104,9 @@
iter != pointsIn2D->end();
++iter, ++index )
{
- 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] << "]";
+ picContour[ 2 * index + 0 ] = static_cast<mitkIpInt4_t>( (*iter)[0] + 1.0 );
+ picContour[ 2 * index + 1 ] = static_cast<mitkIpInt4_t>( (*iter)[1] + 1.0 );
+ MITK_INFO << "mitk 2d [" << (*iter)[0] << ", " << (*iter)[1] << "] pic [" << picContour[ 2*index+0] << ", " << picContour[ 2*index+1] << "]";
}
assert( sliceImage->GetSliceData() );
Index: Modules/MitkExt/Algorithms/mitkCorrectorAlgorithm.cpp
===================================================================
--- Modules/MitkExt/Algorithms/mitkCorrectorAlgorithm.cpp (revision 26530)
+++ 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] + 1.0 );
- _points[ 2 * index + 1 ] = static_cast<mitkIpInt4_t>( (*iter)[1] + 1.0 );
+ _points[ 2 * index + 0 ] = static_cast<mitkIpInt4_t>( (*iter)[0] + 0.5 );
+ _points[ 2 * index + 1 ] = static_cast<mitkIpInt4_t>( (*iter)[1] + 0.5 );
}
// store ofsets of the drawn line in array
Index: Modules/MitkExt/Interactions/mitkPaintbrushTool.cpp
===================================================================
--- Modules/MitkExt/Interactions/mitkPaintbrushTool.cpp (revision 26530)
+++ Modules/MitkExt/Interactions/mitkPaintbrushTool.cpp (working copy)
@@ -237,13 +237,13 @@
// round to nearest voxel center (abort if this hasn't changed)
if ( m_Size % 2 == 0 ) // even
{
- indexCoordinates[firstDimension] = ROUND( indexCoordinates[firstDimension] + 0.5 );
+ indexCoordinates[firstDimension] = ROUND( indexCoordinates[firstDimension] + 0.5);
indexCoordinates[secondDimension] = ROUND( indexCoordinates[secondDimension] + 0.5 );
}
else // odd
{
- indexCoordinates[firstDimension] = ROUND( indexCoordinates[firstDimension] ) ;//+ 0.5;
- indexCoordinates[secondDimension] = ROUND( indexCoordinates[secondDimension] );// + 0.5;
+ indexCoordinates[firstDimension] = ROUND( indexCoordinates[firstDimension] ) ;
+ indexCoordinates[secondDimension] = ROUND( indexCoordinates[secondDimension] ) ;
}
static Point3D lastPos; // uninitialized: if somebody finds out how this can be initialized in a one-liner, tell me
@@ -300,11 +300,11 @@
for (unsigned int index = 0; index < contour->GetNumberOfPoints(); ++index)
{
Point3D point = contour->GetPoints()->ElementAt(index);
- if ( m_Size % 2 != 0 ) // even
+ /*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 26530)
+++ Modules/MitkExt/Interactions/mitkRegionGrowingTool.cpp (working copy)
@@ -524,7 +524,7 @@
newPoint[1] = contourPoints[ 2 * index + 1];
newPoint[2] = 0;
- contourInImageIndexCoordinates->AddVertex( newPoint );
+ contourInImageIndexCoordinates->AddVertex( newPoint + 0.5);
}
free(contourPoints);
Index: Modules/MitkExt/Interactions/mitkSetRegionTool.cpp
===================================================================
--- Modules/MitkExt/Interactions/mitkSetRegionTool.cpp (revision 26530)
+++ Modules/MitkExt/Interactions/mitkSetRegionTool.cpp (working copy)
@@ -188,7 +188,7 @@
newPoint[1] = contourPoints[ 2 * index + 1];
newPoint[2] = 0;
- contourInImageIndexCoordinates->AddVertex( newPoint );
+ contourInImageIndexCoordinates->AddVertex( newPoint - 0.5 );
}
m_SegmentationContourInWorldCoordinates = 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
581
Default Alt Text
Patch_GeometriesAndSegmentationTools.patch (12 KB)

Event Timeline

Patch for Geometries and Segmentation Tools