[vtkusers] Re: Writing a JPEG from vtkActor

Marlos Fabris marlos.fabris at gmail.com
Wed Dec 21 05:39:15 EST 2005


The code is written in C# and I'm using a .NET wrapper, available at:
http://herakles.zcu.cz/research/vtk.net/

vtkStructuredPointsReader reader = vtkStructuredPointsReader.New();
reader.SetFileName("data.vtk");

vtkStructuredPoints grid = reader.GetOutput();
grid.Update();

float[] range;
range = new float[2];
grid.GetPointData().GetScalars("scalars").GetRange(range);
grid.GetPointData().SetActiveScalars("scalars");

vtkImageShiftScale iss = vtkImageShiftScale.New();
iss.SetInput(grid);
iss.SetOutputScalarTypeToUnsignedChar();

vtkLookupTable oLUT1 = vtkLookupTable.New();
oLUT1.SetRange(grid.GetScalarRange());
oLUT1.SetHueRange(0.667f, 0.0f);
oLUT1.SetNumberOfTableValues(1024);
oLUT1.Build();

vtkImageMapToColors oIMTC1 = vtkImageMapToColors.New();
oIMTC1.SetLookupTable(oLUT1);
oIMTC1.SetInput(iss.GetOutput());

vtkImageResample oIR1 = vtkImageResample.New();
oIR1.SetInput(oIMTC1.GetOutput());
oIR1.SetInterpolationModeToCubic();
oIR1.SetAxisMagnificationFactor(0, 2);
oIR1.SetAxisMagnificationFactor(1, 2);

vtkPNGWriter writer = vtkPNGWriter.New();
writer.SetInput(oIR1.GetOutput());
writer.SetFileName("image1.png");
writer.Write();

Console.WriteLine("Press any key to exit...");
Console.Read();

Marlos Fabris
IT Analyst
Institute of Technology for Development
Curitba - Paraná - Brazil
http://www.lactec.org.br/

On 12/20/05, Dominik Szczerba <domi at vision.ee.ethz.ch> wrote:
> Could you please post the relevant lines of code (including the lookup
> table creation)? I never managed to get it working.
> thanks
> Dominik
>
> Marlos Fabris wrote:
> > I found a solution. For example, using the code provided by Dominik
> > Szczerba, I simply used vtkImageMapToColors and assign my
> > vtkLookupTable, just before writing the file. So, I think this is the
> > answer for my own question.
> >
> > Regards,
> >
> > Marlos Fabris
> >
> > On 12/20/05, Marlos Fabris <marlos.fabris at gmail.com> wrote:
> >
> >>Trying to figure out the problem from another perspective.
> >>
> >>What I would like to do is read a vtkStructuredPoints file and create
> >>an image from it (my data is only 2d) with the vtkLookupTable
> >>configured by me. And after this, create a 2d image without the
> >>background borders from using vtkWindowToImageFilter. After this, I
> >>will take the image and apply as a texture in another software. Is
> >>there a way to do this? As I said, I was trying to use some filter,
> >>but I couldn't convert vtkActor to vtkImageData.
> >>
> >>Thank you,
> >>
> >>Marlos Fabris
> >>
> >>On 12/20/05, Marlos Fabris <marlos.fabris at gmail.com> 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.
> Computer Vision Lab 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
>



More information about the vtkusers mailing list