~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to core/imageplugins/enhance/hotpixels/hotpixelfixer.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-11-26 18:24:20 UTC
  • mfrom: (1.9.1) (3.1.23 experimental)
  • Revision ID: package-import@ubuntu.com-20121126182420-qoy6z0nx4ai0wzcl
Tags: 4:3.0.0~beta3-0ubuntu1
* New upstream release
  - Add build-deps :  libhupnp-dev, libqtgstreamer-dev, libmagickcore-dev
* Merge from debian, remaining changes:
  - Make sure libqt4-opengl-dev, libgl1-mesa-dev and libglu1-mesa-dev only
    install on i386,amd64 and powerpc
  - Depend on libtiff-dev instead of libtiff4-dev
  - Drop digikam breaks/replaces kipi-plugins-common since we're past the
    LTS release now
  - digikam to recommend mplayerthumbs | ffmpegthumbs. We currently only
    have latter in the archives, even though former is also supposed to
    be part of kdemultimedia. (LP: #890059)
  - kipi-plugins to recommend www-browser rather than konqueror directly
    since 2.8 no direct usage of konqueror is present in the flickr
    plugin anymore (LP: #1011211)
  - Keep kubuntu_mysqld_executable_name.diff
  - Don't install libkipi translations
  - Keep deps on libcv-dev, libcvaux-dev
  - Keep split packaging of libraries
  - Replace icons from KDE 3 time in debian/xpm.d/*.xpm with the new
    versions (LP: #658047)
* Update debian/not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Date        : 2005-03-27
7
7
 * Description : Threaded image filter to fix hot pixels
8
8
 *
9
 
 * Copyright (C) 2005-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
9
 * Copyright (C) 2005-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
10
10
 * Copyright (C) 2005-2006 by Unai Garro <ugarro at users dot sourceforge dot net>
11
11
 *
12
12
 * This program is free software; you can redistribute it
56
56
namespace DigikamEnhanceImagePlugin
57
57
{
58
58
 
59
 
HotPixelFixer::HotPixelFixer(QObject* parent)
 
59
HotPixelFixer::HotPixelFixer(QObject* const parent)
60
60
    : DImgThreadedFilter(parent)
61
61
{
62
62
    m_interpolationMethod = TWODIM_DIRECTION;
63
63
    initFilter();
64
64
}
65
65
 
66
 
HotPixelFixer::HotPixelFixer(Digikam::DImg* orgImage, QObject* parent, const QList<HotPixel>& hpList,
 
66
HotPixelFixer::HotPixelFixer(Digikam::DImg* const orgImage, QObject* const parent, const QList<HotPixel>& hpList,
67
67
                             int interpolationMethod)
68
68
    : Digikam::DImgThreadedFilter(orgImage, parent, "HotPixels")
69
69
{
82
82
{
83
83
    DefaultFilterAction<HotPixelFixer> action;
84
84
    action.addParameter("interpolationMethod", m_interpolationMethod);
 
85
 
85
86
    foreach(const HotPixel& hp, m_hpList)
86
87
    {
87
88
        QString hpString("%1-%2x%3-%4x%5");
90
91
                   .arg(hp.rect.width()).arg(hp.rect.height());
91
92
        action.addParameter("hotPixel", hpString);
92
93
    }
 
94
 
93
95
    return action;
94
96
}
95
97
 
97
99
{
98
100
    m_interpolationMethod = action.parameter("interpolationMethod").toInt();
99
101
    QRegExp exp("(\\d+)-(\\d+)x(\\d+)-(\\d+)x(\\d+)");
 
102
 
100
103
    foreach(const QVariant& var, action.parameters().values("hotPixel"))
101
104
    {
102
105
        if (exp.exactMatch(var.toString()))
103
106
        {
104
107
            HotPixel hp;
105
108
            hp.luminosity = exp.cap(1).toInt();
106
 
            hp.rect = QRect(exp.cap(2).toInt(), exp.cap(3).toInt(),
107
 
                            exp.cap(4).toInt(), exp.cap(5).toInt());
 
109
            hp.rect       = QRect(exp.cap(2).toInt(), exp.cap(3).toInt(),
 
110
                                  exp.cap(4).toInt(), exp.cap(5).toInt());
108
111
            m_hpList << hp;
109
112
        }
110
113
    }
125
128
}
126
129
 
127
130
// Interpolates a pixel block
128
 
void HotPixelFixer::interpolate (Digikam::DImg& img, HotPixel& hp, int method)
 
131
void HotPixelFixer::interpolate(Digikam::DImg& img, HotPixel& hp, int method)
129
132
{
130
133
    const int xPos = hp.x();
131
134
    const int yPos = hp.y();
142
145
            //case twodim:
143
146
            // {
144
147
            int sum_weight = 0;
145
 
            double vr = 0.0, vg = 0.0, vb = 0.0;
 
148
            double vr      = 0.0, vg = 0.0, vb = 0.0;
146
149
            int x, y;
147
150
            Digikam::DColor col;
148
151
 
195
198
                vb /= (double)sum_weight;
196
199
 
197
200
                for (x = 0; x < hp.width(); ++x)
 
201
                {
198
202
                    for (y = 0; y < hp.height(); ++y)
 
203
                    {
199
204
                        if (validPoint(img,QPoint(xPos+x,yPos+y)))
200
205
                        {
201
206
                            int alpha = sixtBits ? 65535 : 255;
202
207
                            int ir = (int )round(vr), ig = (int) round(vg), ib = (int) round(vb);
203
208
                            img.setPixelColor(xPos+x,yPos+y,Digikam::DColor(ir,ig,ib,alpha,sixtBits));
204
209
                        }
 
210
                    }
 
211
                }
205
212
            }
206
213
 
207
214
            break;
221
228
    }
222
229
}
223
230
 
224
 
void HotPixelFixer::weightPixels (Digikam::DImg& img, HotPixel& px, int method, Direction dir, int maxComponent)
 
231
void HotPixelFixer::weightPixels(Digikam::DImg& img, HotPixel& px, int method, Direction dir, int maxComponent)
225
232
{
226
233
    //TODO: implement direction here too
227
234