texture only on 1 side

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

texture only on 1 side

h0ppel
hi,

I create an image from pixel data like this:

tkFloatArray vtkArray = new vtkFloatArray();
            vtkArray.SetNumberOfComponents(1);
            vtkArray.SetNumberOfTuples(320 * 240);

            int indexInverted = 0;

            for (int k = 0; k < 240; k++)
            {
                for (int i = 0; i < 320; i++)
                {
                    vtkArray.SetTuple1(indexInverted, CamData[indexInverted]);
                    indexInverted++;
                }
            }
            if (ImageData == null)
            {
                ImageData = new vtkImageData();
            }
            ImageData.SetDimensions(320, 240, 1);
            ImageData.SetSpacing(1, 1, 1);
            ImageData.SetOrigin(0, 0, 0);
            ImageData.SetNumberOfScalarComponents(1);
            ImageData.SetScalarTypeToFloat();
            ImageData.AllocateScalars();
            ImageData.GetPointData().SetScalars(vtkArray);

            if (contour == null)
            {
                contour = new vtkContourFilter();
                contour.SetInput(ImageData);
                contour.Update();
            }

            vtkLookupTable table = new vtkLookupTable();
            table.SetTableRange(0, 65536);
            table.SetValueRange(0.0,1.0);
            table.SetSaturationRange(0.0,0.0);
            table.SetHueRange(0.0,0.0);
            table.SetAlphaRange(1.0,1.0);
            table.SetNumberOfColors(65536);
            table.Build();



            // Create texture
            vtkTexture atext = new vtkTexture();
            atext.SetInput(ImageData);
            atext.SetLookupTable(table);
            atext.InterpolateOff();

            vtkImageViewer2 viewer = new vtkImageViewer2();
            viewer.SetColorLevel(0.0);
            viewer.SetColorWindow(65536);
            viewer.SetInput(ImageData);
            viewer.Render();

            vtkPlaneSource plane = new vtkPlaneSource();
              plane.SetCenter(0.0, 0.0, 0.0);
              plane.SetNormal(0.0, 0.0, 1.0);



             vtkPolyDataMapper planeMapper = new vtkPolyDataMapper();
             planeMapper.SetInputConnection(plane.GetOutputPort());

             if (texActor == null)
             {
                  texActor = new vtkActor();
             }
             texActor.SetMapper(planeMapper);
             texActor.SetTexture(atext);

and it works.. but now I have 2 questions:

1) I want the image only on one side of the plane not on both. The other side should be black
2) How can I work with this texturedata? how can I put this into vtkImageLuminance for example?

thanks
Reply | Threaded
Open this post in threaded view
|

Re: texture only on 1 side

Aashish Chaudhary-2
On Wed, Aug 17, 2011 at 7:26 AM, h0ppel <[hidden email]> wrote:

> hi,
>
> I create an image from pixel data like this:
>
>
>
> and it works.. but now I have 2 questions:
>
> 1) I want the image only on one side of the plane not on both. The other
> side should be black

The easiest way would be to draw two quads. Or you can have two pass
rendering (enabling / disabling front and back face alternatively)

> 2) How can I work with this texturedata? how can I put this into
> vtkImageLuminance for example?

Didn't understand this questions. Can you elaborate more?

>
> thanks
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/texture-only-on-1-side-tp4707772p4707772.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK 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: texture only on 1 side

h0ppel
In reply to this post by h0ppel
thanks so far,

after I created the picture, I want to do more operations with this picture like this:

vtkImageLuminance luminance = new vtkImageLuminance();
            luminance.SetInput(imagedata);

the luminance filter needs an imagadata as input, but I dont have Imagedata that I can use correctly. I only have my plane, my texture and my imagedata from the array. but putting only the imagedata in the luminance filter will not work, first I need zu interpret the pixelvalue like I do in the viewer

viewer.SetColorWindow(65536);

without this I can see anythink from my picture in the viewer...
But I dont know what to do with my imagedata, that I can put it into the luminance filter and the correct picture like the texture


Reply | Threaded
Open this post in threaded view
|

Re: texture only on 1 side

h0ppel
In reply to this post by Aashish Chaudhary-2
I found a better way to get the image:

                 if (colorize == null)
             {
                 colorize = new vtkImageMapToColors();
                 colorize.SetOutputFormatToRGB();
                 colorize.SetLookupTable(table);
                 colorize.SetInput(ImageData);
                 colorize.Update();
             }

now I can put the image into other filters... but the image does still have 2 sides and I want only the backside of the image?

but still dont know how to do?

t