[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/krita/image
From: Dmitry Kazakov <dimula73 () gmail ! com>
Date: 2010-11-13 16:21:11
Message-ID: 20101113162111.9E54DAC89E () svn ! kde ! org
[Download RAW message or body]
SVN commit 1196595 by dkazakov:
Made KisConvolutionWorkerSpatial do convolution instead of correlation
M +12 -9 kis_convolution_worker_fft.h
M +1 -1 kis_convolution_worker_spatial.h
M +2 -3 tests/kis_convolution_painter_test.cpp
--- trunk/koffice/krita/image/kis_convolution_worker_fft.h #1196594:1196595
@@ -104,7 +104,7 @@
for (quint32 i = 0; i < m_noOfChannels; ++i)
m_channelFFT[i] = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * \
m_fftLength);
- // fill in data
+ // fill in function
QVector<PtrToDouble> toDoubleFuncPtr(m_noOfChannels);
KisMathToolbox* mathToolbox = \
KisMathToolboxRegistry::instance()->value(src->colorSpace()->mathToolboxId().id()); \
@@ -249,21 +249,24 @@ // find central item
QPoint offset((kernel->width() - 1) / 2, (kernel->height() - 1) / 2);
- qint32 absXpos, absYpos;
+ qint32 xShift = m_fftWidth - offset.x();
+ qint32 yShift = m_fftHeight - offset.y();
+ quint32 absXpos, absYpos;
+
for (quint32 y = 0; y < kernel->height(); y++)
{
- absYpos = y - offset.y();
- if (absYpos < 0)
- absYpos = m_fftHeight + absYpos;
+ absYpos = y + yShift;
+ if (absYpos >= m_fftHeight)
+ absYpos -= m_fftHeight;
for (quint32 x = 0; x < kernel->width(); x++)
{
- absXpos = x - offset.x();
- if (absXpos < 0)
- absXpos = m_fftWidth + absXpos;
+ absXpos = x + xShift;
+ if (absXpos >= m_fftWidth)
+ absXpos -= m_fftWidth;
- ((double*)m_kernelFFT)[(m_fftWidth + m_extraMem) * absYpos + \
absXpos] = (*(kernel->data()))(y, x); + \
((double*)m_kernelFFT)[(m_fftWidth + m_extraMem) * absYpos + absXpos] = \
kernel->data()->coeff(y, x); }
}
}
--- trunk/koffice/krita/image/kis_convolution_worker_spatial.h #1196594:1196595
@@ -228,7 +228,7 @@
for (quint32 pIndex = 0; pIndex < m_cacheSize; ++pIndex) {
qreal cacheValue = m_pixelPtrCache[pIndex][k];
- interimConvoResult += m_kernelData[pIndex] * cacheValue;
+ interimConvoResult += m_kernelData[m_cacheSize - pIndex - 1] * \
cacheValue; }
double channelPixelValue = (double)(interimConvoResult * m_kernelFactor \
+ m_absoluteOffset[k]);
--- trunk/koffice/krita/image/tests/kis_convolution_painter_test.cpp #1196594:1196595
@@ -174,7 +174,7 @@
KisConvolutionKernelSP kernel =
- KisConvolutionKernel::fromMatrix(filter, 0, factor);
+ KisConvolutionKernel::fromMatrix(filter, 0.5, factor);
KisConvolutionPainter gc(dev);
gc.beginTransaction("");
gc.setChannelFlags(channelFlags);
@@ -187,9 +187,8 @@
dev->readBytes((quint8*)resultData.data(), imageRect);
QRect filteredRect = imageRect.adjusted(1, 1, -1, -1);
- KoColor filteredPixel(QColor(8,8,8,0), dev->colorSpace());
+ KoColor filteredPixel(QColor(120,120,120,128), dev->colorSpace());
- const int numPixels = imageRect.width() * imageRect.height();
quint8 *srcPtr = (quint8*) initialData.data();
quint8 *resPtr = (quint8*) resultData.data();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic