Hi Michael,
in general, the test mitkImageVtkMapper2DTransferFunctionTest is a very good
example how to use mitkTransferFunction for an image.
I had a look into the code and the opacity might actually be a problem. I think
the mitkTransferFunction is meant for volume rendering but also very generic
and can be reused for 2D image rendering. However, there is no function, yet,
applying more than a vtkColorTransferFunction to images. Internally, the
mitkTransferFunction holds two vtkPiecewiseFunctions for scalar and gradient
opacity. These are only used during volume rendering. The function
AddScalarOpacityPoint adds a point to one of this vtkPiecewiseFunctions.
Alternative:
Could you use a Lookuptable instead of a TransferFunction? For binary we define
an extra lookuptable which does exactly that. See mitkImageVtkMapper2D
m_BinaryLookupTable.
Quick fix for you:
Could you convert your image to an RGB image for rendering purposes? Then you
could even use the opaclevelwindow property to adapt the opacity or just set it
to 0 for all pixels with 0.0.
For the complex fix:
If you want to have a detailed look into our rendering and adapt the internal
filters to make also use of the vtkPiecewiseFunction, you could use the
existent rendering test for the TransferFunction:
mitkImageVtkMapper2DTransferFunctionTest. This test is in our MitkTestDriver
and will automatically build with MITK_USE_TESTING (and on Linux
MITK_ENABLE_GUI_TESTING). It renders a test image into a render window. You
could also render your own data (can be passed via command line argument) but
then the test will fail (which is not really important for you). To
view/interact with the renderwindow you have to set
renderingHelper.SetAutomaticallyCloseRenderWindow(false); before the render()
method is called.
Regards,
Thomas
From: Michael Helmberger [mailto:[email protected]]
Sent: Montag, 1. Juli 2013 15:04
To: Kilgus, Thomas
Cc: [email protected]
Subject: Re: [mitk-users] Transferfunctions
Hi Thomas,
I stumbled across another problem: the colortransferfunction works, however
setting the opacity of the transferfunction (using AddScalarOpacityPoint) does
not work. I would like that all zero values of the segmentation have an opacity
of 0.0.
Is there something else with the renderer that I have to activate?
best, michael
2013/7/1 Kilgus, Thomas
<[email protected]<mailto:[email protected]>>
Ah sorry, I forgot to mention that. Anyway you found it yourself. Good work! :)
Regards
Thomas
Thomas Kilgus
German Cancer Research Center (DKFZ)
Div. Medical and Biological Informatics
Junior group: Computer-assisted Interventions (E131)
Im Neuenheimer Feld 280
69120 Heidelberg, Germany
Phone: +49(0) 6221-42-3545<tel:%2B49%280%29%206221-42-3545>
From: Michael Helmberger
[mailto:[email protected]<mailto:[email protected]>]
Sent: Montag, 1. Juli 2013 13:56
To: Kilgus, Thomas
Subject: Re: [mitk-users] Transferfunctions
Hello,
if found the error in the code: I had to use the property names "Image
Rendering.Transfer Function" and "Image Rendering.Mode".
now it works like a charm!
thanks :)
2013/7/1 Michael Helmberger
<[email protected]<mailto:[email protected]>>
Hello Thomas,
thanks for the fast reply! I tried setting the property but I think I still
miss something. I use the following code to set the Transferfunction:
// set the rendering mode
mitk::RenderingModeProperty::Pointer renderingModeProp =
mitk::RenderingModeProperty::New()
renderingModeProp->SetValue(mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_LEVELWINDOW_COLOR);
node->SetProperty("RenderingMode", renderingModeProp);
// set the transfer function
mitk::TransferFunctionProperty::Pointer transferFuncProp =
mitk::TransferFunctionProperty::New();
mitk::TransferFunction::Pointer transferFunction =
mitk::TransferFunction::New();
transferFunction->AddRGBPoint(1, 1,0,0); // label 1 should be red
transferFunction->AddRGBPoint(2, 0,1,0); // label 2 green
transferFuncProp->SetValue(transferFunction);
node->SetProperty("TransferFunction", transferFuncProp);
multiWidget->RequestUpdate();
thanks,
michael
ps: sorry for spamming you thomas ;)
2013/7/1 Kilgus, Thomas
<[email protected]<mailto:[email protected]>>
Hi Michael,
if you want to use a TransferFuntionProperty to render an image, you have to
set the property "Image Rendering.Mode" (mitkRenderingModeProperty) to a mode
which enables the TransferFuntion. COLORTRANSFERFUNCTION_LEVELWINDOW_COLOR will
apply your TransferFunction and also allow you to modify the range via the
level window property (level window slider in mitkWorkbench).
COLORTRANSFERFUNCTION_COLOR will only apply your TransferFunction.
Regards,
Thomas
From: Michael Helmberger
[mailto:[email protected]<mailto:[email protected]>]
Sent: Montag, 1. Juli 2013 12:06
To: [email protected]<mailto:[email protected]>
Subject: [mitk-users] Transferfunctions
Hello,
I am using the QmitkStdMultiWidget to display a CT volume and a segmentation. I
would like to assign different colors to different labels in the segmentation,
however setting the TransferFunctionProperty of the corresponding
mitk::DataNode did not change anything.
I also tried changing the Color property, however this does effect the whole
image and I cannot change the color for separate labels.
Thanks,
Michael
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users