[vtkusers] Problem with using vtkJPEGWriter

Ravi Samala raviksamala at yahoo.com
Tue Oct 25 22:46:21 EDT 2005


hi Bruno,

Thankx a lot for the help.......its working now. What
I did was to use vtkExtractVOI instead of
vtkImageReslice and did not use SetScale(). I have no
idea of why its working !!

But still I got a problem. I am having the data in 16
bit format, but vtkJPEGWriter only supports 8bit. Is
there any 16 bit writers available?

thank you,

Ravi.

--- Bruno da Silva de Oliveira <bruno at esss.com.br>
wrote:

> Doesn't seem a problem with vtkJPEGWriter at all
> then... it seems the 
> image is not being constructed correctly. You could
> try to save each 
> step of your pipeline to isolate the problem (right
> after reading it 
> from disk, for instance).
> 
> HTH,
> 
> Ravi Samala wrote:
> 
> > hi Bruno,
> >  
> > I used vtkPNGWriter instead of vtkJPEGWriter, but
> still the final 
> > image complete black !
> >  
> > what could be wrong ?
> >  
> > Thank you,
> > Ravi
> >
> > */Bruno da Silva de Oliveira <bruno at esss.com.br>/*
> wrote:
> >
> >     Hi,
> >
> >     Didn't actually read your code, but what
> happens if you use a
> >     vtkPNGWriter instead? Does the resulting image
> look correct?
> >
> >     Regards,
> >
> >     Ravi Samala wrote:
> >
> >     > Dear /VTKUser's/,
> >     >
> >     >
> >     >
> >     > *Objective*: To write some data to a JPEG
> file.
> >     >
> >     > *Problem*: The final image is black color !
> >     >
> >     >
> >     >
> >     >
> >     >
> >     > The code is as follows:
> >     >
> >     >
> >     >
> >     >
>
//****************************************************
> >     >
> >     > // ***** Used to read 16 bit Image *****
> >     >
> >     >
>
//****************************************************
> >     >
> >     > *vtkVolume16Reader *v16Img =
> vtkVolume16Reader::New(); *
> >     >
> >     > v16Img->SetDataDimensions (sizex,sizey);
> >     >
> >     > v16Img->SetImageRange
> (atoi(argv[3]),atoi(argv[4]));//Specify
> >     > the number of slices to read
> >     >
> >     > v16Img->SetHeaderSize(HeadS); // Specify the
> number of bytes to
> >     > seek over at start of image
> >     >
> >     > v16Img->SetFilePrefix (argv[2]); //Specify
> the File prefix of
> >     > all the slices (files)
> >     >
> >     > v16Img->SetDataSpacing (0.1, 0.1, 0.5);
> >     > //Resolution along X, Y and Z axis
> >     >
> >     > v16Img->SetDataOrigin(0, 0, 0);
> >     >
> >     >
> >     >
> >     >
>
//****************************************************
> >     >
> >     > // ***** Extracting a slice from the 3D
> volume *****
> >     >
> >     >
>
//****************************************************
> >     >
> >     > *vtkImageReslice *imgResliceIn =
> vtkImageReslice::New(); *
> >     >
> >     > imgResliceIn->SetInput(v16Img ->
> GetOutput());
> >     >
> >     > imgResliceIn->SetOutputSpacing(1,1,1);
> >     >
> >     >
> imgResliceIn->SetInterpolationModeToLinear();
> >     >
> >     > imgResliceIn->SetOutputOrigin(0, 0, 10);
> >     >
> >     >
> imgResliceIn->SetOutputExtent(0,312,0,499,0,0);
> >     >
> >     >
> >     >
> >     >
>
//****************************************************
> >     >
> >     > // ***** Scaling the pixel range ******
> >     >
> >     >
>
//****************************************************
> >     >
> >     > *vtkImageShiftScale *imgShSc
> =vtkImageShiftScale::New();*
> >     >
> >     > imgShSc->SetInput(imgResliceIn ->
> GetOutput());
> >     >
> >     > imgShSc->SetScale(256/13000);
> >     >
> >     > /// $$ The input image pixel range is from 0
> to 13000./
> >     >
> >     > /// $$ I wanted to convert the range from
> (0-13000)/
> >     >
> >     > /// $$ to (0-255)./
> >     >
> >     >
> >     >
> >     >
>
//****************************************************
> >     >
> >     > // ***** Converting to Unsigned Char for
> JPEG writer *
> >     >
> >     >
>
//****************************************************
> >     >
> >     > *vtkImageCast *imgCastIn =
> vtkImageCast::New();*
> >     >
> >     > imgCastIn->SetInput(imgShSc -> GetOutput());
> >     >
> >     >
> imgCastIn->SetOutputScalarTypeToUnsignedChar();
> >     >
> >     >
> >     >
> >     >
>
//****************************************************
> >     >
> >     > *vtkJPEGWriter *jpegWrIn =
> vtkJPEGWriter::New();*
> >     >
> >     > jpegWrIn->SetInput(imgCastIn ->
> GetOutput());
> >     >
> >     > jpegWrIn->SetFileName("Input10.jpg");
> >     >
> >     > jpegWrIn->Write();
> >     >
> >     >
>
//****************************************************
> >     >
> >     >
> >     >
> >     >
> >     >
> >     > Thank you,
> >     >
> >     >
> >     >
> >     > Ravi.
> >     >
> >     >
> >    
>
------------------------------------------------------------------------
> >     > Yahoo! Music Unlimited - Access over 1
> million songs. Try it free.
> >     >
> >     >
> >     >
> >    
>
>------------------------------------------------------------------------
> >     >
> >    
> >_______________________________________________
> >     >This is the private VTK discussion list.
> >     >Please keep messages on-topic. Check the FAQ
> at:
> >     http://www.vtk.org/Wiki/VTK_FAQ
> 
=== message truncated ===



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com



More information about the vtkusers mailing list