Page MenuHomePhabricator

bug4017.diff

Authored By
xplanes
May 14 2010, 4:31 PM
Size
6 KB
Referenced Files
None
Subscribers
None

bug4017.diff

Index: Modules/MitkExt/Algorithms/mitkExtractImageFilter.cpp
===================================================================
--- Modules/MitkExt/Algorithms/mitkExtractImageFilter.cpp (revision 21081)
+++ Modules/MitkExt/Algorithms/mitkExtractImageFilter.cpp (working copy)
@@ -55,7 +55,9 @@
else if (input->GetDimension() == 2)
{
Image::Pointer resultImage = ImageToImageFilter::GetOutput();
- resultImage = const_cast<Image*>(input.GetPointer());
+ Image* inputImage = const_cast<Image*>(input.GetPointer());
+ resultImage->Initialize( inputImage );
+ resultImage->SetPicVolume( mitkIpPicClone(inputImage->GetVolumeData(0)->GetPicDescriptor()) );
ImageToImageFilter::SetNthOutput( 0, resultImage );
return;
}
Index: Modules/MitkExt/Algorithms/mitkOverwriteSliceImageFilter.cpp
===================================================================
--- Modules/MitkExt/Algorithms/mitkOverwriteSliceImageFilter.cpp (revision 21081)
+++ Modules/MitkExt/Algorithms/mitkOverwriteSliceImageFilter.cpp (working copy)
@@ -80,7 +80,8 @@
break;
}
- if ( slice->GetDimension() < 2 || input->GetDimension() > 4 ||
+ if ( slice->GetDimension() != 2 ||
+ ( input->GetDimension() != 2 && input->GetDimension() != 3 && input->GetDimension() != 4 ) ||
slice->GetDimension(0) != input->GetDimension(m_Dimension0) ||
slice->GetDimension(1) != input->GetDimension(m_Dimension1) ||
m_SliceIndex >= input->GetDimension(m_SliceDimension)
@@ -110,7 +111,14 @@
//MITK_INFO << "Overwriting slice " << m_SliceIndex << " in dimension " << m_SliceDimension << " at time step " << m_TimeStep << std::endl;
// this will do a long long if/else to find out both pixel types
- AccessFixedDimensionByItk( input3D, ItkImageSwitch, 3 );
+ if ( input->GetDimension() >= 3 )
+ {
+ AccessFixedDimensionByItk( input3D, ItkImageSwitch, 3 );
+ }
+ else
+ {
+ AccessFixedDimensionByItk( input3D, ItkImageSwitch, 2 );
+ }
SegmentationInterpolationController* interpolator = SegmentationInterpolationController::InterpolatorForImage( input );
if (interpolator)
@@ -185,8 +193,11 @@
typename VolumeImageType::RegionType sliceInVolumeRegion;
sliceInVolumeRegion = outputImage->GetLargestPossibleRegion();
- sliceInVolumeRegion.SetSize( m_SliceDimension, 1 ); // just one slice
- sliceInVolumeRegion.SetIndex( m_SliceDimension, m_SliceIndex ); // exactly this slice, please
+ if ( outputImage->GetImageDimension( ) == 3 )
+ {
+ sliceInVolumeRegion.SetSize( m_SliceDimension, 1 ); // just one slice
+ sliceInVolumeRegion.SetIndex( m_SliceDimension, m_SliceIndex ); // exactly this slice, please
+ }
OutputSliceIteratorType outputIterator( outputImage, sliceInVolumeRegion );
outputIterator.SetFirstDirection(m_Dimension0);
Index: Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp
===================================================================
--- Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp (revision 21081)
+++ Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp (working copy)
@@ -294,7 +294,7 @@
mitk::Image::Pointer image = dynamic_cast<mitk::Image*>( node->GetData() );
if (image.IsNotNull())
{
- if (image->GetDimension()>2)
+ if (image->GetDimension()>=2)
{
// ask about the name and organ type of the new segmentation
QmitkNewSegmentationDialog dialog( m_Parent ); // needs a QWidget as parent, "this" is not QWidget
Index: Modules/MitkExt/Controllers/mitkSegmentationInterpolationController.cpp
===================================================================
--- Modules/MitkExt/Controllers/mitkSegmentationInterpolationController.cpp (revision 21081)
+++ Modules/MitkExt/Controllers/mitkSegmentationInterpolationController.cpp (working copy)
@@ -88,7 +88,7 @@
}
if (!segmentation) return;
- if (segmentation->GetDimension() > 4 || segmentation->GetDimension() < 3)
+ if (segmentation->GetDimension() > 4 || segmentation->GetDimension() < 2)
{
itkExceptionMacro("SegmentationInterpolationController needs a 3D-segmentation or 3D+t, not 2D.");
}
@@ -126,7 +126,14 @@
timeSelector->SetTimeNr( timeStep );
timeSelector->UpdateLargestPossibleRegion();
Image::Pointer segmentation3D = timeSelector->GetOutput();
- AccessFixedDimensionByItk_2( segmentation3D, ScanWholeVolume, 3, m_Segmentation, timeStep );
+ if ( segmentation->GetDimension() >= 3 )
+ {
+ AccessFixedDimensionByItk_2( segmentation3D, ScanWholeVolume, 3, m_Segmentation, timeStep );
+ }
+ else
+ {
+ AccessFixedDimensionByItk_2( segmentation3D, ScanWholeVolume, 2, m_Segmentation, timeStep );
+ }
}
//PrintStatus();
@@ -324,6 +331,19 @@
}
}
+template < typename DATATYPE >
+void mitk::SegmentationInterpolationController::ScanWholeVolume( itk::Image<DATATYPE, 2>*, const Image* volume, unsigned int timeStep )
+{
+ if (!volume) return;
+ if ( timeStep >= m_SegmentationCountInSlice.size() ) return;
+
+ DATATYPE* rawVolume = static_cast<DATATYPE*>( const_cast<Image*>(volume)->GetVolumeData(timeStep)->GetData() ); // we again promise not to change anything, we'll just count
+ //DATATYPE* rawSlice = static_cast<DATATYPE*>( volume->GetSliceData(slice)->GetData() ); // TODO THIS wouldn't work. Did I mess up with some internal mitk::Image data structure?
+ DATATYPE* rawSlice = rawVolume;
+
+ ScanChangedSlice<DATATYPE>( NULL, SetChangedSliceOptions(2, 0, 0, 1, timeStep, rawSlice) );
+}
+
void mitk::SegmentationInterpolationController::PrintStatus()
{
unsigned int timeStep(0); // if needed, put a loop over time steps around everyting, but beware, output will be long
Index: Modules/MitkExt/Controllers/mitkSegmentationInterpolationController.h
===================================================================
--- Modules/MitkExt/Controllers/mitkSegmentationInterpolationController.h (revision 21081)
+++ Modules/MitkExt/Controllers/mitkSegmentationInterpolationController.h (working copy)
@@ -176,6 +176,9 @@
template < typename DATATYPE >
void ScanWholeVolume( itk::Image<DATATYPE, 3>*, const Image* volume, unsigned int timeStep );
+ template < typename DATATYPE >
+ void ScanWholeVolume( itk::Image<DATATYPE, 2>*, const Image* volume, unsigned int timeStep );
+
void PrintStatus();
/**

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
515
Default Alt Text
bug4017.diff (6 KB)