00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <QVPyramid>
00026
00027 QVPyramid::QVPyramid(){}
00028
00029 QVPyramid::QVPyramid(int width, int height, int nLevels){
00030
00031 this->width = width;
00032 this->height = height;
00033
00034 this->pyr = new PyramidWithDerivativesCreator ();
00035
00036
00037 this->pyr->allocate(width, height, nLevels);
00038
00039
00040 this->pyr_images = new QVImage<sFloat,1> [nLevels];
00041 }
00042
00043 void QVPyramid::buildPyramid(const QVImage<uChar, 1> &image) {
00044 this->pyr->buildPyramidForGrayscaleImage(image.getReadData());
00045 }
00046
00047 void QVPyramid::getFromGPU() {
00048 int textureWidth, textureHeight;
00049
00050 for (int i=0; i < this->pyr->numberOfLevels(); i++){
00051 this->pyr_images[i] = QVImage<sFloat,1> (width >> i, height >> i);
00052
00053 this->pyr->activateTarget(i);
00054
00055 glReadPixels(0,0, width >> i, height >> i, GL_RED, GL_FLOAT, pyr_images[i].getWriteData());
00056 }
00057 }
00058
00059 QVImage<sFloat,1> QVPyramid::getImage(int level) const{
00060 return this->pyr_images[level];
00061 }
00062
00063 QVPyramid::~QVPyramid(){
00064 this->pyr->deallocate();
00065 }
00066
00067 unsigned int QVPyramid::getID() const{
00068 return this->pyr->textureID();
00069 }
00070
00071 int QVPyramid::getWidth () const{
00072 return this->width;
00073 }
00074
00075 int QVPyramid::getHeight() const{
00076 return this->height;
00077 }