[vtkusers] Reading from memory as opposed to file
David Gobbi
david.gobbi at gmail.com
Mon Mar 24 12:01:15 EDT 2014
Hi David,
Importing complex images into VTK is straightforward,
just use this:
importer->NumberOfScalarComponents(2);
Keeping the same subject line is the best, it makes it
easy to track the conversation.
David
On Mon, Mar 24, 2014 at 9:41 AM, <dfcsingh at sri.utoronto.ca> wrote:
> Hi,
>
> Thanks so much for the help. This seems to have worked well. However I
> mispoke on a rather important detail in my first e-mail. My vector of
> doubles is in fact a vector of complex<double> values. How does vtk handle
> this?
> I'm prototyping my image manipulations in matlab and have guaranteed that
> the vector contains the same data as the array I'm using in matlab.
> However when I visualize each of these data sets I get different visuals
> (attached).
> Can vtk handle the c++ complex data type or is this a GIGO situation
> because I'm feeding the vtk modules a complex vector?
>
> Thanks for any help,
> David
>
> p.s. Sorry for the follow up questions, please let me know if I should
> repost under a new subject line
>
>> Hi David,
>>
>> Use vtkImageImport. It has an interface that is nearly identical to
>> vtkImageReader2, except that instead of having a SetFileName()
>> method, it has a SetImportVoidPointer() method.
>>
>> So if your vector is named "data", do something like this:
>>
>> importer->SetImportVoidPointer(&data[0]);
>> importer->SetDataScalarTypeToDouble();
>> importer->SetDataExtent(0, 255, 0, 255, 0, 0);
>> etcetera.
>>
>> David
>>
>> On Fri, Mar 21, 2014 at 6:27 PM, <dfcsingh at sri.utoronto.ca> wrote:
>>>
>>> Hi vtkusers,
>>>
>>> In my experience with vtk thus far I've used vtkImageReader2 to read
>>> various MR file types and display them. For my next project I need to
>>> visualize raw MR data. To this end I would like to do some
>>> pre-processing
>>> on the data before passing it to a vtk pipeline. At the end of the
>>> processing in c++ I have a vector of doubles. Is there a way to feed
>>> this
>>> vector to vtkImageReader2 (or something similar)?
>>> My google-fu yielded setmemorybuffer however I'm not sure how to pass
>>> this
>>> function a vector and more importantly it wasn't showing up as a member
>>> of
>>> vtkImageReader2 when I attempted to test it (using vtk 5.6.1)
>>> I'd appreciate any help,
>>> David
>>
>
>
More information about the vtkusers
mailing list