[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    Gaussian filter bounds problems
From:       Dmitry Kazakov <dimula73 () gmail ! com>
Date:       2010-05-03 6:28:06
Message-ID: j2hae32c1ef1005022328w7aecc74dra0067a47c8574a7f () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi, Edward!

I tried to reproduce the bug with png image bounds today and i failed.
Everything seems to work with Blur and Gaussian Blur filters added as masks
and adjustment layers. Could you describe how to reproduce it here?


Btw, i found a bug in Gaussian Blur filter. Try to apply it to an image that
is bigger than 512x512 pixels. You get a border effect.
The cause is this code, i think:
 if ( (horizontalRadius > 0) && (verticalRadius > 0) )
    {
        KisPaintDeviceSP interm = new KisPaintDevice(src->colorSpace());

        KisConvolutionKernelSP kernelHoriz =
KisConvolutionKernel::fromMatrix(horizGaussian, 0, horizGaussian.sum());
        KisConvolutionKernelSP kernelVertical =
KisConvolutionKernel::fromMatrix(verticalGaussian, 0,
verticalGaussian.sum());

        KisConvolutionPainter horizPainter(interm, dstInfo.selection());
        horizPainter.setChannelFlags(channelFlags);
        horizPainter.setProgress(progressUpdater);
        horizPainter.applyMatrix(kernelHoriz, src, srcTopLeft, srcTopLeft,
size, BORDER_REPEAT);

        KisConvolutionPainter verticalPainter(dst, dstInfo.selection());
        verticalPainter.setChannelFlags(channelFlags);
        verticalPainter.setProgress(progressUpdater);
        verticalPainter.applyMatrix(kernelVertical, interm, srcTopLeft,
dstTopLeft, size, BORDER_REPEAT);
    }

The problem is, when you convolve the second time, there is no needRect
prepared for the convolution. src device has this additional data (it is
prepared by walkers), while interm doesn't. I see the only way out in
bitBlt'ing src into interm, but this will be very inefficient. Or writing a
special RepeatIteratorFactory that might be too complex task...



-- 
Dmitry Kazakov

[Attachment #5 (text/html)]

Hi, Edward!<br><br>I tried to reproduce the bug with png image bounds today and i \
failed. Everything seems to work with Blur and Gaussian Blur filters added as masks \
and adjustment layers. Could you describe  how to reproduce it here?<br> <br><br>Btw, \
i found a bug in Gaussian Blur filter. Try to apply it to an image that is bigger \
than 512x512 pixels. You get a border effect.<br>The cause is this code, i \
think:<br><span style="font-family: courier new,monospace;">  if ( (horizontalRadius \
&gt; 0) &amp;&amp; (verticalRadius &gt; 0) )</span><br style="font-family: courier \
new,monospace;"> <span style="font-family: courier new,monospace;">       {</span><br \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;">               KisPaintDeviceSP interm = new \
KisPaintDevice(src-&gt;colorSpace());</span><br style="font-family: courier \
new,monospace;"> <br style="font-family: courier new,monospace;"><span \
style="font-family: courier new,monospace;">               KisConvolutionKernelSP \
kernelHoriz = KisConvolutionKernel::fromMatrix(horizGaussian, 0, \
horizGaussian.sum());</span><br style="font-family: courier new,monospace;"> <span \
style="font-family: courier new,monospace;">               KisConvolutionKernelSP \
kernelVertical = KisConvolutionKernel::fromMatrix(verticalGaussian, 0, \
verticalGaussian.sum());</span><br style="font-family: courier new,monospace;"> <br \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;">               KisConvolutionPainter horizPainter(interm, \
dstInfo.selection());</span><br style="font-family: courier new,monospace;"> <span \
style="font-family: courier new,monospace;">               \
horizPainter.setChannelFlags(channelFlags);</span><br style="font-family: courier \
new,monospace;"><span style="font-family: courier new,monospace;">               \
horizPainter.setProgress(progressUpdater);</span><br style="font-family: courier \
new,monospace;"> <span style="font-family: courier new,monospace;">               \
horizPainter.applyMatrix(kernelHoriz, src, srcTopLeft, srcTopLeft, size, \
BORDER_REPEAT);</span><br style="font-family: courier new,monospace;"><br \
style="font-family: courier new,monospace;"> <span style="font-family: courier \
new,monospace;">               KisConvolutionPainter verticalPainter(dst, \
dstInfo.selection());</span><br style="font-family: courier new,monospace;"><span \
style="font-family: courier new,monospace;">               \
verticalPainter.setChannelFlags(channelFlags);</span><br style="font-family: courier \
new,monospace;"> <span style="font-family: courier new,monospace;">               \
verticalPainter.setProgress(progressUpdater);</span><br style="font-family: courier \
new,monospace;"><span style="font-family: courier new,monospace;">               \
verticalPainter.applyMatrix(kernelVertical, interm, srcTopLeft, dstTopLeft, size, \
BORDER_REPEAT);</span><br style="font-family: courier new,monospace;"> <span \
style="font-family: courier new,monospace;">       }<br><br>The problem is, when you \
convolve the second time, there is no needRect prepared for the convolution. src \
device has this additional data (it is prepared by walkers), while interm \
doesn&#39;t. I see the only way out in bitBlt&#39;ing src into interm, but this will \
be very inefficient. Or writing a special RepeatIteratorFactory that might be too \
complex task...<br> <br><br style="font-family: courier new,monospace;" \
clear="all"></span><br>-- <br>Dmitry Kazakov<br>



_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic