[Kdenlive-devel] Kdenlive feature request : blur
Varol
varokan at movingsatellites.com
Thu Sep 28 10:57:05 UTC 2006
All I just recently implemented the following very fast blur algol in
QDVDAuthor. Please note that it is not a Gausian blur but I believe much
faster.
It should be easy to integrate it into kdenlive
#define qMax(a,b) (a>b)?a:b
#define qMin(a,b) (a<b)?a:b
// Exponential blur, Jani Huhtanen, 2006
//
template<int aprec, int zprec>
static inline void blurinner(unsigned char *bptr, int &zR, int &zG, int
&zB, int &zA, int alpha);
template<int aprec,int zprec>
static inline void blurrow( QImage & im, int line, int alpha);
template<int aprec, int zprec>
static inline void blurcol( QImage & im, int col, int alpha);
/*
* expblur(QImage &img, int radius)
*
* In-place blur of image 'img' with kernel
* of approximate radius 'radius'.
*
* Blurs with two sided exponential impulse
* response.
*
* aprec = precision of alpha parameter
* in fixed-point format 0.aprec
*
* zprec = precision of state parameters
* zR,zG,zB and zA in fp format 8.zprec
*/
template<int aprec,int zprec>
void expblur( QImage &img, int radius )
{
if(radius<1)
return;
/* Calculate the alpha such that 90% of
the kernel is within the radius.
(Kernel extends to infinity)
*/
int alpha = (int)((1<<aprec)*(1.0f-expf(-2.3f/(radius+1.f))));
for(int row=0;row<img.height();row++)
{
blurrow<aprec,zprec>(img,row,alpha);
}
for(int col=0;col<img.width();col++)
{
blurcol<aprec,zprec>(img,col,alpha);
}
return;
}
template<int aprec, int zprec>
static inline void blurinner(unsigned char *bptr, int &zR, int &zG, int
&zB, int &zA, int alpha)
{
int R,G,B,A;
R = *bptr;
G = *(bptr+1);
B = *(bptr+2);
A = *(bptr+3);
zR += (alpha * ((R<<zprec)-zR))>>aprec;
zG += (alpha * ((G<<zprec)-zG))>>aprec;
zB += (alpha * ((B<<zprec)-zB))>>aprec;
zA += (alpha * ((A<<zprec)-zA))>>aprec;
*bptr = zR>>zprec;
*(bptr+1) = zG>>zprec;
*(bptr+2) = zB>>zprec;
*(bptr+3) = zA>>zprec;
}
template<int aprec,int zprec>
static inline void blurrow( QImage & im, int line, int alpha)
{
int zR,zG,zB,zA;
QRgb *ptr = (QRgb *)im.scanLine(line);
zR = *((unsigned char *)ptr )<<zprec;
zG = *((unsigned char *)ptr + 1)<<zprec;
zB = *((unsigned char *)ptr + 2)<<zprec;
zA = *((unsigned char *)ptr + 3)<<zprec;
for(int index=1; index<im.width(); index++)
{
blurinner<aprec,zprec>((unsigned char *)&ptr[index],zR,zG,zB,zA,alpha);
}
for(int index=im.width()-2; index>=0; index--)
{
blurinner<aprec,zprec>((unsigned char *)&ptr[index],zR,zG,zB,zA,alpha);
}
}
template<int aprec, int zprec>
static inline void blurcol( QImage & im, int col, int alpha)
{
int zR,zG,zB,zA;
QRgb *ptr = (QRgb *)im.bits();
ptr+=col;
zR = *((unsigned char *)ptr )<<zprec;
zG = *((unsigned char *)ptr + 1)<<zprec;
zB = *((unsigned char *)ptr + 2)<<zprec;
zA = *((unsigned char *)ptr + 3)<<zprec;
for(int index=im.width(); index<(im.height()-1)*im.width();
index+=im.width())
{
blurinner<aprec,zprec>((unsigned char *)&ptr[index],zR,zG,zB,zA,alpha);
}
for(int index=(im.height()-2)*im.width(); index>=0; index-=im.width())
{
blurinner<aprec,zprec>((unsigned char *)&ptr[index],zR,zG,zB,zA,alpha);
}
}
jmpoure at free.fr wrote:
> Dear friends,
>
> I am working on a community TV show, titled "Les super-héros de l'immobilier"
> (in French : Real-Estate Super-Heroes"), which deals with the burst of the
> real-estate bulle in France. It is approximatively a 10 hour show.
>
> For producing the show, we will be using Kdenlive 0.4 cvs version, although it
> is not considered stable. No problem, we are small community using Free
> Software.
>
> It is requested by the French law that buildings may not be recognized,
> especially because we may shoot pictures in the street without prior
> authorization of the owner.
>
> Therefore, we need a simple blur feature, which would allow to blur certain
> parts of the image. In Kdenlive 0.3, there was no blur feature. I guess this
> feature would be very usefull in Kdenlive 0.4 cvs, especially when the show is
> shot by small communities, without money to go to court in case of a problem.
>
> The show community portal is there :
> http://www.bulle-immobiliere.org/forum/viewforum.php?f=34
>
> Our rush (in French, small part of the film) will be publised here :
> http://www.bulle-immobiliere.org/forum/viewforum.php?f=35
>
> I hope that you can help us with the blur feature.
> Whithout blur, I can not release videos showing buildings.
>
> Kindest regards,
> Jean-Michel
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Kdenlive-devel mailing list
> Kdenlive-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kdenlive-devel
>
More information about the Kdenlive
mailing list