vil_mit.h
Go to the documentation of this file.
1 // This is core/vil/file_formats/vil_mit.h
2 #ifndef vil_mit_file_format_h_
3 #define vil_mit_file_format_h_
4 //:
5 // \file
6 // \brief Image in MIT format
7 // \author Alison Noble, Oxford University, TargetJr version
8 // Joris Schouteden, vil1 version
9 // Peter Vanroose, vil version
10 //
11 // vil_mit is a simple image format consisting of a header
12 // of 4 shorts (type,bits_per_pixel,width,height) and the raw data.
13 // The full specification defines a number of image/edge types (see header
14 // for details).
15 //
16 // \verbatim
17 // Modifications
18 // 000218 JS Initial version, header info from MITImage.C
19 // 3 October 2001 Peter Vanroose - Implemented get_property("top_row_first")
20 // 17 June 2003 Peter Vanroose - Converted from vil1, and implemented 16-bit
21 // \endverbatim
22 
23 #include <vil/vil_file_format.h>
24 #include <vil/vil_image_resource.h>
25 
26 //: Loader for MIT files
27 //
28 // TYPES:
29 // -# unsigned (grayscale)
30 // -# rgb
31 // -# hsb
32 // -# cap
33 // -# signed (grayscale?)
34 // -# float
35 // -# edge
36 
38 {
39  public:
40  char const* tag() const override;
43  unsigned int ni, unsigned int nj, unsigned int nplanes,
44  vil_pixel_format format) override;
45 };
46 
47 //: Generic image implementation for MIT files
49 {
51  unsigned int ni_;
52  unsigned int nj_;
53  unsigned int components_;
54  unsigned int type_;
56 
57  bool read_header();
58  bool write_header();
59 
60  friend class vil_mit_file_format;
61  public:
62 
65  unsigned int ni, unsigned int nj, unsigned int nplanes,
66  vil_pixel_format format);
67  ~vil_mit_image() override;
68 
69  //: Dimensions. W x H x Components
70  unsigned int ni() const override { return ni_; }
71  unsigned int nj() const override { return nj_; }
72  unsigned int nplanes() const override { return components_; }
73 
75 
76  enum vil_pixel_format pixel_format() const override { return format_; }
77 
78  //: Return part of this as buffer
79  vil_image_view_base_sptr get_copy_view(unsigned int x0, unsigned int ni, unsigned int y0, unsigned int nj) const override;
80  //: Write buf into this at position (x0,y0)
81  bool put_view(vil_image_view_base const& buf, unsigned int x0, unsigned int y0) override;
82 
83  char const* file_format() const override;
84  bool get_property(char const *tag, void *prop = nullptr) const override;
85 };
86 
87 #endif // vil_mit_file_format_h_
bool read_header()
Definition: vil_mit.cxx:142
~vil_mit_image() override
Definition: vil_mit.cxx:131
An abstract base class of smart pointers to actual image data in memory.
vil_pixel_format
Describes the type of the concrete data.
unsigned int ni() const override
Dimensions. W x H x Components.
Definition: vil_mit.h:70
bool put_view(vil_image_view_base const &buf, unsigned int x0, unsigned int y0) override
Write buf into this at position (x0,y0).
Definition: vil_mit.cxx:297
char const * tag() const override
Return a character string which uniquely identifies this format.
Definition: vil_mit.cxx:98
vil_image_resource_sptr make_input_image(vil_stream *vs) override
Attempt to make a generic_image which will read from vil_stream vs.
Definition: vil_mit.cxx:63
unsigned int nj_
Definition: vil_mit.h:52
unsigned int type_
Definition: vil_mit.h:54
Base class for image formats.
unsigned vil_pixel_format_sizeof_components(enum vil_pixel_format f)
Return the number of bytes used by each component of pixel format f.
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
unsigned int components_
Definition: vil_mit.h:53
vil_mit_image(vil_stream *is)
Definition: vil_mit.cxx:105
Loader for MIT files.
Definition: vil_mit.h:37
Abstract representation of an image source or image destination.
vil_image_resource_sptr make_output_image(vil_stream *vs, unsigned int ni, unsigned int nj, unsigned int nplanes, vil_pixel_format format) override
Definition: vil_mit.cxx:91
unsigned int bytes_per_pixel() const
Definition: vil_mit.h:74
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
unsigned int ni_
Definition: vil_mit.h:51
bool write_header()
Definition: vil_mit.cxx:185
enum vil_pixel_format format_
Definition: vil_mit.h:55
vil_stream * is_
Definition: vil_mit.h:50
unsigned int nplanes() const override
Dimensions: Planes x ni x nj.
Definition: vil_mit.h:72
Generic image implementation for MIT files.
Definition: vil_mit.h:48
unsigned int nj() const override
Dimensions: Planes x ni x nj.
Definition: vil_mit.h:71
Representation of a generic image source or destination.
Base class for image formats.
bool get_property(char const *tag, void *prop=nullptr) const override
Extra property information.
Definition: vil_mit.cxx:136
enum vil_pixel_format pixel_format() const override
Pixel Format.
Definition: vil_mit.h:76
char const * file_format() const override
Return a string describing the file format.
Definition: vil_mit.cxx:117