core/vil/file_formats/vil_dicom.h
Go to the documentation of this file.
00001 // This is core/vil/file_formats/vil_dicom.h
00002 #ifndef vil_dicom_file_format_h_
00003 #define vil_dicom_file_format_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief Reader/Writer for DICOM format 2D images.
00010 // \author Amitha Perera
00011 //
00012 // This dicom parser is a wrapper around DCMTK.
00013 
00014 #include <vil/vil_image_resource.h>
00015 #include <vil/vil_file_format.h>
00016 #include <vil/file_formats/vil_dicom_header.h>
00017 
00018 class DicomImage;
00019 class vil_dicom_stream_input;
00020 class DcmFileFormat;
00021 
00022 class vil_image_view_base;
00023 
00024 
00025 //: Loader for DICOM files
00026 class vil_dicom_file_format : public vil_file_format
00027 {
00028  public:
00029   virtual char const* tag() const;
00030   virtual vil_image_resource_sptr make_input_image(vil_stream* vs);
00031   virtual vil_image_resource_sptr make_output_image(vil_stream* vs,
00032                                                     unsigned ni,
00033                                                     unsigned nj,
00034                                                     unsigned nplanes,
00035                                                     vil_pixel_format format);
00036 };
00037 
00038 
00039 //: Generic image implementation for DICOM files
00040 class vil_dicom_image : public vil_image_resource
00041 {
00042   vil_dicom_header_info header_;
00043   vil_image_resource_sptr pixels_;
00044 
00045  public:
00046   vil_dicom_image(vil_stream* is, unsigned ni,
00047                   unsigned nj, unsigned nplanes,
00048                   vil_pixel_format format);
00049   vil_dicom_image(vil_stream* is);
00050   ~vil_dicom_image();
00051 
00052   virtual unsigned nplanes() const;
00053   virtual unsigned ni() const;
00054   virtual unsigned nj() const;
00055 
00056   virtual enum vil_pixel_format pixel_format() const;
00057 
00058   virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
00059                                                  unsigned j0, unsigned nj) const;
00060 
00061   virtual vil_image_view_base_sptr get_view(unsigned i0, unsigned ni,
00062                                             unsigned j0, unsigned nj) const;
00063 
00064   virtual bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0);
00065 
00066   char const* file_format() const;
00067   bool get_property(char const *tag, void *prop = 0) const;
00068 
00069   // Dicom specific stuff
00070   vil_dicom_header_info const& header() const { return header_; }
00071 
00072   //:correct known manufacturers drop-offs in header data!
00073   //For example Hologic encode pixel-size in the imageComment!
00074   //NB if this section starts bloating, use derived classes which override correct_manufacturer_discrepancies
00075   virtual void correct_manufacturer_discrepancies();
00076 
00077   //:try and interpret the hologic comments section to extract pixel size
00078   virtual bool interpret_hologic_header(float& xpixSize, float& ypixSize);
00079 };
00080 
00081 #endif // vil_dicom_file_format_h_