[vtkusers] imagedata appearing upside down (sometimes..?)

Luke Hua luke_qz at yahoo.com
Mon Mar 22 21:15:09 EST 2004


Hi,
 
Just read this thread. I happened to have same problem. I used vtkimagereader to read raw data and generated a surface, but found out it is in reverse direction.
 
How could I reverse it?
 
Thanks!
 
                                                                      Luke 

Mathieu Malaterre <mathieu.malaterre at kitware.com> wrote:
Howard,

Ok that's what I wanted ! Where does your data comes from ? Did you 
know that VTK read the image data upside down ? Have a look at any image 
reader like png, jpeg, tiff. You'll see that we read starting from the 
bottom. So make sure your array is read starting from the bottom.

Or more generally use an already existing reader.

HTH,
Mathieu

Howard Katz wrote:
> Also,
> just note that I input data using:
> 
> VelocityVsTimeSampleFloatArray->SetVoidArray(array,TotalTimePoints*TotalCycles*NumBins, 
> 1 );
> 
> where array is a 1D float array whcih represents a 2D array through 
> subscirpt arithemtic by doing:
> 
> array [ row*TotalColumns + col ] = value;
> 
> Thanks..!
> Howard
> 
>> From: "Howard Katz" 
>> To: mathieu.malaterre at kitware.com
>> CC: vtkusers at vtk.org
>> Subject: Re: [vtkusers] imagedata appearing upside down (sometimes..?)
>> Date: Mon, 22 Mar 2004 23:11:20 +0000
>>
>> Hi,
>>
>> I called GetSpacing and it returns (1,1,1) just as I had specified..
>> And I know the input values are correct i.e they're not negative or 
>> anything because I also outputted this..
>> And I noticed that whenever I don't add a camera to my renderer, 
>> nothing happens when I change the spacing, is this normal?
>> Okay below is some C++ code,
>> So again its werid because the whole thing appears upside down only 
>> for some cases and not others..?
>> Anyways here it is:
>>
>> VelocityVsTimeSampleFloatArray->SetNumberOfComponents(1);
>> VelocityVsTimeSampleFloatArray->SetNumberOfTuples(TotalCycles*NumVelocityBins*TotalTimePoints 
>> );
>> VelocityVsTimeSampleImageData->SetOrigin(-30, -85, 0);
>> VelocityVsTimeSampleImageData->GetPointData()->SetScalars(VelocityVsTimeSampleFloatArray); 
>>
>> VelocityVsTimeSampleImageData->SetDimensions(TotalCycles*TotalTimePoints,NumVelocityBins, 
>> 1);
>> VelocityVsTimeSampleImageData->SetScalarType(VTK_FLOAT);
>> VelocityVsTimeSampleImageData->SetSpacing(1, 1, 1);
>>
>> ImageCast->SetInput( VelocityVsTimeSampleImageData);
>> ImageCast->SetOutputScalarTypeToUnsignedChar();
>>
>> ImageMapToColors->SetInput(ImageCast->GetOutput());
>> ImageMapToColors->SetLookupTable(SpectLUT);
>>
>> SpectActor->SetInput(ImageMapToColors->GetOutput());
>> SpectActor->SetDisplayExtent( 0, TotalCycles*TotalTimePoints-1, 0, 
>> NumVelocityBins-1, 0, 0 );
>>
>> Cam->SetPosition(0, 0, 325);
>> Cam->SetFocalPoint(0,0,0);
>>
>> Ren1->SetBackground(0.3, 0.3, 0.3);
>> Ren1->SetActiveCamera(Cam);
>> Ren1->AddActor( SpectActor );
>>
>> RenWin->AddRenderer( Ren1 );
>> RenWin->SetSize( 500, 500 );
>> RenWin->SetInteractor(Iren);
>> Iren->SetStillUpdateRate(1000);
>> Iren->SetDesiredUpdateRate(1000);
>> Iren->Initialize();
>> Iren->Render();
>>
>>
>>
>>
>>> From: Mathieu Malaterre 
>>> To: Howard Katz 
>>> CC: vtkusers at vtk.org
>>> Subject: Re: [vtkusers] imagedata appearing upside down (sometimes..?)
>>> Date: Mon, 22 Mar 2004 17:34:30 -0500
>>>
>>> Howard,
>>>
>>> What does :
>>>
>>> //Call Update() before
>>> print imagedata.GetSpacing()
>>>
>>> return ?
>>> Could you reproduce the bad behavior using a tests from VTK ? Or 
>>> could you send us a python/c++/tcl code that shows this problem.
>>>
>>> Thanks
>>> Mathieu
>>>
>>> Howard Katz wrote:
>>>
>>>> Hi..
>>>> What do you mean my spacing 'can' be negative...?
>>>> :S
>>>> Thanks again..!
>>>>
>>>>
>>>>
>>>>> From: Mathieu Malaterre 
>>>>> To: Howard Katz 
>>>>> CC: vtkusers at vtk.org
>>>>> Subject: Re: [vtkusers] imagedata appearing upside down (sometimes..?)
>>>>> Date: Mon, 22 Mar 2004 13:13:18 -0500
>>>>>
>>>>> Howard Katz wrote:
>>>>>
>>>>>> Hi,
>>>>>> so has anyone run into the problem where their vtkImageData looks 
>>>>>> upside down only sometiems depending on the input values..? i.e. 
>>>>>> I know I am inputting values 10, 20, 15 (for example) but these 
>>>>>> appear at rows -10, -20, -15 (..and this will happen for the 
>>>>>> entire image data)
>>>>>>
>>>>>> Can anyoen guess what my problem might be?
>>>>>
>>>>>
>>>>>
>>>>> You spacing can be negative, this happens typically in medical 
>>>>> image data such a MINC or DICOM
>>>>>
>>>>> HTH
>>>>> Mathieu
>>>>>
>>>>>
>>>>
>>>> _________________________________________________________________
>>>> All the action. All the drama. Get NCAA hoops coverage at MSN Sports 
>>>> by ESPN. http://msn.espn.go.com/index.html?partnersite=espn
>>>>
>>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> This is the private VTK discussion list. Please keep messages 
>>> on-topic. Check the FAQ at: 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>> _________________________________________________________________
>> Get tax tips, tools and access to IRS forms ?all in one place at MSN 
>> Money! http://moneycentral.msn.com/tax/home.asp
>>
>> _______________________________________________
>> This is the private VTK discussion list. Please keep messages 
>> on-topic. Check the FAQ at: 
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 
> _________________________________________________________________
> Is your PC infected? Get a FREE online computer virus scan from McAfee?
> Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> 
> _______________________________________________
> This is the private VTK discussion list. Please keep messages on-topic. 
> Check the FAQ at: 
> 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: 
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040322/4d463075/attachment.htm>


More information about the vtkusers mailing list