Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

Image.cpp

Go to the documentation of this file.
00001 /**************************************************************************
00008  *
00009  * Source code for Real Time Image Library (libRTImage)
00010  *
00011  * Leeds Vision Group give permission for this code to be copied, modified 
00012  * and distributed within the University of Leeds subject to the following 
00013  * conditions:-
00014  *
00015  * - The code is not to be used for commercial gain.
00016  * - The code and use thereof will be attributed to the author where
00017  *   appropriate (inluding demonstrations which rely on it's use).
00018  * - All modified, distributions of the source files will retain this header.
00019  *
00020  ****************************************************************************/
00021 
00022 #include <new>          // bad_alloc exception
00023  
00024 #include "Image.h"
00025 
00026 
00027 Image::Image(Image& img) : ImageBase(img), ImageRGB(img), ImageGrey(img)
00033 {
00034 }
00035 
00036 
00037 Image::Image(unsigned int w, unsigned int h)
00038  : ImageBase(w,h), ImageRGB(w,h), ImageGrey(w,h)
00045 {
00046 }
00047 
00048 
00049 Image::~Image()
00053 {
00054 }
00055 
00056 
00057 void Image::set_rgb(unsigned int x, unsigned int y, PixelRGB& p)
00064 {
00065         ImageRGB::set_pixel(x,y,p);
00066 }
00067 
00068 
00069 void Image::set_brightness(unsigned int x, unsigned int y, PixelGrey& level)
00077 {
00078         ImageGrey::set_pixel(x,y,level);
00079 }
00080 
00081 
00082 void Image::get_rgb(unsigned int x, unsigned int y, PixelRGB& p)
00090 {
00091         ImageRGB::get_pixel(x, y, p);
00092 }
00093 
00094 
00095 void Image::get_brightness(unsigned int x, unsigned int y, PixelGrey& p)
00103 {
00104         ImageGrey::get_pixel(x,y, p);
00105 }
00106 
00107 
00108 Image& Image::clear_rgb(int k)
00114 {
00115         ImageRGB::clear(k);
00116         return *this;
00117 }
00118 
00119 
00120 Image& Image::clear_rgb(PixelRGB& p)
00126 {
00127         ImageRGB::clear(p);
00128         return *this;
00129 }
00130 
00131 
00132 Image& Image::clear_brightness(int k)
00138 {
00139         ImageGrey::clear(k);
00140         return *this;
00141 }
00142 
00143 
00144 Image& Image::copy(Image& img)
00151 {
00152         ImageRGB::copy(img);
00153         ImageGrey::copy(img);
00154         return *this;
00155 }
00156 
00157  
00158 Image& Image::operator = (Image& img)
00165 {
00166         this->ImageRGB::copy(img);
00167         this->ImageGrey::copy(img);
00168         return *this ;
00169 }
00170 
00171 void Image::update_brightness()
00175 {
00176         unsigned int y_cnt;
00177         unsigned int x_cnt;
00178         PixelGrey *bri_ptr = brightness;
00179         PixelRGB* rgb_ptr = data;
00180 
00181         for(y_cnt=0 ; y_cnt< height ; y_cnt++){
00182             for(x_cnt=0 ; x_cnt< width ; x_cnt++){
00183                 *(bri_ptr++) = (PixelGrey)( (RED_COEF*(float)(*rgb_ptr)[0]) +
00184                                         (GREEN_COEF*(float)(*rgb_ptr)[1]) +
00185                                         (BLUE_COEF*(float)(*rgb_ptr)[2]) );
00186                 rgb_ptr++;
00187             } 
00188         }
00189 }
00190 
00191 /****************************************************************************\
00192  *       Extra doxygen comments and information relating to this file       *
00193 \****************************************************************************/
00194  

Generated at Fri Aug 13 17:29:21 2004 for libRTImage by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001