[vtkusers] quick vtkImageData question

John Durkin jrd5084 at psu.edu
Mon Apr 26 14:35:02 EDT 2010


Nevermind fixed it.  I was mixing up i and j and forgot to increment ptr2.
Fixed below

        for(int i = 0; i < 720; i++)
        {
            for(int j = 0; j < 720; j++)
            {
                if(j <600 && j > 119 && i < 680 && i > 39)
                {
                    *ptr = *ptr2;
                    *ptr++;
                    *ptr2++;
                    *ptr = *ptr2;
                    *ptr++;
                    *ptr2++;
                    *ptr = *ptr2;
                    *ptr++;
                    *ptr2++;


                }
                else
                {
                    *ptr++;
                    *ptr++;
                    *ptr++;


                }



            }

        }

On Mon, Apr 26, 2010 at 2:27 PM, John Durkin <jrd5084 at psu.edu> wrote:

> Hi vtk community,
>
> I can't seem to remember how the data is represented in vtkImageData.  I
> have a 720x720x1 3 component RGB image being represented by vtkImageData.  I
> am using imageData->GetScalarPointer() to access the data.  I have another
> image 480x640x1 3 component RGB that I want to place in the middle of the
> new image.  Here is the code I have but its not lining up correctly.  Any
> ideas?
>
>
> thanks,
>
> John
>
>
>     ptr = (unsigned char*)imageData->GetScalarPointer();
>         unsigned char *ptr2 = (unsigned char*)origData->GetScalarPointer();
>
>
>         for(int i = 0; i < 720; i++)
>         {
>             for(int j = 0; j < 720; j++)
>             {
>                 if(i <600 && i > 119 && j <680 && j > 39)
>                 {
>                     *ptr = *ptr2;
>                     *ptr++;
>                     *ptr = *ptr2;
>                     *ptr++;
>                     *ptr = *ptr2;
>                     *ptr++;
>
>
>                 }
>                 else
>                 {
>                     *ptr++;
>                     *ptr++;
>                     *ptr++;
>
>
>                 }
>
>
>
>             }
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100426/34af8bf2/attachment.htm>


More information about the vtkusers mailing list