X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=rgb_image.cc;h=35d0a204fc4b217194eb96f67535a994cef075f1;hb=bd7db9aaf937bdba66445231a39518f2ae30b0d3;hp=c343f47f5b44d21880d17b43c6a711023a410cef;hpb=20ec321944108cd1fe74b37ea45db3ba1a2d526a;p=folded-ctf.git
diff --git a/rgb_image.cc b/rgb_image.cc
index c343f47..35d0a20 100644
--- a/rgb_image.cc
+++ b/rgb_image.cc
@@ -1,22 +1,26 @@
-
-///////////////////////////////////////////////////////////////////////////
-// This program is free software: you can redistribute it and/or modify //
-// it under the terms of the version 3 of the GNU General Public License //
-// as published by the Free Software Foundation. //
-// //
-// This program is distributed in the hope that it will be useful, but //
-// WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
-// General Public License for more details. //
-// //
-// You should have received a copy of the GNU General Public License //
-// along with this program. If not, see . //
-// //
-// Written by Francois Fleuret //
-// (C) Idiap Research Institute //
-// //
-// Contact for comments & bug reports //
-///////////////////////////////////////////////////////////////////////////
+/*
+ * folded-ctf is an implementation of the folded hierarchy of
+ * classifiers for object detection, developed by Francois Fleuret
+ * and Donald Geman.
+ *
+ * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/
+ * Written by Francois Fleuret
+ *
+ * This file is part of folded-ctf.
+ *
+ * folded-ctf is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * folded-ctf is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with folded-ctf. If not, see .
+ *
+ */
#include
#include
@@ -91,99 +95,6 @@ RGBImage::~RGBImage() {
deallocate();
}
-void RGBImage::write_ppm(const char *filename) {
- FILE *outfile;
-
- if ((outfile = fopen (filename, "wb")) == 0) {
- fprintf (stderr, "Can't open %s for reading\n", filename);
- exit(1);
- }
-
- fprintf(outfile, "P6\n%d %d\n255\n", _width, _height);
-
- char *raw = new char[_width * _height * 3];
-
- int k = 0;
- for(int y = 0; y < _height; y++) for(int x = 0; x < _width; x++) {
- raw[k++] = _bit_map[x + _width * (y + _height * RED)];
- raw[k++] = _bit_map[x + _width * (y + _height * GREEN)];
- raw[k++] = _bit_map[x + _width * (y + _height * BLUE)];
- }
-
- fwrite((void *) raw, sizeof(unsigned char), _width * _height * 3, outfile);
- fclose(outfile);
-
- delete[] raw;
-}
-
-void RGBImage::read_ppm(const char *filename) {
- const int buffer_size = 1024;
- FILE *infile;
- char buffer[buffer_size];
- int max;
-
- deallocate();
-
- if((infile = fopen (filename, "r")) == 0) {
- fprintf (stderr, "Can't open %s for reading\n", filename);
- exit(1);
- }
-
- fgets(buffer, buffer_size, infile);
-
- if(strncmp(buffer, "P6", 2) == 0) {
-
- do {
- fgets(buffer, buffer_size, infile);
- } while((buffer[0] < '0') || (buffer[0] > '9'));
- sscanf(buffer, "%d %d", &_width, &_height);
- fgets(buffer, buffer_size, infile);
- sscanf(buffer, "%d", &max);
-
- allocate();
-
- unsigned char *raw = new unsigned char[_width * _height * RGB_DEPTH];
- fread(raw, sizeof(unsigned char), _width * _height * RGB_DEPTH, infile);
-
- int k = 0;
- for(int y = 0; y < _height; y++) for(int x = 0; x < _width; x++) {
- _bit_plans[RED][y][x] = raw[k++];
- _bit_plans[GREEN][y][x] = raw[k++];
- _bit_plans[BLUE][y][x] = raw[k++];
- }
-
- delete[] raw;
-
- } else if(strncmp(buffer, "P5", 2) == 0) {
-
- do {
- fgets(buffer, buffer_size, infile);
- } while((buffer[0] < '0') || (buffer[0] > '9'));
- sscanf(buffer, "%d %d", &_width, &_height);
- fgets(buffer, buffer_size, infile);
- sscanf(buffer, "%d", &max);
-
- allocate();
-
- unsigned char *pixbuf = new unsigned char[_width * _height];
- fread(buffer, sizeof(unsigned char), _width * _height, infile);
-
- int k = 0, l = 0;
- for(int y = 0; y < _height; y++) for(int x = 0; x < _width; x++) {
- unsigned char c = pixbuf[k++];
- _bit_map[l++] = c;
- _bit_map[l++] = c;
- _bit_map[l++] = c;
- }
-
- delete[] pixbuf;
-
- } else {
- cerr << "Can not read ppm of type [" << buffer << "] from " << filename << ".\n";
- exit(1);
- }
-}
-
void RGBImage::read_png(const char *name) {
// This is the number of bytes the read_png routine will read to
// decide if the file is a PNG or not. According to the png