Quantcast

vtkFixedPointVolumeRayCastMapper Problem in java

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

vtkFixedPointVolumeRayCastMapper Problem in java

Sercani

Hi everyone;

I am using vtk java wrapping for MIP(maximum intensity projection)/MINIP(minimum intensity projection)…I figured out that vtkVolumeRayCastMapper doesn’t support minip so decided to use vtkFixedPointRayCastMapper for these projections…First I wrote in C++ and everything works great…But in java(exactly the same code but in java syntax of course) it always crashes when rendering the vtkPanel first time and gives this stack overflow exception:

 

An unrecoverable stack overflow has occurred.

#

# An unexpected error has been detected by Java Runtime Environment:

#

#  EXCEPTION_STACK_OVERFLOW (0xc00000fd) at pc=0x50aee7e7, pid=3268, tid=5264

#

# Java VM: Java HotSpot(TM) Client VM (11.0-b16 mixed mode windows-x86)

# Problematic frame:

# C  [vtkVolumeRendering.dll+0x4fe7e7]

#

I change my JVM’s heap space( netbeans_default_options="-J-client -J-Xverify:none -J-Xss2m -J-Xms200m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true" it’s minimum was 32m before the changing, should i change the J-XX:PermSize=32m too? ) but it couldn’t do the trick…I think this bug is related to my problem : http://www.vtk.org/Bug/view.php?id=6443 and i patched my vtk source code with the patch that Levap attaches, but nothing changes…How can i use vtkFixedPointRayCastMapper with my java project? This is my testing code in c++, i tried every possible combinations with vtkImageCast output or reader output, this code works but in java it always crashes…

 

Yours sincerely…

Sercan…

 

#include "vtkRenderer.h"

#include "vtkRenderWindow.h"

#include "vtkRenderWindowInteractor.h"

#include "vtkPolyDataToImageStencil.h"

#include "vtkImageData.h"

#include "vtkDICOMImageReader.h"

#include "vtkImageCast.h"

#include "vtkFixedPointVolumeRayCastMapper.h"

#include "vtkVolumeRayCastMapper.h"

#include "vtkVolumeRayCastMIPFunction.h"

#include "vtkPiecewiseFunction.h"

#include "vtkVolumeProperty.h"

#include "vtkVolume.h"

#include "vtkTextactor.h"

#include "Math.h"

#include <string>

#include <iostream>

#include <sstream>

 

class test

{

 

public:

        test();

};

test::test()

{

       vtkDICOMImageReader *reader= vtkDICOMImageReader::New();

                 reader->SetDirectoryName("C:\\Dicom\\MANIX\\manix-study\\ANGIOCT");

                   reader->SetDataScalarTypeToUnsignedChar();

                 reader->Update();

     

                  vtkImageCast *imageCast=vtkImageCast::New();

                   imageCast->SetInputConnection(reader->GetOutputPort());

                   imageCast->SetOutputScalarTypeToUnsignedChar();

                   imageCast->Update();

 

                   double *range=imageCast->GetOutput()->GetScalarRange();

                  double window=range[1]-range[0];

                   double level=window/2;

                              

 

                window=1500;

                level=20;

                   vtkPiecewiseFunction *opacityFunction=vtkPiecewiseFunction::New();

                   opacityFunction->AddPoint(level-window/2.0,0.0);

                   opacityFunction->AddPoint(level+window/2.0,1.0);

                  

                   vtkPiecewiseFunction *grayFunction=vtkPiecewiseFunction::New();

                   grayFunction->AddSegment(level - window / 2,0.0,level + window / 2 , 1.0);

 

 

                   vtkFixedPointVolumeRayCastMapper *raycastMapper=vtkFixedPointVolumeRayCastMapper::New();

                  //vtkVolumeRayCastMIPFunction *mipFunction=vtkVolumeRayCastMIPFunction::New();

                  //mipFunction->SetMaximizeMethodToScalarValue();

                 //vtkVolumeRayCastMapper *raycastMapper=vtkVolumeRayCastMapper::New();

                   raycastMapper->SetInputConnection(imageCast->GetOutputPort());

                   raycastMapper->SetSampleDistance(1.0);

                   //raycastMapper->SetVolumeRayCastFunction(mipFunction);

                   raycastMapper->SetBlendModeToMaximumIntensity();

                                              

                   raycastMapper->ReleaseDataFlagOn();

 

                   vtkVolumeProperty *volumeProperty=vtkVolumeProperty::New();

                   volumeProperty->SetScalarOpacity(opacityFunction);

                   volumeProperty->SetColor(grayFunction);

                   volumeProperty->SetInterpolationTypeToLinear();

                   volumeProperty->ShadeOff();

                   volumeProperty->SetIndependentComponents(0);

                                  /*volumeProperty->SetSpecularPower(10);

                   volumeProperty->SetSpecular(1.0);

                   volumeProperty->SetAmbient(1.0);

                   volumeProperty->SetDiffuse(1.0);*/

 

                   vtkVolume *volume=vtkVolume::New();

                   volume->SetMapper(raycastMapper);

                   volume->SetProperty(volumeProperty);

                   volume->Update();   

 

                   vtkRenderer *aRenderer = vtkRenderer::New();

                   aRenderer->AddActor(volume);

       vtkRenderWindow *renWin = vtkRenderWindow::New();

       renWin->AddRenderer(aRenderer);

       vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

       iren->SetRenderWindow(renWin);

  

                  

      // aRenderer->ResetCamera();

                   //aRenderer->ResetCameraClippingRange();

       aRenderer->Render();

       aRenderer->SetBackground(0.5,0.5,0.5);

       renWin->SetSize(512, 512);

       // interact with data

       iren->Initialize();

       iren->Start();

}

 

