[vtkusers] newbie question: how to access BMP pixels

Amy Henderson amy.henderson at kitware.com
Tue Jul 20 08:44:09 EDT 2004


Hi Fred,

Call Update() on the reader before you ask for its output.

- Amy

At 08:11 PM 7/19/2004, Fred August wrote:
>Hi
>
>I'm trying to access the grayscale pixels of a BMP.
>I'd like to know what is the first pixel in any
>direction, starting from the center of my BMP, to be
>above a certain level of luminance.
>
>I tried the following code
>
>
>vtkBMPReader *reader = vtkBMPReader::New();
>   reader->SetFileName("slice.bmp");
>
>vtkImageData *vol = vtkImageData::New();
>   vol = reader->GetOutput();
>
>int n;
>n=vol->GetPointData()->GetScalars()->GetNumberOfTuples();
>cout << img_size << endl;
>
>
>
>thinking that then I'd use GetTuple1() to get the
>scalar element that I'm interested in, but I get an
>access violation since the vtkDataArray whose number
>of tuples I trie to read turns out to be NULL. The
>image loads just fine though... so I'm imagining that
>there's some basic problem that I just don't get...
>
>Also, i tried the same code on a vtkImageData that I
>built (the Vol.cxx example sphere data set) and
>everything worked fine.
>
>Any help on why this is happening and/or on a better
>way to access pixels of a BMP would be great!
>
>thanks!
>
>f
>
>
>
>
>
>
>____________________________________________________________
>Yahoo! Companion - Scarica gratis la toolbar di Ricerca di Yahoo!
>http://companion.yahoo.it
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: 
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers






More information about the vtkusers mailing list