[vtkusers] quick vtkImageData question
David Doria
daviddoria+vtk at gmail.com
Mon Apr 26 14:37:38 EDT 2010
On Mon, Apr 26, 2010 at 2:35 PM, John Durkin <jrd5084 at psu.edu> wrote:
> 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++;
>>
>>
>> }
>>
>>
>>
>> }
>> }
>
I'm glad you got it working, but I thought I'd make sure you were
aware of these classes. I think you could use a combination of
vtkImageMask, vtkImageConstantPad and vtkImageMathematics to do
something like this.
Dave
More information about the vtkusers
mailing list