On Tue, 2008-08-26 at 10:54 +0200, Kelm, Michael wrote:
> Hi Daniel, 
> 
> I've already been looking into that but could not come up with a
> solution.
> 
> The best thing to do would certainly be to convert the 2D image into a
> 3D image first. The constructor of mitk::Image determines the number of
> dimensions from the size of the third dimension. If it is 1, the image
> is assumed to be 2D while if it is >1, the image is assumed to be 3D.
> This distinction seems artificial and I wonder whether there is a
> problem to cast a 2D mitk::Image to a 3D itk image at all?
> 

I'm not sure what method you mean now, mitk::Image has no public
constructor and the protected one doesn't take parameters.

My way of making a 2D image 3D would be something like this:

unsigned int dimensions[3];
dimensions[0] = twoDImage->GetDimension(0);
dimensions[1] = twoDImage->GetDimension(1);
dimensions[2] = 1;
PixelType pixelType( typeid(short) ); // or whatever you wanted
Image::Pointer threeDImage = Image::New();
threeDImage->Initialize( pixelType, 3, dimensions );
threeDImage->SetSlice( twoDImage->GetData() );

I havn't tested this but I think that would work. You might also have to
set some geometry. In this case my first try would be to take the 2D
geometry and set it as 3D geometry.

Regards
Daniel

-- 
Dipl.-Inform. Med. Daniel Maleike          Phone: +49 6221 42 2326
Deutsches Krebsforschungszentrum           Im Neuenheimer Feld 280
Medical and Biological Informatics (E130)         69120 Heidelberg


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to