[vtkusers] Writing a JPEG from vtkActor

Dominik Szczerba domi at vision.ee.ethz.ch
Wed Dec 21 13:18:05 EST 2005


I figured out for sure that ShiftScale is innocent. It is the multiple 
instances of VECTORS and SCALARS in the input files. The documentation 
is not clear on this point at all, see the other thread:

[confusion about scalars/vectors and field data]

Using exclusively field data eliminates the problem, however, 
appearently it's a trap.
Dominik

Dominik Szczerba wrote:
> For me the problem is VTK crashing on ShiftScale operation on files
> containing many vector/scalar data. Paraview reads the file OK, VTK CVS
> 15DEC05 crashes. But if I break the file into one scalar per file the
> problem is not there anymore. That is what I added to the bug tracker.
> thank you
> Dominik
> 
> Amy Squillacote wrote:
> 
>>At 11:30 AM 12/20/2005, Dominik Szczerba wrote:
>>
>>
>>>>I always have to check the source code to see which way it should go.
>>>>Could I suggest adding a simpler API like:
>>>>
>>>> SetOutputRange(lowValue, highValue)?
>>>
>>>
>>>I strongly second the notion.
>>>Dominik
>>
>>
>>So this suggestion doesn't get lost, please add this as a feature
>>request to the bug tracker: http://public.kitware.com/Bug/.  (You'll
>>need to create an account for yourself in the bug tracker in order to
>>add a bug / feature request.)
>>
>>- Amy
>>
>>
>>>>>
>>>>>>  vtkPNGWriter* writer = vtkPNGWriter::New();
>>>>>>  writer->SetInput(iss->GetOutput());
>>>>>>  writer->SetFileName(argv[2]);
>>>>>>  writer->Write();
>>>>>>
>>>>>>Always the first scalar is taken, regardles of explicit selection
>>>
>>>with
>>>
>>>>>>setActiveScalarrs. The info seems displayed properly (of the first
>>>>>>scalar) whih is in my case -9.11732e-06 1.53533e-05, output is black
>>>>>>image (empty histogram).
>>>>>>I will be grateful if you shed some light on this mystery.
>>>>>>Dominik
>>>>>>
>>>>>>Amy Squillacote wrote:
>>>>>>
>>>>>>>Try using vtkImageShiftScale instead.  Do something like the
>>>>>>
>>>>>>following.
>>>>>>
>>>>>>>double range[2];
>>>>>>>grid->GetCellData()->GetScalars("abc")->GetScalarRange(range);
>>>>>>>
>>>>>>>vtkImageShiftScale *iss = vtkImageShiftScale::New();
>>>>>>>iss->SetInput(grid);
>>>>>>>iss->SetOutputScalarTypeToUnsignedChar();
>>>>>>>iss->SetShift(-range[0]);
>>>>>>>iss->SetScale((range[1] - range[0]) / 256.0);
>>>>>>>
>>>>>>>Are you sure that the data in your grid (a vtkImageData, I assume)
>>>>>>
>>>>>>is in
>>>>>>
>>>>>>>cell data? It's usually in point data.
>>>>>>>
>>>>>>>- Amy
>>>>>>>
>>>>>>>At 09:44 AM 12/20/2005, Dominik Szczerba wrote:
>>>>>>>
>>>>>>>
>>>>>>>>Thanks a lot, yes, I am trying the vtkImageCast, compiles fine,
>>>>>>
>>>>>>but get
>>>>>>
>>>>>>>>a black image at the end. Shouldnt I set ranges somewhere?
>>>>>>>>I can do
>>>>>>>>
>>>>>>>>grid->GetCellData()->GetScalars("abc")->GetRange())
>>>>>>>>
>>>>>>>>but where do I plug the output?
>>>>>>>>
>>>>>>>>Dominik
>>>>>>>>
>>>>>>>>Amy Squillacote wrote:
>>>>>>>>
>>>>>>>>>Try using either vtkImageCast or vtkImageShiftScale to change
>>>
>>>your
>>>
>>>>>>>>image
>>>>>>>>
>>>>>>>>>data to contain either unsigned char or unsigned short data.
>>>>>>>>>
>>>>>>>>>- Amy
>>>>>>>>>
>>>>>>>>>At 08:58 AM 12/20/2005, Dominik Szczerba wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>What is the error? I try to do the same with vtkPNGWriter
>>>>>>
>>>>>>ending up
>>>>>>
>>>>>>>>with:
>>>>>>>>
>>>>>>>>>>vtkPNGWriter (0x8058948): PNGWriter only supports unsigned char
>>>>>>
>>>>>>and
>>>>>>
>>>>>>>>>>unsigned short inputs
>>>>>>>>>>
>>>>>>>>>>Meanwhile I try to figure out how to do the appropriate
>>>>>>
>>>>>>convertion in
>>>>>>
>>>>>>>>>>vtk.
>>>>>>>>>>--dsz
>>>>>>>>>>
>>>>>>>>>>Marlos Fabris wrote:
>>>>>>>>>>
>>>>>>>>>>>Hi,
>>>>>>>>>>>
>>>>>>>>>>>I'm trying to write a jpeg file (using vtkJPEGWriter) from a
>>>>>>>>
>>>>>>>>vtkActor
>>>>>>>>
>>>>>>>>>>>but I can't accomplish this. I have a vtk file with
>>>
>>>structured
>>>
>>>>>>>>points
>>>>>>>>
>>>>>>>>>>>data and I wish to transform to vtkPolyData and color it
>>>
>>>with my
>>>
>>>>>>>>>>>vtkLookupTable.
>>>>>>>>>>>
>>>>>>>>>>>Is there a way to convert only my vtkActor to a vtkImageData,
>>>>>>>>
>>>>>>>>without
>>>>>>>>
>>>>>>>>>>>the frameborders of vtkWindowToImageFilter?
>>>>>>>>>>>
>>>>>>>>>>>Or is there a way to trim my image?
>>>>>>>>>>>
>>>>>>>>>>>Thank you in advance,
>>>>>>>>>>>
>>>>>>>>>>>Marlos Fabris
>>>>>>>>>>>_______________________________________________
>>>>>>>>>>>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
>>>>>>>>>>
>>>>>>>>>>--
>>>>>>>>>>Dominik Szczerba, Dr.
>>>>>>>>>>ETZ C110 CO-ME/BIWI CH-8092 Zurich
>>>>>>>>>>http://www.vision.ee.ethz.ch/~domi
>>>>>>>>>>_______________________________________________
>>>>>>>>>>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
>>>>>>>>
>>>>>>>>--
>>>>>>>>Dominik Szczerba, Dr.
>>>>>>>>ETZ C110 CO-ME/BIWI CH-8092 Zurich
>>>>>>>>http://www.vision.ee.ethz.ch/~domi
>>>>>>>>_______________________________________________
>>>>>>>>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
>>>>>>
>>>>>>--
>>>>>>Dominik Szczerba, Dr.
>>>>>>ETZ C110 CO-ME/BIWI CH-8092 Zurich
>>>>>>http://www.vision.ee.ethz.ch/~domi
>>>>>>_______________________________________________
>>>>>>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
>>>>
>>>>
>>>>_________________________________________________________________
>>>>Don�t just search. Find. Check out the new MSN Search!
>>>>http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>>>
>>>-- 
>>>Dominik Szczerba, Dr.
>>>ETZ C110 CO-ME/BIWI CH-8092 Zurich
>>>http://www.vision.ee.ethz.ch/~domi
>>>_______________________________________________
>>>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/vtkuser
>>
>>s
> 
> 

-- 
Dominik Szczerba, Dr.
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi



More information about the vtkusers mailing list