Ghosts and Extents (was vtkImageImport in java?)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Ghosts and Extents (was vtkImageImport in java?)

Stewart, Terry

Steve,

  I'm using Java and ran into a similar situation while trying to get my
internally-generated RGB image into vtkImageData.  I'd tried the
vtkImageImport path too only to run into the same roadblock with the
missing [Copy|Set]ImportVoidPointer() methods for Java.  I've gotten my
logic to a functional state via:

   vtkImageData imageData = new vtkImageData();
         :
   for (x = 0; ...)
      for (y = 0; ... )
         imageData.SetScalarComponentFromDouble(x, y, 0, rComp, (double)
buffer[byteIndex++]);
         imageData.SetScalarComponentFromDouble(x, y, 0, gComp, (double)
buffer[byteIndex++]);
         imageData.SetScalarComponentFromDouble(x, y, 0, bComp, (double)
buffer[byteIndex++]);

However this is quite slow.  Did you use some other mechanism to get
your image data inserted into vtkImageData that is perhaps more
efficient?  

Thx.

Terry

>Howdy,
>
>On Fri, Jan 28, 2005 at 03:25:44PM -0500, Steve M. Robbins wrote:
>
>> Has anyone got example code that builds image data from
>scratch in Java?
>> Ultimately I'd like a vtkImageData object.
>>
>> I considered using vtkImageImport in java but there doesn't
>appear to
>> be any access to the two methods that actually copy data:
>> CopyImportVoidPointer() and SetImportVoidPointer().  :-/
>
>I went back to copying the data directly into a vtkImageData
>object and finally managed to get things working.  It turns
>out that the only bit that I had missed initially was to call
>SetWholeExtent().  Using just SetExtent() is not enough, it seems.
>
>
>I have read the VTK User's Guide.  The chapter on how the
>pipeline operates is helpful, but I'm still not sure exactly
>what is the distinction between "extent", "whole extent" and
>"update extent".  I get the feeling that the update extent is
>set at the output end of the pipeline (e.g. by mappers) and
>propagated backwards towards the source objects, but even that
>is not clear.  Who is responsible for setting the other two
>extents?  And what is a "ghost level"?
>
>Is there any documentation that defines these terms?
>
>How about source code: is there a particularly good class to
>start with?  Data class?  Source class?  Reader?
>
>Thanks,
>-Steve
>
>
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Ghosts and Extents (was vtkImageImport in java?)

Steve M. Robbins
On Thu, Feb 09, 2006 at 10:35:49AM -0800, Stewart, Terry wrote:

>
> Steve,
>
>   I'm using Java and ran into a similar situation while trying to get my
> internally-generated RGB image into vtkImageData.  I'd tried the
> vtkImageImport path too only to run into the same roadblock with the
> missing [Copy|Set]ImportVoidPointer() methods for Java.  I've gotten my
> logic to a functional state via:
>
>    vtkImageData imageData = new vtkImageData();
>          :
>    for (x = 0; ...)
>       for (y = 0; ... )
>          imageData.SetScalarComponentFromDouble(x, y, 0, rComp, (double)
> buffer[byteIndex++]);
>          imageData.SetScalarComponentFromDouble(x, y, 0, gComp, (double)
> buffer[byteIndex++]);
>          imageData.SetScalarComponentFromDouble(x, y, 0, bComp, (double)
> buffer[byteIndex++]);
>
> However this is quite slow.

Yep.

> Did you use some other mechanism to get
> your image data inserted into vtkImageData that is perhaps more
> efficient?  

Yep.  We wrote JNI code that effectively does a memcpy() to
vtkImage.GetVoidPointer().  I'd give you the code except that the JNI
bit is very specific to our application so it really wouldn't help
you.


-Steve
P.S.  I still don't know what ghost levels are.  Anyone?



> >On Fri, Jan 28, 2005 at 03:25:44PM -0500, Steve M. Robbins wrote:
> >
> >> Has anyone got example code that builds image data from
> >scratch in Java?
> >> Ultimately I'd like a vtkImageData object.
> >>
> >> I considered using vtkImageImport in java but there doesn't
> >appear to
> >> be any access to the two methods that actually copy data:
> >> CopyImportVoidPointer() and SetImportVoidPointer().  :-/
> >
> >I went back to copying the data directly into a vtkImageData
> >object and finally managed to get things working.  It turns
> >out that the only bit that I had missed initially was to call
> >SetWholeExtent().  Using just SetExtent() is not enough, it seems.
> >
> >
> >I have read the VTK User's Guide.  The chapter on how the
> >pipeline operates is helpful, but I'm still not sure exactly
> >what is the distinction between "extent", "whole extent" and
> >"update extent".  I get the feeling that the update extent is
> >set at the output end of the pipeline (e.g. by mappers) and
> >propagated backwards towards the source objects, but even that
> >is not clear.  Who is responsible for setting the other two
> >extents?  And what is a "ghost level"?
> >
> >Is there any documentation that defines these terms?
> >
> >How about source code: is there a particularly good class to
> >start with?  Data class?  Source class?  Reader?
> >
> >Thanks,
> >-Steve
> >
> >
> _______________________________________________
> 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
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

RE: Ghosts and Extents (was vtkImageImport in java?)

Stewart, Terry
In reply to this post by Stewart, Terry

Steve,

  OK, thanks.   Updating the JNI logic was an idea that my team had been
contemplating.  Thanks for the confirmation.  And right, the interface
updates we'd like to make would likely be different than yours, so no
problem there.  

  Thanks again.

