GrayLevelImageFloat.cpp
Go to the documentation of this file.
00001 #include "GrayLevelImageFloat.h"
00002 // #include "ImageReader.h" // TODO
00003 // #include "ImageWriter.h" // TODO
00004 
00005 #include "GrayLevelImage8.h"
00006 
00007 using namespace puma2;
00008 
00009 GrayLevelImageFloat::GrayLevelImageFloat(int width, int height)
00010         : SingleElementImage<float>(width, height)
00011 {
00012   setupImageBaseVariables();
00013   alt = new MultiElementImage<float,1>(width, height,
00014         (MultiElementImage<float,1>*) (void*) (SingleElementImage<float>*) this, 0,0);
00015 };
00016 
00017 GrayLevelImageFloat::GrayLevelImageFloat(int width, int height, GrayLevelImageFloat * m, int xo, int yo)
00018         : SingleElementImage<float>(width, height,m,xo,yo)
00019 {
00020   setupImageBaseVariables();
00021   alt = new MultiElementImage<float,1>(width, height,
00022         (MultiElementImage<float,1>*) (void*) (SingleElementImage<float>*) this, xo,yo);
00023 };
00024 
00025 GrayLevelImageFloat::GrayLevelImageFloat(const GrayLevelImageFloat& f)
00026   : SingleElementImage<float>(f)
00027 {
00028   using namespace std;
00029   // cerr << "Copy Constructor Gray-Level Image" << endl;
00030   setupImageBaseVariables();
00031   // alt = new MultiElementImage<float,1>(f.alt);
00032   alt = new MultiElementImage<float,1>(f.getWidth(), f.getHeight(),
00033         (MultiElementImage<float,1>*) (void*) (SingleElementImage<float>*) this, 0,0);
00034 };
00035 
00036 GrayLevelImageFloat::~GrayLevelImageFloat()
00037 {
00038   using namespace std;
00039   // cerr << "Delete Gray-Level Image" << endl;
00040   delete alt;
00041 };
00042 
00043 MultiElementImage<float,1> & GrayLevelImageFloat::asMultiElementImage()
00044 {
00045   return *alt;
00046 };
00047 
00048 void GrayLevelImageFloat::readFromFile(const char * fileName)
00049 {
00050   GrayLevelImage8 byteImg;
00051   // ImageReader::readImage( byteImg, fileName); // TODO
00052 
00053   resize( byteImg.getWidth(), byteImg.getHeight() );
00054   for ( unsigned y=0; y<getHeight(); y++ )
00055   {
00056     for ( unsigned x=0; x<getWidth(); x++ )
00057     {
00058       (*this)[y][x]= byteImg[y][x] * (1.0/255.0);
00059     }
00060   }
00061 }
00062 
00063 void GrayLevelImageFloat::writeToFile(const char * fileName) const
00064 {
00065   GrayLevelImage8 byteImg;
00066   byteImg.resize( getWidth(), getHeight() );
00067 
00068   for ( unsigned y=0; y<getHeight(); y++ )
00069   {
00070     for ( unsigned x=0; x<getWidth(); x++ )
00071     {
00072       float value = (*this)[y][x] * 255.0;
00073       if ( value < 0 )
00074       {
00075         value = 0;
00076       }
00077       if ( value > 255 )
00078       {
00079         value = 255;
00080       }
00081       byteImg[y][x] = value;
00082     }
00083   }
00084 
00085   // ImageWriter::writeImage(byteImg, fileName); // TODO
00086 }
00087 
00088 void GrayLevelImageFloat::reset()
00089 {
00090 }
00091 
00092 
00093 


obj_rec_gui
Author(s): AGAS/agas@uni-koblenz.de
autogenerated on Mon Oct 6 2014 02:53:43