int main()

{

       test t;

       return 0;

 

}

    


_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vtkFixedPointVolumeRayCastMapper Problem in java

Stef_D
Sercani wrote
Hi everyone;

I am using vtk java wrapping for MIP ... so decided to use
vtkFixedPointRayCastMapper for these projections.First I wrote in C++ and
everything works great.But in java(exactly the same code but in java syntax
of course) it always crashes when rendering the vtkPanel first time and
gives this stack overflow exception:

An unrecoverable stack overflow has occurred.

#

# An unexpected error has been detected by Java Runtime Environment:

#

#  EXCEPTION_STACK_OVERFLOW (0xc00000fd) at pc=0x50aee7e7, pid=3268,
tid=5264

#

# Java VM: Java HotSpot(TM) Client VM (11.0-b16 mixed mode windows-x86)

# Problematic frame:

# C  [vtkVolumeRendering.dll+0x4fe7e7]
...

I'm quoting your post as i've the exact same problem as you. I can bring news pieces as i spent many time on this problem without success :
- It does work prefectly on OSX 10.6.3 (so with osx adapted compilation)
- It does work with a pure win64 version (64 bits JVM with 64 bits VTK compilation) but the 64 bits VTK version brings some others problems.
- It does not work with win32 version which is a shame as it's probably the most used version. I tried many VTK version (nighty, 5.4.2, 5.0... ) with many JVM version and always got the same result as soon i try to use the vtkFixedPointVolumeRayCastMapper with volume rendering. I need it as it's the only mapper which actually support multi component volume rendering.

Someone else experienced this problem ? Can it be fixed or is it a bug in VTK library ?
I don't understand why only the win32 port is affected (maybe other 32 bits ports but i didn't tested)...
Thanks in advance for any help !

Cheers.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vtkFixedPointVolumeRayCastMapper Problem in java

Sercani
27.04.2010 11:10, Stef_D yazmış:

>
> Sercani wrote:
>    
>> Hi everyone;
>>
>> I am using vtk java wrapping for MIP ... so decided to use
>> vtkFixedPointRayCastMapper for these projections.First I wrote in C++ and
>> everything works great.But in java(exactly the same code but in java
>> syntax
>> of course) it always crashes when rendering the vtkPanel first time and
>> gives this stack overflow exception:
>>
>> An unrecoverable stack overflow has occurred.
>>
>> #
>>
>> # An unexpected error has been detected by Java Runtime Environment:
>>
>> #
>>
>> #  EXCEPTION_STACK_OVERFLOW (0xc00000fd) at pc=0x50aee7e7, pid=3268,
>> tid=5264
>>
>> #
>>
>> # Java VM: Java HotSpot(TM) Client VM (11.0-b16 mixed mode windows-x86)
>>
>> # Problematic frame:
>>
>> # C  [vtkVolumeRendering.dll+0x4fe7e7]
>> ...
>>
>>      
>
> I'm quoting your post as i've the exact same problem as you. I can bring
> news pieces as i spent many time on this problem without success :
> - It does work prefectly on OSX 10.6.3 (so with osx adapted compilation)
> - It does work with a pure win64 version (64 bits JVM with 64 bits VTK
> compilation) but the 64 bits VTK version brings some others problems.
> - It does not work with win32 version which is a shame as it's probably the
> most used version. I tried many VTK version (nighty, 5.4.2, 5.0... ) with
> many JVM version and always got the same result as soon i try to use the
> vtkFixedPointVolumeRayCastMapper with volume rendering. I need it as it's
> the only mapper which actually support multi component volume rendering.
>
> Someone else experienced this problem ? Can it be fixed or is it a bug in
> VTK library ?
> I don't understand why only the win32 port is affected (maybe other 32 bits
> ports but i didn't tested)...
> Thanks in advance for any help !
>
> Cheers.
>    
Hi;

