[vtkusers] VolumeRendering Window Width and Window Level

Mallikarjun K mallikarjun49 at gmail.com
Fri Sep 25 05:30:28 EDT 2015


Hi Aashis,

Below is the code snippet.

WindowLevelStyle = vtkSmartPointer<vtkInteractorStyleImage>::New();
WindowLevelStyle->AddObserver(vtkCommand::WindowLevelEvent, callback);

callback:

class vtkImageInteractionCallback : public vtkCommand
{
public:
static vtkImageInteractionCallback *New()
{
return new vtkImageInteractionCallback;
}

vtkImageInteractionCallback()
{
this->interactor = NULL;
this->volumeProperty = NULL;
this->compositeOpacity = NULL;
this->color = NULL;
this->volume = NULL;
this->mapper = NULL;
this->renderwin = NULL;
}

~vtkImageInteractionCallback()
{
this->interactor = NULL;
this->volumeProperty = NULL;
this->compositeOpacity = NULL;
this->color = NULL;
this->volume = NULL;
this->mapper = NULL;
}

void SetInteractor(vtkRenderWindowInteractor *_interactor)
{
this->interactor = _interactor;
}

void SetVolumeProperty(vtkSmartPointer<vtkVolumeProperty> _volumeProperty)
{
this->volumeProperty = _volumeProperty;
}

void SetCompositeOpacity(vtkSmartPointer<vtkPiecewiseFunction>
_compositeOpacity)
{
this->compositeOpacity = _compositeOpacity;
}
void Setcolor(vtkSmartPointer<vtkColorTransferFunction> _color)
{
this->color = _color;
}

void Setvolume(vtkSmartPointer<vtkVolume> _volume)
{
this->volume = _volume;
}
void Setmapper(vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>_mapper)
{
this->mapper = _mapper;
}
void SetRenWin(vtkRenderWindow* _renderwin)
{
this->renderwin = _renderwin;
}

virtual void Execute(vtkObject *, unsigned long vtkNotUsed(event), void *)
{
vtkRenderWindowInteractor *interactor = this->renderwin->GetInteractor();
vtkInteractorStyleImage *style =
vtkInteractorStyleImage::SafeDownCast(interactor->GetInteractorStyle());

this->mapper->AutoAdjustSampleDistancesOff();

int *w=new int[2];
w=style->GetWindowLevelCurrentPosition();
int windowWidth = w[0];
int windowLevel = w[1];


  * I want to modify the color transfer function and opacity transfer
functions here in which volume transition has to happen **from CT  skin to
bone as mouse+move on volume window. Don't know  what/how LUTs I have to
set here. Kindly suggest me how can I do this.*

                        //color->RemoveAllPoints();
                       // color->AddRGBpoint(args);

                        // compositeOpacity->RemoveAllPoints();
                        //compositeOpacity->AddPoint(args);

this->renderwin->Render();
}

private:
vtkRenderWindowInteractor *interactor;
vtkRenderWindow* renderwin;
vtkVolumeProperty* volumeProperty;
vtkPiecewiseFunction* compositeOpacity;
vtkColorTransferFunction* color;
vtkVolume* volume;
vtkFixedPointVolumeRayCastMapper*mapper;
double table[257][3];
};

Thank you

Regards,
Mallikarjun


On Fri, Sep 25, 2015 at 2:48 AM, Aashish Chaudhary <
aashish.chaudhary at kitware.com> wrote:

> Right you are already using what Sankhesh suggested you. So what prevents
> you from changing the transfer function if you are getting the callback?
>
> - Aashish
>
> On Thu, Sep 24, 2015 at 1:09 AM, Mallikarjun K <mallikarjun49 at gmail.com>
> wrote:
>
>> Hi Sankhesh,
>> Thanks for your suggestions.  Actually  I want to modify the existing
>>  color transfer function and Opacity transfer function interactively  on
>> left mouse+move on the volume.
>>
>> Thank you
>>
>> With Kind Regards,
>> Mallikarjun
>>
>> On Thu, Sep 24, 2015 at 3:06 AM, Sankhesh Jhaveri <
>> sankhesh.jhaveri at kitware.com> wrote:
>>
>>> Hello Mallikarjuna,
>>>
>>> vtkInteractorStyleImage provides events for window level changes. See:
>>> http://www.vtk.org/doc/nightly/html/classvtkInteractorStyleImage.html
>>>
>>> You can add an observer to the vtkCommand::WindowLevelEvent or
>>> vtkCommand::EndWindowLevelEvent and change the functions as you like. On a
>>> side note, if all you are changing is the window width and level, you can
>>> just pass those values to
>>> vtkFixedPointVolumeRayCastMapper::SetFinalColorWindow() and
>>> SetFinalColorLevel().
>>>
>>> Hope that helps.
>>>
>>>
>>> Warm regards,
>>> Sankhesh
>>>
>>>
>>>
>>> On Wed, Sep 23, 2015 at 2:48 PM, Mallikarjun K <mallikarjun49 at gmail.com>
>>> wrote:
>>>
>>>> Hi Aashish,
>>>>
>>>> I have created a simple program which does volume rendering using
>>>> vtkfixedpointraycastmapper. Now what I am trying to achieve is that when I
>>>> change the window/level by left mouse click+drag on the renderwindow, then
>>>>  want to change the color volume characteristics by means of window/level.
>>>>
>>>> I used vtkInteractorstyleimage interactor style to change the
>>>> window/level  on left mouse click+drag and in a call back I am getting the
>>>> window and level using
>>>> vtkInteractorStyleImage::GetWindowLevelCurrentPosition. Based on these w/l
>>>>  I want to change/modify the color transferfunction and opacity transfer
>>>> function.
>>>>
>>>> please can you suggest me how can I achieve it.
>>>>
>>>> Thank you in advance.
>>>>
>>>>
>>>>
>>>> On Wed, Sep 23, 2015 at 11:23 PM, Aashish Chaudhary <
>>>> aashish.chaudhary at kitware.com> wrote:
>>>>
>>>>> Can you describe more in detail what you are trying to do? We have
>>>>> piecewise method for transfer functions. What value you set for each step
>>>>> depends on what is needed.
>>>>>
>>>>> - aashsih
>>>>>
>>>>> On Tue, Sep 22, 2015 at 12:28 AM, Mallikarjun K <
>>>>> mallikarjun49 at gmail.com> wrote:
>>>>>
>>>>>>
>>>>>> Hi Everyone,
>>>>>>
>>>>>> How can I set color transfer function and opacity transfer function
>>>>>> based on window width and window level ?
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thanks in advance..
>>>>>>
>>>>>> Regards,
>>>>>> Mallikarjun
>>>>>>
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>>
>>>>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>>
>>>>> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.
>>>>>     *
>>>>> *| http://www.kitware.com/company/team/chaudhary.html
>>>>> <http://www.kitware.com/company/team/chaudhary.html>*
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> *With Kind Regards:*
>>>> Mallikarjuna K,
>>>> 07795531103/09908238861.
>>>>
>>>>
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>
>>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>>
>>>>
>>>
>>
>>
>> --
>> *With Kind Regards:*
>> Mallikarjuna K,
>> 07795531103/09908238861.
>>
>>
>
>
> --
>
>
>
> *| Aashish Chaudhary | Technical Leader         | Kitware Inc.            *
> *| http://www.kitware.com/company/team/chaudhary.html
> <http://www.kitware.com/company/team/chaudhary.html>*
>



-- 
*With Kind Regards:*
Mallikarjuna K,
07795531103/09908238861.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150925/75394917/attachment.html>


More information about the vtkusers mailing list