[Wavelet-commit] Wavelet ColorImage.cc, 1.12, 1.13 Image.cc, 1.31, 1.32
Status: Beta
Brought to you by:
herbert
From: Herbert M. D. <he...@us...> - 2009-05-28 13:15:31
|
Update of /cvsroot/wavelet/Wavelet In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv2712 Modified Files: ColorImage.cc Image.cc Log Message: fixed bug in mirror extend function for resizing, added another fill strategy Index: ColorImage.cc =================================================================== RCS file: /cvsroot/wavelet/Wavelet/ColorImage.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ColorImage.cc 13 Apr 2009 01:35:47 -0000 1.12 --- ColorImage.cc 28 May 2009 12:21:28 -0000 1.13 *************** *** 479,482 **** --- 479,496 ---- ColorImage * + ColorImage::fitInto (int rows, int cols, ExtendFunc extend, int function) const + { + Image **channels = NEW (Image* [m_colors]); + for (int i = 0; i < m_colors; i++) + { + channels[i] = m_images[i]->fitInto (rows, cols, extend, function); + } + ColorImage *ret = NEW (ColorImage (m_colors, m_cmodel, channels, + false, true)); + DELETEAR (channels); + return ret; + } + + ColorImage * ColorImage::fitInto (int rows, int cols, ResizeFillFunc *fillFunc, int function) const Index: Image.cc =================================================================== RCS file: /cvsroot/wavelet/Wavelet/Image.cc,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Image.cc 13 Apr 2009 19:29:38 -0000 1.31 --- Image.cc 28 May 2009 12:21:30 -0000 1.32 *************** *** 842,851 **** col = 2 * (xOffset + newCols - 1) - x; } ! if (row < 0 || row >= scaled.rows () || col < 0 || col >= scaled.cols ()) { return doit (scaled, factor, row, col, newRows, newCols, yOffset, xOffset); } - return g_calc[m_resizeFunc] (m_image, row - yOffset, col - xOffset, factor); } --- 842,851 ---- col = 2 * (xOffset + newCols - 1) - x; } ! if ((row - yOffset) < 0 || (row - yOffset) / factor >= m_image.rows () ! || (col - xOffset) < 0 || (col - xOffset) / factor >= m_image.cols ()) { return doit (scaled, factor, row, col, newRows, newCols, yOffset, xOffset); } return g_calc[m_resizeFunc] (m_image, row - yOffset, col - xOffset, factor); } *************** *** 854,857 **** --- 854,902 ---- }; + class OuterBorderFill : public ResizeFillFunc { + public: + OuterBorderFill (const Image &image) + : m_image (image) {} + virtual ~OuterBorderFill (void) {} + virtual coeff operator() (const Image &scaled, double factor, int y, int x, + int newRows, int newCols, + int yOffset, int xOffset) { + return doit (scaled, factor, y, x, newRows, newCols, yOffset, xOffset); + } + private: + virtual coeff doit (const Image &scaled, double factor, int y, int x, + int newRows, int newCols, int yOffset, int xOffset) { + int row; + int col; + + if (y < yOffset) + { + row = 0; + } + else if (y >= yOffset + newRows) + { + row = m_image.rows () - 1; + } + else + { + row = (int)((double)y / factor + 0.5); + } + if (x < xOffset) + { + col = 0; + } + else if (x >= xOffset + newCols) + { + col = m_image.cols () - 1; + } + else + { + col = (int)((double)x / factor + 0.5); + } + return m_image.at (row, col); + } + const Image &m_image; + }; + Image * *************** *** 870,873 **** --- 915,937 ---- Image * + Image::fitInto (int rows, int cols, ExtendFunc extend, int function) const + { + MirrorFill mirrorFunc (*this, function); + OuterBorderFill outerBorderFunc (*this); + switch (extend) + { + case ef_mirror: + return fitInto (rows, cols, &mirrorFunc, function); + break; + case ef_outerBorder: + return fitInto (rows, cols, &outerBorderFunc, function); + break; + default: + assert (0); + } + return NULL; + } + + Image * Image::fitInto (int rows, int cols, ResizeFillFunc *fillFunc, int function) const |