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

Lorensen, William E (GE, Research) lorensen at crd.ge.com
Mon Apr 10 07:20:33 EDT 2006


Before accessing the data, do a
gaussianSmooth->Update();

vtk's pipeline is demand-driven. Your example worked when you viewed the data because the renderer forces an update on the pipeline.

Bill

-----Original Message-----
From: vtkusers-bounces+lorensen=crd.ge.com at vtk.org [mailto:vtkusers-bounces+lorensen=crd.ge.com at vtk.org]On Behalf Of Michnay Balázs
Sent: Monday, April 10, 2006 7:15 AM
To: vtkusers at vtk.org
Subject: [vtkusers] Accessing scalar data of GaussianSmooth->GetOutput()


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


_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list