[vtkusers] Dicom to jpeg
Amy Henderson
amy.henderson at kitware.com
Wed Jun 23 09:40:07 EDT 2004
Hi Jean-Philippe,
Probably the scalar values from your Dicom image are some type other than
unsigned char. Find out the data type of the scalars coming out of the
Dicom reader (reader->GetOutput()->GetScalarTypeAsString()). Then use a
vtkImageShiftScale to rescale the scalar values so they fit in the unsigned
char range. Set the input of the vtkJPEGWriter to be the output of the
vtkImageShiftScale. I'm guessing that the scalar value from the Dicom
reader may be of type unsigned short, in which case you would want to set a
scale value of 1/256 in vtkImageShiftScale.
- Amy
At 09:28 AM 6/23/2004, Jean-Philippe Lebel wrote:
> I use the following code to convert a Dicom Image to jpeg but vtk throw
>me a "JPEGWriter only supports unsigned char input" error.
>
>Do you know where the problem is? I followed line by line the
>vtkJPEGWriter test example.
>
>
> vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
> reader->SetFileName("Images/120");
> reader->Update();
>
> vtkJPEGWriter *jpgw1 = vtkJPEGWriter::New();
> jpgw1->SetInput(reader->GetOutput());
> jpgw1->SetFileName("jpgw1.jpg");
> jpgw1->Write();
>
>Jean-Philippe
>Forintek Canada Corp.
>418-659-2647, ext 3301
>jean-philippe.lebel at qc.forintek.ca
>
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at:
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list