X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=pom.git;a=blobdiff_plain;f=proba_view.cc;fp=proba_view.cc;h=3bf3fafcf2ac3f7bc8cfa97ae4a5db876f64600c;hp=0000000000000000000000000000000000000000;hb=97a7e68f234cc09807d2d55f550e2516be0e9093;hpb=48c9926a2ed03737a3b024a85cda348caebf4cfe diff --git a/proba_view.cc b/proba_view.cc new file mode 100644 index 0000000..3bf3faf --- /dev/null +++ b/proba_view.cc @@ -0,0 +1,33 @@ + +////////////////////////////////////////////////////////////////////////////////// +// 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) Ecole Polytechnique Federale de Lausanne // +// Contact for comments & bug reports // +////////////////////////////////////////////////////////////////////////////////// + +#include "proba_view.h" + +ProbaView::ProbaView(int view_width, int view_height) : Array(view_width, view_height) { } + +void ProbaView::from_image(const RGBImage *image) { + ASSERT(image->width() == width && image->height() == height, + "Image size missmatch"); + int k = 0; + for(int x = 0; x < width; x++) for(int y = 0; y < height; y++) { + content[k++] = scalar_t(image->pixel(x, y, 0) + + image->pixel(x, y, 1) + + image->pixel(x, y, 2))/(3 * 255); + } +}