[Insight-users] Help on getting and reading image buffer
Xuejun
sd2usa at gmail.com
Fri Aug 25 01:57:53 EDT 2006
Dear all ITK users and developers;
I am trying to getting the image buffer and input it into a OpenGL function
gluScaleImage to resize the image. Unfortunately my code does not work
despite my many times try. The major part of the code is listed as follows:
..
try
{
reader->Update();
}
catch (itk::ExceptionObject & err)
{
std::cerr << "exception in file reader " <<
std::endl;
std::cerr << err << std::endl;
return ;
}
InputImageType::Pointer image = reader->GetOutput() ;
const InputImageType::RegionType ®ion = image->GetBufferedRegion() ;
// image size
unsigned long lwidth = image->GetBufferedRegion().GetSize()[0] ;
unsigned long lheight = image->GetBufferedRegion().GetSize()[1] ;
// set up new size
double factor = 0.5 ;
int nNewWidth = (int)lwidth * factor;
int nNewHeight = (int)lheight * factor;
unsigned char rasterNew = new unsigned char [nNewHeight * nNewWidth] ;
// resize the image buffer
int iscale = gluScaleImage(GL_RGBA, (GLint)lwidth, (GLint)lheight,
GL_UNSIGNED_BYTE, ®ion, (GLint)nNewWidth, (GLint)nNewHeight,
GL_UNSIGNED_BYTE, rasterNew ) ;
But the output of the function iscale=gluScaleImage is 1285. I also tried to
use InputPixelType *pointer = image->GetBufferPointer();. It does not work
either.
My questions are:
1. How to get and reading the buffer of the image after reading an
image file? Is the method in the above code correct?
2. What does it mean by the return value 1285 of the OpenGL function (I
used a DICOM image with unsigned char type and it is successfully read by
the code)? Is the first item (pixel format) I set GL_RGBA correct? and how
to fix the problem?
Your kind help is greatly appreciated.
Best regards,
Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060825/50275106/attachment.html
More information about the Insight-users
mailing list