// img.cc - Classe Image // nono - Programme du robot Efrei Robotique I1-I2 2004 // Copyright (C) 2004 Olivier Gaillard /// @file img.cc Chargement des images, conversion en YUV, HSI, detection des contours, transformation d'une image segmentee en RGB, ecriture de l'image sur le disque #include "img.h" #include #include #include #include using namespace std; /// Renvoie le minimum entre 2 nombres inline unsigned char min(unsigned char a, unsigned char b) { if (awidth = width; this->height = height; nbPixels = width * height; delete[] tabData; tabData = new unsigned char[nbPixels*3]; yuv = mode; FILE *file; file = fopen(filename, "r"); fread(tabData, 3, width*height, file); fclose(file); } /// Lit une image depuis un ImageLoader. void Img::load (ImageLoader &loader) { delete[] tabData; loader.getSize (width, height); nbPixels = width * height; tabData = new unsigned char[loader.getBufSize ()]; loader.read (tabData, loader.getBufSize ()); yuv = loader.getColorSpace () == ImageLoader::yuv; }