[vtkusers] RE: vtkusers Digest, Vol 14, Issue 5

Abhi Rampal a_rampal at hotmail.com
Fri Jun 3 12:10:48 EDT 2005


Good Day Amy,

Thank you for the solution - it worked. The problem now is the window stays 
but the image does not come up, i.e. all I get is a black screen. I tried to 
open up a *.jpg image using the same code and got the same results (black 
screen). Do you have a solution to this? Is there a site or a book that has 
examples and explains VTK coding in C++. I am new to VTK and using the VTK 
User's Guide to learn it but eveything is in TCL (which I do not know).

The code that I am using is:

int main(int argc, char *argv[])
{

  vtkImageReader *reader = vtkImageReader::New();
  reader->SetDataByteOrderToLittleEndian();
  reader->SetDataExtent(0,63,0,63,40,40);
  reader->SetFilePrefix("C:\\vtk\\VTKData\\Data\\headsq\\quarter");
  reader->SetDataMask(0x7fff);

  vtkImageGradient *gradient = vtkImageGradient::New();
  gradient->SetInput(reader->GetOutput());
  gradient->SetDimensionality(3);

  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

  vtkImageViewer *viewer = vtkImageViewer::New();
  viewer->SetInput(gradient->GetOutput());           //Added Lines
  viewer->SetZSlice(22);
  viewer->SetColorWindow(2000);
  viewer->SetColorLevel(0);
  viewer->SetupInteractor(iren);                           //Added Lines
  viewer->Render();

  iren->Start();                                                  //Added 
Lines

Thank you and with kind regards,

Abhi

>From: vtkusers-request at vtk.org
>Reply-To: vtkusers at vtk.org
>To: vtkusers at vtk.org
>Subject: vtkusers Digest, Vol 14, Issue 5
>Date: Thu,  2 Jun 2005 15:52:43 -0400 (EDT)
>
>Send vtkusers mailing list submissions to
>	vtkusers at vtk.org
>
>To subscribe or unsubscribe via the World Wide Web, visit
>	http://www.vtk.org/mailman/listinfo/vtkusers
>or, via email, send a message with subject or body 'help' to
>	vtkusers-request at vtk.org
>
>You can reach the person managing the list at
>	vtkusers-owner at vtk.org
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of vtkusers digest..."
>
>
>Today's Topics:
>
>    1. formatting (Justin)
>    2. Re: formatting (Amy Squillacote)
>    3. Re: vtkFixedPointVolumeRayCastMapper question (Randall Hand)
>    4. vtkImageViewer Help (Abhi Rampal)
>    5. Re: vtkImageViewer Help (Amy Squillacote)
>    6. fluttering problem, double buffering, memory buffering
>       (Renaud Isabelle)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Thu, 02 Jun 2005 12:04:10 -0400
>From: Justin <hanloj at rpi.edu>
>Subject: [vtkusers] formatting
>To: vtkusers at vtk.org
>Message-ID: <429F2DFA.5060105 at rpi.edu>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>does anybody know how to change a file from vtk format to stl format
>
>Thanks,
>Justin
>
>
>------------------------------
>
>Message: 2
>Date: Thu, 02 Jun 2005 13:04:45 -0400
>From: Amy Squillacote <amy.squillacote at kitware.com>
>Subject: Re: [vtkusers] formatting
>To: vtkusers at vtk.org
>Message-ID: <6.2.1.2.2.20050602130210.03fc5eb8 at pop.biz.rr.com>
>Content-Type: text/plain; charset="us-ascii"; format=flowed
>
>Hi Justin,
>
>Assuming your vtk data file contains polygonal data, do the following.
>
>vtkPolyDataReader *reader = vtkPolyDataReader::New();
>reader->SetFileName("foo.vtk");
>
>vtkSTLWriter *writer = vtkSTLWriter::New();
>writer->SetFileName("foo.stl");
>writer->Write();
>
>reader->Delete();
>writer->Delete();
>
>- Amy
>
>At 12:04 PM 6/2/2005, Justin wrote:
> >does anybody know how to change a file from vtk format to stl format
> >
> >Thanks,
> >Justin
> >_______________________________________________
> >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
>
>
>
>------------------------------
>
>Message: 3
>Date: Thu, 2 Jun 2005 12:52:46 -0500
>From: Randall Hand <randall.hand at gmail.com>
>Subject: Re: [vtkusers] vtkFixedPointVolumeRayCastMapper question
>To: Lisa Avila <lisa.avila at kitware.com>
>Cc: VTK Users <vtkusers at vtk.org>
>Message-ID: <b022647205060210527062b3a9 at mail.gmail.com>
>Content-Type: text/plain; charset="iso-8859-1"
>
>Ok, I was finally able to resolve this. the problem seems to have been in
>how I was combining the 2 datasets. I'm guessing the 
>FixedPointRayCastMapper
>must be doing some fancy pointer magic for speed, but when I used a :
>OpacityData->GetPointData()->AddArray(Colordata->GetPointData()->GetArray("colorField"))
>and then a vtkMergeFields to combine the two arrays, it didn't work.
>
>I simply switched to using a vtkImageAppendComponents and it works 
>perfectly
>now.
>
>(Sorry Lisa, forgot to include the mailing list the first time... Reply vs
>Reply All :) )
>
>On 5/25/05, Lisa Avila <lisa.avila at kitware.com> wrote:
> >
> >
> > Well, the TestFixedPoint*.tcl scripts test all the configurations 
>(single
> > component, multiple component, independent, not independent, shade on, 
>shade
> > off, nearest, linear, MIP, composite, etc.) and this test is passing so
> > there is at least one example of 2 component dependent data rendering
> > correctly. Can you try this: save the data that you input to the volume
> > mapper. Can you load this into VolView? The mapper has changed quite a 
>bit
> > since that released version, but it should at least give us a clue that 
>your
> > data is what you expect it to be. The fact that you have a solid black 
>cube
> > when you don't have shading on and your color transfer function is set 
>to
> > solid red is suspicious. What type is your data? (int, float, unsigned
> > char,....?) (The test only checks unsigned char for two component 
>depended -
> > I can change it to your data type if that is different to see if a 
>problem
> > arises.) Does your color function span the scalar range of your first
> > component? (Shouldn't matter since Clamping is on by default, but 
>perhaps
> > you turned it off?)
> >
> > Thanks,
> >
> > Lisa
> >
> >
> > At 03:04 PM 5/25/2005, Randall Hand wrote:
> >
> > Sadly, none of that worked.
> > 1) Checked, and even if I have them backwards I should see something 
>other
> > than a blurry black spot.
> > 2) Tried, no difference really.. With shading on I get a few specular
> > highlights on my blurry black spot, but still isn't right.
> > 3) I'm working with offscreen Mesa rendering, which is why I had this 
>on.
> > I commented it out, so it would use the default, but still no dice.
> > 4) I set it to use all-red, and I still got my blurry black spot. I
> > changed it to be all-red, and all opaque (set my opacity function to a
> > constant 1) and my blurry black spot become a solid black brick (as
> > attached).
> >
> > Any ideas?
> >
> > On 5/25/05, *Lisa Avila* <lisa.avila at kitware.com > wrote:
> >
> > Looking quickly at your code I don't see anything obviously wrong.
> > However, I would suggest trying a few things to isolate the problem:
> >
> > 1) Make sure your first component is the one you want mapped to color, 
>and
> > the second is the one you want mapped to opacity.
> >
> > 2) Try volProp->ShadeOff(). Perhaps you do not have good gradients in 
>your
> > data and that is causing the problem (although you have a high ambient 
>so
> > that shouldn't be the problem...)
> >
> > 3) Leave your ImageSampleDistance at 1.0 (the default). Keep in mind 
>that
> > a distance of 0.5 means that you cast 4 rays for every pixels on the
> > screen. I believe when OpenGL maps this texture to the screen, it will
> > sample it for the pixel value, meaning that you are throwing away 3/4 of 
>the
> > information you created during ray casting.
> >
> > 4) If all these fail, try using a solid color transfer function (all
> > values map to red for example) - do you get what you expect?
> >
> >
> > Lisa
> >
> >
> >
> >
> > At 02:15 PM 5/25/2005, Randall Hand wrote:
> >
> > I have a long pipeline setup to render a multifield dataset. one field I
> > want mapped to opacity, and the other one is a vector that I want 
>magnitude
> > mapped to color.
> > My pipeline resembles the following:
> >
> >
> > vtkDataSetReader -> vtkArrayCalculator (to calculate magnitude) ->
> > vtkGaussianSplatter -> vtkImageShiftScale = Dataset with ColorField 
>single
> > component scalar
> >  +-> vtkGaussianSplatter -> ImageShiftScale = Dataset with OpacityField
> > single component scalar.
> >
> > I then do a
> > 
>OpacityData->GetPointData()->AddArray(Colordata->GetPointData()->GetArray("colorField")),
> > and pass the result through a vtkMergeFields to combine the 2 fields 
>into a
> > single dual-component field, and make the new field the Active Scalar.
> >
> >
> > I then construct my volume parts:
> >  vtkVolumeProperty *volProp = vtkVolumeProperty::New();
> >  volProp->IndependentComponentsOff();
> >  volProp->SetColor(xf_Color);
> >  volProp->SetScalarOpacity(xf_Opacity);
> >  volProp->SetInterpolationTypeToLinear();
> >  volProp->ShadeOn();
> >  volProp->SetAmbient(0.7);
> >
> >  // Now setup the Ray Caster
> >  vtkFixedPointVolumeRayCastMapper *modelMapper =
> > vtkFixedPointVolumeRayCastMapper::New();
> >  modelMapper->SetImageSampleDistance(0.5);
> >  modelMapper->SetSampleDistance(0.1);
> >  modelMapper->SetInput(mergeFilter->GetOutput());
> >
> >  // Creating Volume
> >  vtkVolume *volume = vtkVolume::New();
> >  volume->SetMapper(modelMapper);
> >  volume->SetProperty(volProp);
> >  volume->Update();
> >
> > When all is said and done, however, I just get a darkish blurry spot
> > (image Attached). Can anyone see what's wrong, or have I exposed a bug 
>in
> > the FixedPointVolumeRayCastMapper ? I've been waiting to do this since I
> > figured out that the old VolumeRayCastMapper couldn't handle 
>multi-component
> > data, and i'm anxious to see this work for once :)
> > --
> > Randall Hand
> > http://www.yeraze.com
> > _______________________________________________
> > 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
> >
> >
> >
> >
> >
> > --
> > Randall Hand
> > http://www.yeraze.com
> > _______________________________________________
> > 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
> >
> >
>
>
>--
>Randall Hand
>http://www.yeraze.com
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL: 
>http://public.kitware.com/pipermail/vtkusers/attachments/20050602/a64bf4eb/attachment-0001.htm
>
>------------------------------
>
>Message: 4
>Date: Thu, 02 Jun 2005 18:28:08 +0000
>From: "Abhi Rampal" <a_rampal at hotmail.com>
>Subject: [vtkusers] vtkImageViewer Help
>To: vtkusers at vtk.org
>Message-ID: <BAY106-F336862C3B7C5149CAD42F5F2060 at phx.gbl>
>Content-Type: text/plain; format=flowed
>
>Good Day,
>
>I wrote a program in C++ to view DICOM images using vtKImageViewer. When I
>run the program the window into which the image is loaded closes
>automatically. With Polydata I woudl use vtkRenderWindowInteractor to keep
>the window open but this solution does not work with vtkImageViewer. Does
>anyone have a solution?
>
>the code being used is:
>
>   vtkImageReader *reader = vtkImageReader::New();
>   reader->SetDataByteOrderToLittleEndian();
>   reader->SetDataExtent(0,63,0,63,40,40);
>   reader->SetFilePrefix("C:\\vtk\\VTKData\\Data\\headsq\\quarter");
>   reader->SetDataMask(0x7fff);
>
>   vtkImageGradient *gradient = vtkImageGradient::New();
>   gradient->SetInput(reader->GetOutput());
>   gradient->SetDimensionality(3);
>
>   vtkImageViewer *viewer = vtkImageViewer::New();
>   viewer->SetInput(gradient->GetOutput());
>   viewer->SetZSlice(22);
>   viewer->SetColorWindow(2000);
>   viewer->SetColorLevel(0);
>   viewer->Render();
>
>   reader->Delete();
>   gradient->Delete();
>   viewer->Delete();
>
>Thank you and with kind regards,
>
>Abhi
>
>
>
>
>------------------------------
>
>Message: 5
>Date: Thu, 02 Jun 2005 14:39:10 -0400
>From: Amy Squillacote <amy.squillacote at kitware.com>
>Subject: Re: [vtkusers] vtkImageViewer Help
>To: vtkusers at vtk.org
>Message-ID: <6.2.1.2.2.20050602143729.03fc6520 at pop.biz.rr.com>
>Content-Type: text/plain; charset="us-ascii"; format=flowed
>
>Hi Abhi,
>
>Try creating a vtkRenderWindowInteractor and passing it to vtkImageViewer
>using its SetupInteractor method.  Then you should still be able to use the
>vtkRenderWindowInteractor to keep the window open.
>
>- Amy
>
>At 02:28 PM 6/2/2005, Abhi Rampal wrote:
> >Good Day,
> >
> >I wrote a program in C++ to view DICOM images using vtKImageViewer. When 
>I
> >run the program the window into which the image is loaded closes
> >automatically. With Polydata I woudl use vtkRenderWindowInteractor to 
>keep
> >the window open but this solution does not work with vtkImageViewer. Does
> >anyone have a solution?
> >
> >the code being used is:
> >
> >  vtkImageReader *reader = vtkImageReader::New();
> >  reader->SetDataByteOrderToLittleEndian();
> >  reader->SetDataExtent(0,63,0,63,40,40);
> >  reader->SetFilePrefix("C:\\vtk\\VTKData\\Data\\headsq\\quarter");
> >  reader->SetDataMask(0x7fff);
> >
> >  vtkImageGradient *gradient = vtkImageGradient::New();
> >  gradient->SetInput(reader->GetOutput());
> >  gradient->SetDimensionality(3);
> >
> >  vtkImageViewer *viewer = vtkImageViewer::New();
> >  viewer->SetInput(gradient->GetOutput());
> >  viewer->SetZSlice(22);
> >  viewer->SetColorWindow(2000);
> >  viewer->SetColorLevel(0);
> >  viewer->Render();
> >
> >  reader->Delete();
> >  gradient->Delete();
> >  viewer->Delete();
> >
> >Thank you and with kind regards,
> >
> >Abhi
> >
> >
> >_______________________________________________
> >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
>
>
>
>------------------------------
>
>Message: 6
>Date: Thu, 2 Jun 2005 21:51:18 +0200 (CEST)
>From: Renaud Isabelle <renauisa at yahoo.fr>
>Subject: [vtkusers] fluttering problem, double buffering, memory
>	buffering
>To: vtkusers at public.kitware.com, vtkusers at vtk.org,
>	insight-users at itk.org
>Message-ID: <20050602195118.35711.qmail at web26103.mail.ukl.yahoo.com>
>Content-Type: text/plain; charset="iso-8859-1"
>
>Hi guys,
>
>I'm displaying a 2D slice of a 3D image in a MFC GUI and using VTK.
>
>When I'm trying to change the slice to display, it works but I have 
>fluttering problem
>
>I'm triing to use doubble buffering and memory rendering but I really don't 
>know how to implement it.
>
>vtkWin32OpenGLRenderWindow owns SetOffScreenRendering and 
>SetupMemoryRendering() - ResumeScreenRendering(). How does it work? What is 
>the best to use?Does anyone have an example or any tutorial what I can look 
>at?
>
>Please help
>
>Isabelle
>
>
>---------------------------------
>  Découvrez le nouveau Yahoo! Mail : 1 Go d'espace de stockage pour vos 
>mails, photos et vidéos !
>Créez votre Yahoo! Mail
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL: 
>http://public.kitware.com/pipermail/vtkusers/attachments/20050602/dd12f5af/attachment.html
>
>------------------------------
>
>_______________________________________________
>vtkusers mailing list
>vtkusers at vtk.org
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>End of vtkusers Digest, Vol 14, Issue 5
>***************************************





More information about the vtkusers mailing list