summaryrefslogtreecommitdiffstats
path: root/src/imageplugins/hotpixels/hotpixelfixer.h
blob: 2bf8131c3905909cac455c3227ce1526d7651ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* ============================================================
 * Authors: Unai Garro <ugarro at users dot sourceforge dot net>
 *          Gilles Caulier <caulier dot gilles at free dot fr>
 * Date   : 2005-03-27
 * Description : Threaded image filter to fix hot pixels
 * 
 * Copyright 2005-2007 by Unai Garro and Gilles Caulier
 *
 * The algorithm for fixing the hot pixels was based on
 * the code of jpegpixi, which was released under the GPL license,
 * and is Copyright (C) 2003, 2004 Martin Dickopp
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 * 
 * 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.
 * 
 * ============================================================*/

#ifndef HOTPIXELFIXER_H
#define HOTPIXELFIXER_H

// TQt includes.

#include <tqimage.h>
#include <tqobject.h>
#include <tqvaluelist.h>
#include <tqrect.h>
#include <tqstring.h>

// Digikam includes.

#include "dimgthreadedfilter.h"

// Local includes.

#include "hotpixel.h"
#include "weights.h"

namespace DigikamHotPixelsImagesPlugin
{

class HotPixelFixer : public Digikam::DImgThreadedFilter
{

public:
    
    enum InterpolationMethod 
    {
        AVERAGE_INTERPOLATION   = 0,
        LINEAR_INTERPOLATION    = 1,
        QUADRATIC_INTERPOLATION = 2,
        CUBIC_INTERPOLATION     = 3
    };
    
    enum Direction
    {
        TWODIM_DIRECTION        = 0,
        VERTICAL_DIRECTION      = 1,
        HORIZONTAL_DIRECTION    = 2    
    };

public:
        
    HotPixelFixer(Digikam::DImg *orgImage, TQObject *parent, 
                  const TQValueList<HotPixel>& hpList, int interpolationMethod);
    ~HotPixelFixer();

private: 

    virtual void filterImage(void);
    
    void interpolate (Digikam::DImg &img,HotPixel &hp, int method);
    void weightPixels (Digikam::DImg &img, HotPixel &px, int method, Direction dir, int maxComponent);
    
    inline bool validPoint(Digikam::DImg &img, TQPoint p)
    {
        return (p.x()>=0 && p.y()>=0 && p.x()<(long) img.width() && p.y()<(long) img.height());
    };
    
    TQValueList <Weights> mWeightList;

private: 

    int                  m_interpolationMethod;
       
    TQValueList<HotPixel> m_hpList;
};

}  // NameSpace DigikamHotPixelsImagesPlugin

#endif  // HOTPIXELFIXER_H