[vtkusers] newbie question: how to access BMP pixels

Fred August pitoz at yahoo.com
Mon Jul 19 20:11:04 EDT 2004


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



More information about the vtkusers mailing list