[vtkusers] writing a custom image loader
Mike Jackson
imikejackson at gmail.com
Tue Jan 22 10:40:14 EST 2008
Basically, instantiate a vtkImageData class. Set the data Type to the
type that your "measured value" is, (int or float or char..). Set the
extents (width, height, depth). Set the scaling factor (in case your
data is not 0,1,2,3,4, but something like (0.5, 1.0, 1.5, ...)
Then loop on your measured values and set each pixel in the image
data object:
vtkImageData* image = vtkImageData::New();
image->setDimensions(width, height, depth);
image->SetScalarTypeToFloat(); // or what ever makes sense
image->SetSpacing ( ... );
image->SetOrigin (.... );
void* dataPointer = NULL;
for (int i = ....)
for (int j = .... )
dataPointer = image->getScalarPointer(i,j,0);
*dataPointer = [get the value for this pixel from your data];
Something like the above should get you close.
Mike
On Jan 22, 2008, at 10:14 AM, Oliver Kania wrote:
> Hello and thanks,
> We have points in the eucledian plane which are arranged like a
> regular grid.
> (evenly spaced)
> We have a measured value for each point that should be interpreted
> as a grey-scale or color
> value.
> How do I tie this to a vtkImageData ?
>
> best regards,
> Oliver
>
> PS: we already ordered both VTK-books.
>
> 2008/1/22, burlen < burlen at apollo.sr.unh.edu>:
> Hi, Oliver, writing an image loader is fairly strait forward but
> the details depend on the specifics of your data. Does your data
> have a regular Cartesian geometry? You first need to figure out
> which vtkDataSet best matches the geometry of your data. For
> instance using an vtkUnstructuredGrid where you could use
> vtkImageData would overly complicate things and adversely impact
> performance. A good deal of information can be found in the vtk
> users guide. In ver 4.2 of the user guide chap 5 has relevant info.
> If you plan to use VTK you would be well advised to obtain a copy.
> Burlen
>
>
>
> Oliver Kania wrote:
>>
>> Hello !
>> Can someone provide a step by step guide on
>> writing a custom image loader.
>> We basically have 2D-point data with values attached to each point.
>>
>>
>> Best regards, Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080122/e43ec1fd/attachment.htm>
More information about the vtkusers
mailing list