Hi,

I have a diffusion image in *.nii format. It include value from -1  
until 1. X-values are in time 0, Y-values in time 1 and Z-values in  
time 2.
I wanna turn X-values red, Y green and Z in blue. But when I use the  
code here, all values in X,Y and Z time will be colored.

Thanks for help

Frank

<code>

MITK_INFO << "Performing diffusion image coloring.";

               //turn X redr, Y green and Z blue
               //transfer function from 0 till 1 of [r,g,b] = [0,0,0]  
until [1,0,0] etc
               //create new node,, hide the old one

               //Create new DataNode
               mitk::DataNode::Pointer dataNode = mitk::DataNode::New();
               dataNode->SetData(image);
               dataNode->SetName(node->GetName() + "_DiffusionColor");

               //TimeSelector to get singe images x,y,z
               mitk::ImageTimeSelector::Pointer selector =  
mitk::ImageTimeSelector::New();
               selector->SetInput(image);

               //X-image from time 0
               selector->SetTimeNr(0);//X
               selector->Update();
               mitk::Image::Pointer selectedImageX = mitk::Image::New();
               selectedImageX->Initialize(selector->GetPic());
               selectedImageX->SetPicVolume(selector->GetPic());
                
//selectedImageX->SetGeometry(selector->GetGeometry());//doesn't work
               selectedImageX->Update();

               //Y-image from time 1
               selector->SetTimeNr(1);//Y
               selector->Update();
               mitk::Image::Pointer selectedImageY = mitk::Image::New();
               selectedImageY->Initialize(selector->GetPic());
               selectedImageY->SetPicVolume(selector->GetPic());
                
//selectedImageY->SetGeometry(selector->GetGeometry());//doesn't work
               selectedImageY->Update();

               //Z-image from time 2
               selector->SetTimeNr(2);//Z
               selector->Update();
               mitk::Image::Pointer selectedImageZ = mitk::Image::New();
               selectedImageZ->Initialize(selector->GetPic());
               selectedImageZ->SetPicVolume(selector->GetPic());
                
//selectedImageZ->SetGeometry(selector->GetGeometry());//doesn't work
               selectedImageZ->Update();

               // Set the property "volumerendering" to the Boolean  
value "true"
               dataNode->SetProperty("volumerendering",  
mitk::BoolProperty::New(true));
               //dataNode->SetProperty("color", mitk::BoolProperty::New(true));

               // Create a transfer function to assign optical  
properties (color and opacity) to grey-values of the data
               mitk::TransferFunction::Pointer tfX =  
mitk::TransferFunction::New();
               tfX->InitializeByMitkImage(selectedImageX);

               // Set the color transfer function AddRGBPoint(double  
x, double r, double g, double b)
               tfX->GetColorTransferFunction()->AddRGBPoint ( -1.0,  
1.0, 0.0, 0.0 );
               tfX->GetColorTransferFunction()->AddRGBPoint ( 0.0,  
0.0, 0.0, 0.0 );
//              tfX->GetColorTransferFunction()->AddRGBPoint (  
tfX->GetColorTransferFunction()->GetRange()[0], 0.0, 0.0, 0.0 );
               tfX->GetColorTransferFunction()->AddRGBPoint ( 1.0,  
1.0, 0.0, 0.0 );
//              tfX->GetColorTransferFunction()->AddRGBPoint (  
tfX->GetColorTransferFunction()->GetRange()[1], 1.0, 0.0, 0.0 );

               // Set the piecewise opacity transfer function  
AddPoint(double x, double y)
               tfX->GetScalarOpacityFunction()->AddPoint ( -1.0, 1.0 );
               tfX->GetScalarOpacityFunction()->AddPoint ( 0.0, 0.0 );
               tfX->GetScalarOpacityFunction()->AddPoint ( 1.0, 1.0);
//              tfX->GetScalarOpacityFunction()->AddPoint (  
tfX->GetColorTransferFunction()->GetRange()[1], 1.0);

               dataNode->SetProperty ( "TransferFunction",  
mitk::TransferFunctionProperty::New(tfX.GetPointer()));

               this->GetDefaultDataStorage()->Add(dataNode);//Should  
add as child, but add as new node next to the others.

MITK_INFO << "Done.";

</code>


-- 

Frank Blaschke

Department for Biometry and Medical Informatics
web:    http://www.med.uni-magdeburg.de/ibmi.html
phone:  +49 391 67 135 51
office: building 2 / room 212



------------------------------------------------------------------------------
Automate Storage Tiering Simply
Optimize IT performance and efficiency through flexible, powerful, 
automated storage tiering capabilities. View this brief to learn how
you can reduce costs and improve performance. 
http://p.sf.net/sfu/dell-sfdev2dev
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to