I couldn't solve this problem, but you can of course use
vtkVolumeRayCastMapper for maximum intensity(or minimum intensity)
projection, here is an example:


int scalarRangeMin = reader.GetOutput().GetScalarRange()[0];
int scalarRangeMax = reader.GetOutput().GetScalarRange()[1];

int window = (int) (scalarRangeMax - scalarRangeMin);
int level = (int) (scalarRangeMin + (window / 2));

vtkImageShiftScale shiftscale = new vtkImageShiftScale();
shiftscale.SetInputConnection(reader.GetOutputPort());
shiftscale.SetOutputScalarTypeToUnsignedShort();
if (scalarRangeMin < 0) {
shiftscale.SetShift(-1 * scalarRangeMin);
}
shiftscale.Update();
vtkPiecewiseFunction opacityFunction=new vtkPiecewiseFunction();
opacityFunction.AddPoint(scalarRangeMin, 0.0);
opacityFunction.AddPoint((level + window / 2), 1.0);
opacityFunction.AddPoint((level - window / 2), 0.0);
opacityFunction.AddPoint(scalarRangeMax, 0.0);

vtkPiecewiseFunction grayFunction = new vtkPiecewiseFunction();
grayFunction.AddSegment(0, 0.0, 255, 1.0);

volumeProperty.SetColor(grayFunction);
volumeProperty.SetScalarOpacity(opacityFunction);
volumeProperty.SetInterpolationTypeToLinear();
volumeProperty.ShadeOff();

vtkVolumeRayCastMIPFunction mipFunction = new vtkVolumeRayCastMIPFunction();
raycastMapper.SetInputConnection(shiftscale.GetOutputPort());
raycastMapper.SetBlendModeToMaximumIntensity();
raycastMapper.SetVolumeRayCastFunction(mipFunction);
raycastMapper.ReleaseDataFlagOn();

vtkVolume volume=new vtkVolume();
volume.SetMapper(raycastMapper);
volume.SetProperty(volumeProperty);

this.getRenderer().AddVolume(volume);
this.getRenderer().ResetCamera();



_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vtkFixedPointVolumeRayCastMapper Problem in java

Stef_D
This post was updated on .
Afaik i already though about that solution of moving several component in a single one by adding different scalar range in a final one and adjusting final color function. My problem is that my source image can already have a complexe colormap schem *per component* so it becomes very difficult to map all them in a single component...
Thanks for your help anyway, it's really appreciated.
So you never found any solution to fix the problem with the vtkFixedPointVolumeRayCastMapper ? too bad... i wonder if i should report it as VTK bug.

Thanks again.

Cheers.

Sercani wrote
Hi;

I couldn't solve this problem, but you can of course use
vtkVolumeRayCastMapper for maximum intensity(or minimum intensity)
projection, here is an example:


int scalarRangeMin = reader.GetOutput().GetScalarRange()[0];
int scalarRangeMax = reader.GetOutput().GetScalarRange()[1];

int window = (int) (scalarRangeMax - scalarRangeMin);
int level = (int) (scalarRangeMin + (window / 2));

vtkImageShiftScale shiftscale = new vtkImageShiftScale();
shiftscale.SetInputConnection(reader.GetOutputPort());
shiftscale.SetOutputScalarTypeToUnsignedShort();
if (scalarRangeMin < 0) {
shiftscale.SetShift(-1 * scalarRangeMin);
}
shiftscale.Update();
vtkPiecewiseFunction opacityFunction=new vtkPiecewiseFunction();
opacityFunction.AddPoint(scalarRangeMin, 0.0);
opacityFunction.AddPoint((level + window / 2), 1.0);
opacityFunction.AddPoint((level - window / 2), 0.0);
opacityFunction.AddPoint(scalarRangeMax, 0.0);

vtkPiecewiseFunction grayFunction = new vtkPiecewiseFunction();
grayFunction.AddSegment(0, 0.0, 255, 1.0);

volumeProperty.SetColor(grayFunction);
volumeProperty.SetScalarOpacity(opacityFunction);
volumeProperty.SetInterpolationTypeToLinear();
volumeProperty.ShadeOff();

vtkVolumeRayCastMIPFunction mipFunction = new vtkVolumeRayCastMIPFunction();
raycastMapper.SetInputConnection(shiftscale.GetOutputPort());
raycastMapper.SetBlendModeToMaximumIntensity();
raycastMapper.SetVolumeRayCastFunction(mipFunction);
raycastMapper.ReleaseDataFlagOn();

vtkVolume volume=new vtkVolume();
volume.SetMapper(raycastMapper);
volume.SetProperty(volumeProperty);

this.getRenderer().AddVolume(volume);
this.getRenderer().ResetCamera();
Loading...