[vtkusers] Writing Image Slices with unsigned short data type

Asad A. Abu-Tarif tarifa at rpi.edu
Wed Nov 1 03:43:51 EST 2000


Hi,
Thank you very much. The vtkTIFF16Writer class is working perfectly. However, why the need for a new class? The changes are limited and it should be easy to just incorporate them inside the vtkTIFFWriter class with automatic checking of the data type!!

Thanks again,
Asad


  ----- Original Message ----- 
  From: HIRAKI Hideaki 
  To: Asad A. Abu-Tarif 
  Cc: vtkusers at public.kitware.com 
  Sent: Sunday, October 29, 2000 8:25 PM
  Subject: Re: [vtkusers] Writing Image Slices with unsigned short data type


  At Sat 28 Oct 2000 13:33:19 +0200, Sebastien BARRE wrote:
  >At 28/10/00 06:07, Asad A. Abu-Tarif wrote:
  >
  >>Is there any Image writer that takes vtkStructuredPoints as its input and 
  >>writes the image slices to standart image format(s)? I found vtkBMPWriter 
  >>and vtkTIFFWriter, however, these deal only with unsigned char input type. 
  >>My data is 2 bytes long (unsigned short) and hence I need some other image 
  >>writer.
  >
  >BMP won't support unsigned short anyway.
  >The TIFF format does, theoritically. I do remember that the TIFF reader is 
  >able to read 16 bits data, si I guess the writer does the same. Try this 
  >out, and test the result with Photoshop for example (which is able to 
  >handle 16 bits).

  As vtkTIFFWriter didn't support 16 bits data, I made vtkTIFF16Writer 
  tweaking vtkTIFFWriter. The modifications are shown below. I hope 
  this helps.


  % diff imaging/vtkTIFFWriter.h local/vtkTIFF16Writer.h
  42c42
  < // .NAME vtkTIFFWriter - write out structured points as a TIFF file
  ---
  > // .NAME vtkTIFF16Writer - write out structured points as a TIFF file
  46,47c46,47
  < #ifndef __vtkTIFFWriter_h
  < #define __vtkTIFFWriter_h
  ---
  > #ifndef __vtkTIFF16Writer_h
  > #define __vtkTIFF16Writer_h
  52c52
  < class VTK_EXPORT vtkTIFFWriter : public vtkImageWriter
  ---
  > class VTK_EXPORT vtkTIFF16Writer : public vtkImageWriter
  55,56c55,56
  <   static vtkTIFFWriter *New();
  <   vtkTypeMacro(vtkTIFFWriter,vtkImageWriter);
  ---
  >   static vtkTIFF16Writer *New();
  >   vtkTypeMacro(vtkTIFF16Writer,vtkImageWriter);
  59,62c59,62
  <   vtkTIFFWriter() {};
  <   ~vtkTIFFWriter() {};
  <   vtkTIFFWriter(const vtkTIFFWriter&) {};
  <   void operator=(const vtkTIFFWriter&) {};
  ---
  >   vtkTIFF16Writer() {};
  >   ~vtkTIFF16Writer() {};
  >   vtkTIFF16Writer(const vtkTIFF16Writer&) {};
  >   void operator=(const vtkTIFF16Writer&) {};


  % diff imaging/vtkTIFFWriter.cxx local/vtkTIFF16Writer.cxx
  42c42
  < #include "vtkTIFFWriter.h"
  ---
  > #include "vtkTIFF16Writer.h"
  55c55
  < vtkTIFFWriter* vtkTIFFWriter::New()
  ---
  > vtkTIFF16Writer* vtkTIFF16Writer::New()
  58c58
  <   vtkObject* ret = vtkObjectFactory::CreateInstance("vtkTIFFWriter");
  ---
  >   vtkObject* ret = vtkObjectFactory::CreateInstance("vtkTIFF16Writer");
  61c61
  <     return (vtkTIFFWriter*)ret;
  ---
  >     return (vtkTIFF16Writer*)ret;
  66c66
  <     vtkGenericWarningMacro ("vtkTIFFWriter expects sizeof(vtkTiffLong) to be 4,"
  ---
  >     vtkGenericWarningMacro ("vtkTIFF16Writer expects sizeof(vtkTiffLong) to be 4,"
  70c76
  <   return new vtkTIFFWriter;
  ---
  >   return new vtkTIFF16Writer;
  285c291
  < void vtkTIFFWriter::WriteFileHeader(ofstream *file, vtkImageData *cache)
  ---
  > void vtkTIFF16Writer::WriteFileHeader(ofstream *file, vtkImageData *cache)
  357c363
  <       short depth = 8;
  ---
  >       short depth = 16;
  362c368
  <       vtkTiffUnsignedLong depth = 8 + (8 << 16);
  ---
  >       vtkTiffUnsignedLong depth = 16 + (16 << 16);
  421c427
  <   vtkTiffLong stripByteCounts = width*height*bpp;
  ---
  >   vtkTiffLong stripByteCounts = width*height*bpp*2;
  469c475
  <   short depth = 8;
  ---
  >   short depth = 16;
  483c489
  < void vtkTIFFWriter::WriteFile(ofstream *file, vtkImageData *data,
  ---
  > void vtkTIFF16Writer::WriteFile(ofstream *file, vtkImageData *data,
  500,501c506,507
  <     case VTK_UNSIGNED_CHAR:
  <       rowLength = sizeof(unsigned char); 
  ---
  >     case VTK_UNSIGNED_SHORT:
  >       rowLength = sizeof(unsigned short); 
  504c510
  <       vtkErrorMacro("TIFFWriter only accepts unsigned char scalars!");
  ---
  >       vtkErrorMacro("TIFF16Writer only accepts unsigned short scalars!");

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20001101/77497e61/attachment.htm>


More information about the vtkusers mailing list