[vtkusers] RE: Problem visualizing an image gradient vector field

Dean Inglis dean.inglis at camris.ca
Thu Oct 19 10:24:32 EDT 2006


Oscar,

one thing to keep in mind is that vtkImageGradient,
when given a 2D image generates  x-y data regardless
of extents: that is, if you have a (2D) y-z data plane
it won't give what you expect: this is because when it takes
1 component scalar values it computes a 2 scalar component image
and isn't designed to figure out the orientation (associated axes)
of those components.
You can use:

vtkImagePermute  // to reorder things
vtkImageGradient // to do gradient
vtkImageConstantPad // to pad zeros and get 3rd scalar field
vtkImageExtractComponents // one or more to pull each component separately
vtkImageAppendComponents // to put them all back together

Dean

-----Original Message-----
From:
Oscar Yañez Suarez
Sent: Thursday, October 19, 2006 9:26 AM
To:
Subject: Re: Problem visualizing an image gradient vector field


Dean,
Thanks again for your response. I posted to the list a not-so-nice
solution to the problem (copying by hand the Scalars to the Vectors
array). I have what I need, but I don't like the solution at all.
Bypassing the shrink filter makes no difference, nor switching from
ImageData to generic geometry (vtkImageDataGeometryFilter) before the
AssignAttribute. I wonder what is different in the output of
ProbeFilter...I'll take a peek.
Thanks for your help!!
Oscar

> Oscar,
>
> don't worry about threads, I never seem to
> get them to match up either.
>
> in the pipeline I constructed, I pass my image
> data (the gradient vectors) into a vtkProbeFilter
> and probe the field with a polydata from an interactive
> spline.  The output of the probe filter goes into
> the vtkAssignAttributes (with the exact same settings
> you have) and then to the 3D arrow/glyph pipepline.
> Maybe the shrink filter is affecting it or maybe
> assignattributes doesn't like image data?
>
> Dean
>
> -----Original Message-----
> From:
> Oscar Yañez Suarez
> Sent: Wednesday, October 18, 2006 10:01 AM
> Subject: Re: Problem visualizing an image gradient vector field
>
>
> ( sorry to send this to your mailbox, but I don't know how to make
> this message thread with the previous messages at vtkusers ... )
>
> Hi Dean, thanks for your prompt response. Unfortunately it is not
> working yet. Let me add some info to your suggestions and some extras
> I've found recently:
>
> > if your original image is a 2D image, then you
> > have to set the gradient filter correctly (I think
> >it will do this for you automatically)
>
> > hgrd SetDimensionality 2
>
> > then try padding the gradient image with zeros:
> > ...
>
> This is true, the original image is 2D, so doing what you suggest
> works fine. vtkImageGradient also handles the "SetDimensionality 3"
> for a 2D image, yielding a third scalar component of constant zeros
> (just like your suggested padding). So either method produces a 3D
> vector field, but whose components are stored in the Scalars.
> Therefore the need for the vtkAssignAttribute.
>
> > this will give you a 3D vector field,
> > so use a vtkArrowSource instead of a vtkGlyphSource2D:
> > ...
>
> OK, no problem with this
>
> > field SetScaleModeToDataScalingOff
> > field SetScaleFactor 0.05
>
> I think these settings you suggest will cancel each other's efects, won't
> they?
>
> And finally, as I am suspicious of the Scalars -> Vectors array
> copying, I looked carefully into the output of vtkAssignAttribute, and
> it has 3 Scalar components and NO Vector components. I guess this is
> the main reason for the failure, but I have no clue of what is going
> on there.
>
> Thanks for your help, it is really appreciated.
>  Oscar
>
> --
> Oscar Yanez Suarez
> Laboratorio de Neuroimagenologia
> Departamento de Ingenieria Electrica
> UAM - Iztapalapa
> http://docencia.izt.uam.mx/oys
>


--
Oscar Yanez Suarez
Laboratorio de Neuroimagenologia
Departamento de Ingenieria Electrica
UAM - Iztapalapa
http://docencia.izt.uam.mx/oys



More information about the vtkusers mailing list