[vtkusers] Problem with using vtkJPEGWriter
    Ravi Samala 
    raviksamala at yahoo.com
       
    Sun Oct 16 23:14:33 EDT 2005
    
    
  
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20051016/a09fc17f/attachment.htm>
    
    
More information about the vtkusers
mailing list