// ImagePyramid.cpp: implementation of the CImagePyramid class. // ////////////////////////////////////////////////////////////////////// #include #include "ImagePyramid.h" #include "PMImage.h" #include "GaussMatrix.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CImagePyramid::CImagePyramid() { Depth = 0; Gauss = new CGaussMatrix(); Pyramid = new CPMImage *[1](); Pyramid[0] = new CPMImage(); printf("CImagePyramid class (new image pyramid): succesfull...\n"); } CImagePyramid::~CImagePyramid() { for (int i = 0; i < Depth; i++){ Pyramid[i]->~CPMImage(); } } int CImagePyramid::GetDepth() { return Depth; } CImagePyramid::CImagePyramid(char *FileName, int Depth, int GaussSize) { if (Depth < 0) Depth = 0; int sx, sy; this->Depth = Depth; Gauss = new CGaussMatrix(GaussSize); Pyramid = new CPMImage *[Depth](); Pyramid[0] = new CPMImage(FileName); //hp //Pyramid[0]->Smooth(0); sx = Pyramid[0]->GetSizeX(); sy = Pyramid[0]->GetSizeY(); if (Depth > 0){ for (int i = 1; i < Depth; i++){ sx = sx >> 1; sy = sy >> 1; if (sx < 1) sx = 1; if (sy < 1) sy = 1; Pyramid[i] = new CPMImage(sx, sy); } } // make small pictures with Gauss matrix int incX, incY, GaussX, GaussY, color; double tmpr, tmpg, tmpb; for(int i = 0; i < Depth-1; i++){ for (incX = 0; incX < Pyramid[i]->GetSizeX(); incX+=2){ for (incY = 0; incY < Pyramid[i]->GetSizeY(); incY+=2){ tmpr = 0.0; tmpg = 0.0; tmpb = 0.0; for (GaussX = - GaussSize / 2; GaussX GetPixel(incX + GaussX, incY + GaussY) & 0x0000FF) * Gauss->GetXY(GaussX, GaussY); } } for (GaussX = - GaussSize / 2; GaussX < GaussSize / 2 + 1; GaussX++){ for (GaussY = - GaussSize / 2; GaussY < GaussSize / 2 + 1; GaussY++){ tmpg += (double)(Pyramid[i]->GetPixel(incX + GaussX, incY + GaussY) & 0x00FF00 >> 8) * Gauss->GetXY(GaussX, GaussY); } } for (GaussX = - GaussSize / 2; GaussX < GaussSize / 2 + 1; GaussX++){ for (GaussY = - GaussSize / 2; GaussY < GaussSize / 2 + 1; GaussY++){ tmpb += (double)(Pyramid[i]->GetPixel(incX + GaussX, incY + GaussY) & 0xFF0000 >> 16) * Gauss->GetXY(GaussX, GaussY); } } //printf("{%x, %x, %x} ",(unsigned char) tmpr,(unsigned char) tmpg,(unsigned char) tmpb ); color = (unsigned char) tmpr + (((unsigned char) tmpg) << 8) + (((unsigned char) tmpb) << 16); //printf("%x\n", color); Pyramid[i+1]->SetPixel(incX / 2, incY / 2, color); } } } printf("CImagePyramid class (new image pyramid, depth = %d): succesfull...\n", Depth); }