Assignments Assignments

image.h
Go to the documentation of this file.
1#ifndef IMAGE_INCLUDED
2#define IMAGE_INCLUDED
3
4#include <stdio.h>
5#include <string>
6#include <stdexcept>
7#include <Util/geometry.h>
8#include "lineSegments.h"
9
10 namespace Image
11{
13 class Pixel32
14 {
15 public:
17 unsigned char r;
18
20 unsigned char g;
21
23 unsigned char b;
24
26 unsigned char a;
27
29 Pixel32( void );
30 };
31
32
34 class Image32
35 {
37 int _width , _height;
38
40 Pixel32* _pixels;
41
43 void _assertInBounds( int x , int y ) const;
44 public:
45
47 struct iterator
48 {
49 using iterator_category = std::forward_iterator_tag;
50 using reference = Pixel32 &;
51 using pointer = Pixel32 *;
52 using value_type = Pixel32;
53 using difference_type = std::ptrdiff_t;
54
55 iterator( void ) : _p(NULL) {}
56 iterator( Pixel32 *p ) : _p(p) {}
57 bool operator == ( const iterator &it ) const { return _p==it._p; }
58 bool operator != ( const iterator &it ) const { return _p!=it._p; }
59 iterator operator ++( int ){ iterator it = *this ; _p++ ; return it; }
60 iterator &operator ++( void ){ _p++ ; return *this; }
61 Pixel32 &operator * ( void ){ return *_p; }
62 Pixel32 *operator -> ( void ){ return _p; }
63 protected:
64 friend Image32;
65 Pixel32 *_p;
66 };
67
69 struct const_iterator
70 {
71 using iterator_category = std::forward_iterator_tag;
72 using reference = const Pixel32 &;
73 using pointer = const Pixel32 *;
74 using value_type = Pixel32;
75 using difference_type = std::ptrdiff_t;
76
77 const_iterator( void ) : _p(nullptr) {}
78 const_iterator( const Pixel32 *p ) : _p(p) {}
79 bool operator == ( const const_iterator &it ) const { return _p==it._p; }
80 bool operator != ( const const_iterator &it ) const { return _p!=it._p; }
81 const_iterator operator ++( int ){ const_iterator it = *this ; _p++ ; return it; }
82 const_iterator &operator ++( void ){ _p++ ; return *this; }
83 const Pixel32 &operator * ( void ){ return *_p; }
84 const Pixel32 *operator -> ( void ){ return _p; }
85 protected:
86 friend Image32;
87 const Pixel32 *_p;
88 };
89
90 iterator begin( void ){ return iterator( _pixels ); }
91 iterator end( void ){ return iterator( _pixels+_width*_height ); }
92 const_iterator begin( void ) const { return const_iterator( _pixels ); }
93 const_iterator end( void ) const { return const_iterator( _pixels+_width*_height ); }
94
96 Image32( void );
97
99 Image32( const Image32& img );
100
102 Image32( Image32&& img );
103
105 Image32& operator = ( const Image32& img );
106
108 Image32& operator = ( Image32&& img );
109
111 ~Image32( void );
112
114 void setSize( int width , int height );
115
117 int width( void ) const;
118
120 int height( void ) const;
121
124 Pixel32& operator() ( int x , int y );
125
128 const Pixel32& operator() ( int x , int y ) const;
129
131 void read( std::string fileName );
132
134 void write( std::string fileName ) const;
135
139 Image32 addRandomNoise( double noise ) const;
140
143 Image32 brighten( double brightness ) const;
144
146 Image32 luminance( void ) const;
147
150 Image32 contrast( double contrast ) const;
151
154 Image32 saturate( double saturation ) const;
155
159 Image32 quantize( int bits ) const;
160
164 Image32 randomDither( int bits ) const;
165
169 Image32 orderedDither2X2( int bits ) const;
170
174 Image32 floydSteinbergDither( int bits ) const;
175
177 Image32 blur3X3( void ) const;
178
180 Image32 edgeDetect3X3( void ) const;
181
185 Image32 scaleNearest( double scaleFactor ) const;
186
189 Image32 scaleBilinear( double scaleFactor ) const;
190
193 Image32 scaleGaussian( double scaleFactor ) const;
194
197 Image32 rotateNearest( double angle ) const;
198
201 Image32 rotateBilinear( double angle ) const;
202
205 Image32 rotateGaussian( double angle ) const;
206
209 void setAlpha( const Image32& matte );
210
213 Image32 composite( const Image32& overlay ) const;
214
217 Image32 crop( int x1 , int y1 , int x2 , int y2 ) const;
218
220 Image32 funFilter( void ) const;
221
225 static Image32 BeierNeelyMorph( const Image32& source , const Image32& destination , const OrientedLineSegmentPairs& olsp , double timeStep );
226
228 Image32 warp( const OrientedLineSegmentPairs& olsp ) const;
229
233 static Image32 CrossDissolve( const Image32& source , const Image32& destination , double blendWeight );
234
236 Pixel32 nearestSample( Util::Point2D p ) const;
237
239 Pixel32 bilinearSample( Util::Point2D p ) const;
240
243 Pixel32 gaussianSample( Util::Point2D p , double variance , double radius ) const;
244 };
245}
246#endif // IMAGE_INCLUDED
247
Image::Image32
Definition image.h:35
Image::Image32::composite
Image32 composite(const Image32 &overlay) const
Definition image.todo.cpp:174
Image::Image32::operator=
Image32 & operator=(const Image32 &img)
Definition image.cpp:29
Image::Image32::blur3X3
Image32 blur3X3(void) const
Definition image.todo.cpp:94
Image::Image32::brighten
Image32 brighten(double brightness) const
Definition image.todo.cpp:22
Image::Image32::_pixels
Pixel32 * _pixels
Definition image.h:40
Image::Image32::~Image32
~Image32(void)
Definition image.cpp:52
Image::Image32::end
const_iterator end(void) const
Definition image.h:93
Image::Image32::scaleNearest
Image32 scaleNearest(double scaleFactor) const
Definition image.todo.cpp:112
Image::Image32::scaleGaussian
Image32 scaleGaussian(double scaleFactor) const
Definition image.todo.cpp:130
Image::Image32::orderedDither2X2
Image32 orderedDither2X2(int bits) const
Definition image.todo.cpp:76
Image::Image32::randomDither
Image32 randomDither(int bits) const
Definition image.todo.cpp:67
Image::Image32::height
int height(void) const
Definition image.cpp:89
Image::Image32::_assertInBounds
void _assertInBounds(int x, int y) const
Definition image.cpp:70
Image::Image32::setAlpha
void setAlpha(const Image32 &matte)
Definition image.todo.cpp:166
Image::Image32::rotateBilinear
Image32 rotateBilinear(double angle) const
Definition image.todo.cpp:148
Image::Image32::warp
Image32 warp(const OrientedLineSegmentPairs &olsp) const
Definition image.todo.cpp:192
Image::Image32::_height
int _height
Definition image.h:37
Image::Image32::_width
int _width
Definition image.h:37
Image::Image32::contrast
Image32 contrast(double contrast) const
Definition image.todo.cpp:40
Image::Image32::scaleBilinear
Image32 scaleBilinear(double scaleFactor) const
Definition image.todo.cpp:121
Image::Image32::bilinearSample
Pixel32 bilinearSample(Util::Point2D p) const
Definition image.todo.cpp:228
Image::Image32::read
void read(std::string fileName)
Definition image.cpp:118
Image::Image32::crop
Image32 crop(int x1, int y1, int x2, int y2) const
Definition image.todo.cpp:210
Image::Image32::funFilter
Image32 funFilter(void) const
Definition image.todo.cpp:201
Image::Image32::addRandomNoise
Image32 addRandomNoise(double noise) const
Definition image.todo.cpp:13
Image::Image32::begin
const_iterator begin(void) const
Definition image.h:92
Image::Image32::operator()
Pixel32 & operator()(int x, int y)
Definition image.cpp:75
Image::Image32::luminance
Image32 luminance(void) const
Definition image.todo.cpp:31
Image::Image32::edgeDetect3X3
Image32 edgeDetect3X3(void) const
Definition image.todo.cpp:103
Image::Image32::quantize
Image32 quantize(int bits) const
Definition image.todo.cpp:58
Image::Image32::gaussianSample
Pixel32 gaussianSample(Util::Point2D p, double variance, double radius) const
Definition image.todo.cpp:237
Image::Image32::width
int width(void) const
Definition image.cpp:87
Image::Image32::setSize
void setSize(int width, int height)
Definition image.cpp:54
Image::Image32::nearestSample
Pixel32 nearestSample(Util::Point2D p) const
Definition image.todo.cpp:219
Image::Image32::floydSteinbergDither
Image32 floydSteinbergDither(int bits) const
Definition image.todo.cpp:85
Image::Image32::write
void write(std::string fileName) const
Definition image.cpp:126
Image::Image32::Image32
Image32(void)
Definition image.cpp:21
Image::Image32::begin
iterator begin(void)
Definition image.h:90
Image::Image32::rotateGaussian
Image32 rotateGaussian(double angle) const
Definition image.todo.cpp:157
Image::Image32::rotateNearest
Image32 rotateNearest(double angle) const
Definition image.todo.cpp:139
Image::Image32::saturate
Image32 saturate(double saturation) const
Definition image.todo.cpp:49
Image::Image32::CrossDissolve
static Image32 CrossDissolve(const Image32 &source, const Image32 &destination, double blendWeight)
Definition image.todo.cpp:183
Image::Image32::end
iterator end(void)
Definition image.h:91
Image::OrientedLineSegmentPairs
Definition lineSegments.h:63
Image::Pixel32
Definition image.h:14
Image::Pixel32::Pixel32
Pixel32(void)
Definition image.cpp:16
Image::Pixel32::r
unsigned char r
Definition image.h:17
Image::Pixel32::a
unsigned char a
Definition image.h:26
Image::Pixel32::b
unsigned char b
Definition image.h:23
Image::Pixel32::g
unsigned char g
Definition image.h:20
Util::Point
Definition geometry.h:52
geometry.h
lineSegments.h
BeierNeelyMorph
CmdLineParameterArray< string, 3 > BeierNeelyMorph("bnMorph")
Image
Definition bmp.cpp:142
Image::Image32::const_iterator
Definition image.h:70
Image::Image32::const_iterator::operator!=
bool operator!=(const const_iterator &it) const
Definition image.h:80
Image::Image32::const_iterator::const_iterator
const_iterator(void)
Definition image.h:77
Image::Image32::const_iterator::operator==
bool operator==(const const_iterator &it) const
Definition image.h:79
Image::Image32::const_iterator::_p
const Pixel32 * _p
Definition image.h:87
Image::Image32::const_iterator::operator++
const_iterator & operator++(void)
Definition image.h:82
Image::Image32::const_iterator::operator*
const Pixel32 & operator*(void)
Definition image.h:83
Image::Image32::const_iterator::operator->
const Pixel32 * operator->(void)
Definition image.h:84
Image::Image32::const_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition image.h:71
Image::Image32::const_iterator::const_iterator
const_iterator(const Pixel32 *p)
Definition image.h:78
Image::Image32::const_iterator::difference_type
std::ptrdiff_t difference_type
Definition image.h:75
Image::Image32::const_iterator::Image32
friend Image32
Definition image.h:86
Image::Image32::iterator
Definition image.h:48
Image::Image32::iterator::Image32
friend Image32
Definition image.h:64
Image::Image32::iterator::operator->
Pixel32 * operator->(void)
Definition image.h:62
Image::Image32::iterator::operator!=
bool operator!=(const iterator &it) const
Definition image.h:58
Image::Image32::iterator::_p
Pixel32 * _p
Definition image.h:65
Image::Image32::iterator::operator*
Pixel32 & operator*(void)
Definition image.h:61
Image::Image32::iterator::iterator
iterator(void)
Definition image.h:55
Image::Image32::iterator::operator++
iterator & operator++(void)
Definition image.h:60
Image::Image32::iterator::iterator
iterator(Pixel32 *p)
Definition image.h:56
Image::Image32::iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition image.h:49
Image::Image32::iterator::difference_type
std::ptrdiff_t difference_type
Definition image.h:53
Image::Image32::iterator::operator==
bool operator==(const iterator &it) const
Definition image.h:57