[vtkusers] How To Change A 24 Bits BMP Picture To A 8 Bits ?

Cory Quammen cquammen at cs.unc.edu
Thu Sep 13 22:57:44 EDT 2007


Mark,

Please keep your response on the list so that if someone with a
similar question searches the archive, they may find this thread.

Looking at the source code of vtkBMPReader, 24-bit BMPs are read in as
standard 3 color channel images (RGB) where each channel is 8-bits.
What do you BMP's look like in a standard image viewer? If they are
grayscale images where each color channel at each pixel has the same
value, you can simply extract one of the 8-bit components as I
suggested and pass the output of the vtkImageExtractComponents filter,
which is now an 8-bit image, to the volume renderer you are using.

By the way, what volume renderer are you using?

Cory

On 9/13/07, JohnMark <zhaojunxp at hotmail.com> wrote:
>
> Thank you , Cory ,
>
>      what I do is not to extract a single color channel from the 24-bit BMP
> images , but to do volume
>  rendering . my code is :
>
>  vtkBMPReader *reader = vtkBMPReader::New();
>  reader->SetDataExtent(0, 299, 0, 299, 1, 5);
>  reader->SetFilePrefix("../Data/CT");
>  reader->SetDataByteOrderToLittleEndian();
>  reader->Allow8BitBMPOn();
>  reader->SetDataMask(0x7fff);
>  reader->SetDataSpacing(3.2,3.2,3.5);
>  reader->SetDataOrigin(0.0,0.0,0.0);
>
>      and I think you can see easily : reader->Allow8BitBMPOn(); that is ,
> the reader ask for the 8-bit
>  BMP images . but I only have 24-bit BMP images , so my volume rendering is
> just a cube , and there is
>  something I can't see clearly in the " cube " . and in a word , if I would
> get the volume rendering ,
>  I should use the 8-bit BMP images .
>
>      So my question is : are there any classes in VTK that I can use to
> change the 24-bit BMP images to
>  8-bit ?
>
>      Thank you for your help again !
>
>      Mark
>
>
>
>
>
>
>
>  ________________________________
>
>  > Date: Thu, 13 Sep 2007 22:11:22 -0400
> > From: cquammen at cs.unc.edu
> > To: zhaojunxp at hotmail.com
> > Subject: Re: [vtkusers] How To Change A 24 Bits BMP Picture To A 8 Bits ?
> > CC: vtkusers at vtk.org
> >
> > Hi Mark,
> >
> > It sounds like you need to extract a single color channel from the
> > 24-bit BMP image you are generating (and I presume reading into your
> > program to do volume rendering). If so, you should be able to use
> > vtkImageExtractComponents, as in:
> >
> > vtkImageExtractComponents extract =
> vtkImageExtractComponents::New();
> > extract.SetComponents(0); // If you want the red channel, for instance
> > extract.SetInputConnection(bmp24.GetOutputPort());
> > ...
> >
> > Hope this helps,
> > Cory
> >
> > On 9/13/07, JohnMark <zhaojunxp at hotmail.com> wrote:
> > >
> > > Hi , vtkusers ,
> > >
> > > with the help of classes vtkStructure! dPoints and vtkBMPWriter , I
> change
> > > the DICOM pictures to BMP
> > > pictures successfully . however , I found the BMP pictures' format was
> wrong
> > > when I decided to use them
> > > to reconsturct ( i.e. , volume rendering ) . it asked for 8 bits' BMP
> > > pictures , not 24 bits . So , I
> > > want to know whether there is a class changing 24 bits BMP picture to 8
> bits
> > > ?
> > >
> > > and I find there is not a function to do so in vtkStructuredPoints .
> > >
> > > thanks a lot !
> > > Mark
> > >
> > >
> > >
> > > ________________________________
> > > 不登录就能管理多个邮件帐户,试试 Windows Live Mail。 立即尝试!
> > > _______________________________________________
> > > This is the private VTK discussion list.
> > > Please keep messages on-topic. Check the FAQ at:
> > > http://www.vtk.org/Wiki/VTK_FAQ
> > >! Follow this link to subscribe/unsubscribe:
> > > http://www.vt k.org/mailman/listinfo/vtkusers
> > >
> > >
> >
> >
> > --
> > Cory Quammen
> > Department of Computer Science
> > University of North Carolina at Chapel Hill
> > http://www.cs.unc.edu/~cquammen
>
>
> ________________________________
> 使用新一代 Windows Live Messenger 轻松交流和共享! 立即体验!


-- 
Cory Quammen
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen


More information about the vtkusers mailing list