Terry

>-----Original Message-----
>From: Steve M. Robbins [mailto:[hidden email]]
>Sent: Thursday, February 09, 2006 3:08 PM
>To: Stewart, Terry
>Cc: [hidden email]
>Subject: Re: Ghosts and Extents (was [vtkusers] vtkImageImport
>in java?)
>
>On Thu, Feb 09, 2006 at 10:35:49AM -0800, Stewart, Terry wrote:
>>
>> Steve,
>>
>>   I'm using Java and ran into a similar situation while
>trying to get
>> my internally-generated RGB image into vtkImageData.  I'd tried the
>> vtkImageImport path too only to run into the same roadblock with the
>> missing [Copy|Set]ImportVoidPointer() methods for Java.  I've gotten
>> my logic to a functional state via:
>>
>>    vtkImageData imageData = new vtkImageData();
>>          :
>>    for (x = 0; ...)
>>       for (y = 0; ... )
>>          imageData.SetScalarComponentFromDouble(x, y, 0, rComp,
>> (double) buffer[byteIndex++]);
>>          imageData.SetScalarComponentFromDouble(x, y, 0, gComp,
>> (double) buffer[byteIndex++]);
>>          imageData.SetScalarComponentFromDouble(x, y, 0, bComp,
>> (double) buffer[byteIndex++]);
>>
>> However this is quite slow.
>
>Yep.
>
>> Did you use some other mechanism to get your image data
>inserted into
>> vtkImageData that is perhaps more efficient?
>
>Yep.  We wrote JNI code that effectively does a memcpy() to
>vtkImage.GetVoidPointer().  I'd give you the code except that
>the JNI bit is very specific to our application so it really
>wouldn't help you.
>
>
>-Steve
>P.S.  I still don't know what ghost levels are.  Anyone?
>
>
>
>> >On Fri, Jan 28, 2005 at 03:25:44PM -0500, Steve M. Robbins wrote:
>> >
>> >> Has anyone got example code that builds image data from
>> >scratch in Java?
>> >> Ultimately I'd like a vtkImageData object.
>> >>
>> >> I considered using vtkImageImport in java but there doesn't
>> >appear to
>> >> be any access to the two methods that actually copy data:
>> >> CopyImportVoidPointer() and SetImportVoidPointer().  :-/
>> >
>> >I went back to copying the data directly into a vtkImageData object
>> >and finally managed to get things working.  It turns out that the
>> >only bit that I had missed initially was to call SetWholeExtent().  
>> >Using just SetExtent() is not enough, it seems.
>> >
>> >
>> >I have read the VTK User's Guide.  The chapter on how the pipeline
>> >operates is helpful, but I'm still not sure exactly what is the
>> >distinction between "extent", "whole extent" and "update
>extent".  I
>> >get the feeling that the update extent is set at the output end of
>> >the pipeline (e.g. by mappers) and propagated backwards towards the
>> >source objects, but even that is not clear.  Who is responsible for
>> >setting the other two extents?  And what is a "ghost level"?
>> >
>> >Is there any documentation that defines these terms?
>> >
>> >How about source code: is there a particularly good class to start
>> >with?  Data class?  Source class?  Reader?
>> >
>> >Thanks,
>> >-Steve
>> >
>> >
>> _______________________________________________
>> 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
>
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Ghosts and Extents (was vtkImageImport in java?)

David E DeMarle
In reply to this post by Steve M. Robbins
Ghost levels are used in VTK parallel applications to keep track of
which cells/points are managed by the local processor and which are just
kept locally for convenience.

With four points, two processors and one level of ghost cells the two
processes ghost level arrays would look something like this:

P0[0 0 1 -]
P1[- 1 0 0]

Here each process owns two points (marked with a 0), keeps around one
point owned by the other (marked with a 1) and doesn't have any
information at all about the last point (marked with a -).

hth
Dave DeMarle

>-Steve
>P.S.  I still don't know what ghost levels are.  Anyone?
>
>  
>

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

when is ok to Delete()

santana
Hi, I have the following code on the inside of 3 nested loops. After all the
loops are finished I then get the output of the append filter. I seem to be
running out of memory before the loops complete. My question is: can I
Delete() vtkExtractGeometry, and vtkPlanes objects  before I GetOutput of the
vtkAppendFilter? or do I have to keep all these around till after GetOutput()
is called?


vtkAppendFilter *af = ...;

for (...)
for (...)
for (...)

if ( ( ints = this->BoxIntersect(coarseBox, fineBox) ) != NULL )
{// intersection is not empty
           
  vtkPlanes           *removeThis    = vtkPlanes::New();
  vtkExtractGeometry  *removalFilter = vtkExtractGeometry::New();
           
  //
  // remove the overlap region from coarse data
  //
  removeThis->SetBounds(ints);
  removalFilter->ExtractBoundaryCellsOff();
  removalFilter->ExtractInsideOff();
  removalFilter->SetImplicitFunction(removeThis);
  removalFilter->SetInput(coarseBox);
           
  af->AddInput( removalFilter->GetOutput() );
  af->Update();
 
  //
  // should I Delete() removeThis and removalFilter here??
  //
}

endfor(...)
endfor(...)
endfor(...)

return af->GetOutput();

--

Burlen Loring
Space Science Center
Institute for the Study of Earth, Oceans, and Space
University of New Hampshire
39 College Road, Durham, NH 03824
Phone: 603-862-1140
_______________________________________________
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