[vtkusers] Accessing scalar data of GaussianSmooth->GetOutput()

Michnay Balázs michnay at freemail.hu
Mon Apr 10 07:14:55 EDT 2006


Dear VTK Users,

I ran into a very interesting problem. What I want to do is to access the 
scalar data of an image, which was previously gauss-smoothed using 
vtkImageGaussianSmooth class.

When I get scalar data, there is no error:

Scalars = (vtkUnsignedCharArray *)inputImage->GetPointData()-
>GetScalars();

But when I try to read the actual scalars I get a run-time error: "Access 
Violation".

int b = Scalars->GetComponent(0,0 );

Now comes the interesting part. If I visualize the image before 
accessing scalar data, everything works fine. I use vtkImageActor, 
vtkRenderer and vtkRenderWindow for visualization.

I think I miss some kind of a setting using the Set macro the 
visualization automatically sets.

Here's my code, it's very simple.
Thanks for your help,
MB

----------------
vtkImageGaussianSmooth *gaussianSmooth = 
vtkImageGaussianSmooth::New();	
  gaussianSmooth->SetDimensionality(2);
  gaussianSmooth->SetRadiusFactor(1);
  gaussianSmooth->SetInput(inputImage);
//Input image is fine, it can be visualized...

image = gaussianSmooth->GetOutput();
//this output is also fine when visualized

vtkUnsignedCharArray *Scalars = vtkUnsignedCharArray::New();
Scalars = (vtkUnsignedCharArray *)image->GetPointData()->GetScalars
();

//This generates the "Access Violation" error message:

int b = Scalars->GetComponent(0,0 );

_______________________________________________________________________
3 könyv = 15+5% kedvezmény!
http://www.bookline.hu/control/news?newsid=351&affiliate=fre3kokar2230





More information about the vtkusers mailing list