SilentEye 0.4.1

modules/seformatjpeg/groupedimage.h

Go to the documentation of this file.
00001 //  This file is part of SilentEye.
00002 //
00003 //  SilentEye is free software: you can redistribute it and/or modify
00004 //  it under the terms of the GNU General Public License as published by
00005 //  the Free Software Foundation, either version 3 of the License, or
00006 //  (at your option) any later version.
00007 //
00008 //  SilentEye is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //  GNU General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU General Public License
00014 //  along with SilentEye. If not, see <http://www.gnu.org/licenses/>.
00015 
00016 #ifndef GROUPEDIMAGE_H_
00017 #define GROUPEDIMAGE_H_
00018 
00019 #define PIXEL_GROUP_SIZE 8
00020 
00021 #include <QObject>
00022 #include <QPointer>
00023 #include <QImage>
00024 #include <QVector>
00025 
00026 #include <logger.h>
00027 #include "ycbcr.h"
00028 
00029 using namespace SilentEyeFramework;
00030 
00031 namespace SEFormatJPEG {
00032 
00034 
00037     class PixelGroup : public QObject{
00038     private:
00040         QPointer<Logger> m_logger;
00041         
00043         QVector< QPointer<YCbCr> > m_pixels;
00045         float m_miv;
00046         
00047     public:
00048         PixelGroup(QObject* parent=0);
00049         ~PixelGroup();
00050 
00052 
00056         QPointer<YCbCr> pixel(quint8, quint8);
00058 
00062         void setPixel(quint8, quint8, QPointer<YCbCr>);
00063         
00064         float miv() const;
00066         void updateMivTo(float);
00067         
00068         QString toString() const;
00069 
00070         static quint8 width() { return PIXEL_GROUP_SIZE; }
00071         static quint8 height() { return PIXEL_GROUP_SIZE; }
00072         
00073     private:
00075         void computeMIV();
00077         void updatePixelMiv(QPointer<YCbCr>, double);
00078     };
00079 
00081     class GroupedImage : public QObject{
00082     private:
00084         QPointer<Logger> m_logger;
00085 
00087         quint16 m_width;
00089         quint16 m_height;
00091         quint16 m_initialWidth;
00093         quint16 m_initialHeight;
00095         QImage::Format m_initialFormat;
00096 
00098         QVector< QPointer<PixelGroup> > m_pg;
00099     public:
00100         GroupedImage(QImage&, quint8, QObject* parent=0);
00101         ~GroupedImage();
00102 
00103         quint16 width();
00104         quint16 height();
00105         quint16 initialWidth();
00106         quint16 initialHeight();
00107 
00109 
00113         QPointer<PixelGroup> pixelGroup(quint16, quint16);
00114 
00116         QImage* toImage();
00118         static void compactImage(QImage&, quint8);
00119 
00120     private:
00121         void compacteAndGroupImage(QImage&, quint8);
00123         static void compactPixel(QPointer<YCbCr>, quint8);
00124     };
00125 
00126 }
00127 
00128 #endif