Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 4f45e7bdfd4a5ff17f5f8eaab90d017f > files > 430

albumshaper-2.1-6mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>AlbumShaper: blur.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>blur.cpp</h1><a href="blur_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//==============================================</span>
<a name="l00002"></a>00002 <span class="comment">//  copyright            : (C) 2003-2005 by Will Stokes</span>
<a name="l00003"></a>00003 <span class="comment">//==============================================</span>
<a name="l00004"></a>00004 <span class="comment">//  This program is free software; you can redistribute it</span>
<a name="l00005"></a>00005 <span class="comment">//  and/or modify it under the terms of the GNU General</span>
<a name="l00006"></a>00006 <span class="comment">//  Public License as published by the Free Software</span>
<a name="l00007"></a>00007 <span class="comment">//  Foundation; either version 2 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">//  (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//==============================================</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">//Systemwide includes</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;qimage.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;qstring.h&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="comment">//Projectwide includes</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="blur_8h.html">blur.h</a>"</span>
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 <span class="comment">//----------------------------------------------</span>
<a name="l00020"></a>00020 <span class="comment">// Inputs:</span>
<a name="l00021"></a>00021 <span class="comment">// -------</span>
<a name="l00022"></a>00022 <span class="comment">// QImage&amp; - image to be blurred</span>
<a name="l00023"></a>00023 <span class="comment">// Float sigma - amount of blurring desired</span>
<a name="l00024"></a>00024 <span class="comment">//</span>
<a name="l00025"></a>00025 <span class="comment">// Description:</span>
<a name="l00026"></a>00026 <span class="comment">// ------------</span>
<a name="l00027"></a>00027 <span class="comment">// This method blurs a color image using the approach published</span>
<a name="l00028"></a>00028 <span class="comment">// by Ian T. Young and Lucas J. van Vliet, "Recursive implementation</span>
<a name="l00029"></a>00029 <span class="comment">// of the Gaussian filter", 1995 Signal Processing.</span>
<a name="l00030"></a>00030 <span class="comment">//</span>
<a name="l00031"></a>00031 <span class="comment">// The first solution one might take to blurring an image</span>
<a name="l00032"></a>00032 <span class="comment">// is to convolve a gaussian filter with an image. This is expensive since</span>
<a name="l00033"></a>00033 <span class="comment">// as the gaussian filter matrix grows, processing becomes quite expensive</span>
<a name="l00034"></a>00034 <span class="comment">// ( O(M^2 * N^2) where M is the width/height of the gaussian matrix and N is the </span>
<a name="l00035"></a>00035 <span class="comment">// width/height of the image. )</span>
<a name="l00036"></a>00036 <span class="comment">//</span>
<a name="l00037"></a>00037 <span class="comment">// An alternative is to approximate a gaussian by repeatedly convolving a kernel </span>
<a name="l00038"></a>00038 <span class="comment">// such as uniform filter. While faster, this is only an approximation of a </span>
<a name="l00039"></a>00039 <span class="comment">// gaussian, and the weights one uses for each iteration must be hand picked in</span>
<a name="l00040"></a>00040 <span class="comment">// order to follow the Well's equation:</span>
<a name="l00041"></a>00041 <span class="comment">// (W_1^2 + W_2^2 + W_3^2 + W_4^2 = 12*sigma^2 + 4)</span>
<a name="l00042"></a>00042 <span class="comment">//</span>
<a name="l00043"></a>00043 <span class="comment">// This process is tedious and limits us in applying intermediate blur amounts.</span>
<a name="l00044"></a>00044 <span class="comment">//</span>
<a name="l00045"></a>00045 <span class="comment">// In theory Young and Vliet's technique (which is O(4N^2) = O(N^2)) is not only</span>
<a name="l00046"></a>00046 <span class="comment">// more accurate but faster as well. The only penalty we pay is the extra storage</span>
<a name="l00047"></a>00047 <span class="comment">// of a row or column while that row or column is being processed. For a </span>
<a name="l00048"></a>00048 <span class="comment">// 2048x2048 image my implementation will require an extra 16kb for this extra </span>
<a name="l00049"></a>00049 <span class="comment">// storage space, a drop in the bucket compared to the memory required to hold</span>
<a name="l00050"></a>00050 <span class="comment">// the entire image in float memory while being processed.</span>
<a name="l00051"></a>00051 <span class="comment">//</span>
<a name="l00052"></a>00052 <span class="comment">// Before being blurred color values are converted from integer [0-255] to float</span>
<a name="l00053"></a>00053 <span class="comment">// [0.0-1.0] space. This is necessary to avoid compound rounding errors. In order</span>
<a name="l00054"></a>00054 <span class="comment">// to minimize space required to store the float buffer, the image is processed </span>
<a name="l00055"></a>00055 <span class="comment">// in three passes for each of the red, green, and blue color channels.</span>
<a name="l00056"></a>00056 <span class="comment">//</span>
<a name="l00057"></a>00057 <span class="comment">// Since the code is broken up nicely, well commented, and is a direct </span>
<a name="l00058"></a>00058 <span class="comment">// implementation of Young and Vliet's techinque I point you to their paper for a</span>
<a name="l00059"></a>00059 <span class="comment">// better understanding of why/how this techinque actually works. Vliet has a </span>
<a name="l00060"></a>00060 <span class="comment">// copy on his personal web site, last seen at:</span>
<a name="l00061"></a>00061 <span class="comment">// http://www.ph.tn.tudelft.nl/~lucas/</span>
<a name="l00062"></a>00062 <span class="comment">//----------------------------------------------</span>
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#05a2bdd9a08d923f1cbb51fb3c82e87a">computeCoeffs</a>( <span class="keywordtype">float</span> sigma );
<a name="l00065"></a>00065 <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#4f60299801c18dfeb6188d1905dc9753">fillBuffer</a>( QImage &amp;image, <span class="keywordtype">int</span> channel );
<a name="l00066"></a>00066 <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#94205af164693648b9082eefcbb9cdbc">blurBuffer</a>();
<a name="l00067"></a>00067 
<a name="l00068"></a>00068 <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#91fed80947f02fc86a923a68a37fd0c9">blurRow</a>( <span class="keywordtype">int</span> row );
<a name="l00069"></a>00069 <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#7cf2d364e9c5bd5c66fee296c5b85784">blurColumn</a>( <span class="keywordtype">int</span> column );
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#e2bd8758f167288d1f3f3be7cd77c4e3">blurRegionsInRow</a>( <span class="keywordtype">int</span> y );
<a name="l00072"></a>00072 <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#5b070fddaaa81dc81a431ce9741a5fc8">blurRegionsInCol</a>( <span class="keywordtype">int</span> x );
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#7fbca6e5494a3008dd90ec0d6103bba0">resetImageData</a>( QImage &amp;image, <span class="keywordtype">int</span> channel, <span class="keywordtype">bool</span> blurEdges);
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 <span class="keywordtype">float</span> <a class="code" href="blur_8cpp.html#374c077a12cb98c0a52723b460079ae9">edgeValue</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
<a name="l00077"></a>00077 
<a name="l00078"></a><a class="code" href="blur_8cpp.html#0a19a0620af7373e3ddba0ce4e1058e1">00078</a> <span class="keywordtype">float</span> <a class="code" href="blur_8cpp.html#0a19a0620af7373e3ddba0ce4e1058e1">q</a>, <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>, <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a>, <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a>, <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a>, <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a>;
<a name="l00079"></a><a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">00079</a> <span class="keywordtype">int</span> <a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>, <a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>;
<a name="l00080"></a><a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">00080</a> <span class="keywordtype">float</span>* <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>;
<a name="l00081"></a><a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">00081</a> <span class="keywordtype">float</span>* <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>;
<a name="l00082"></a><a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">00082</a> <span class="keywordtype">float</span>* <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>;
<a name="l00083"></a>00083 
<a name="l00084"></a><a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">00084</a> <span class="keywordtype">float</span>* <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>;
<a name="l00085"></a><a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">00085</a> <span class="keywordtype">float</span>* <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>;
<a name="l00086"></a>00086 
<a name="l00087"></a><a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">00087</a> QImage* <a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>;
<a name="l00088"></a><a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">00088</a> <span class="keywordtype">int</span>* <a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">regionMap</a>;
<a name="l00089"></a><a class="code" href="blur_8cpp.html#99011823ef56f33be976af30f313f132">00089</a> <span class="keywordtype">int</span> <a class="code" href="blur_8cpp.html#99011823ef56f33be976af30f313f132">regionCount</a>;
<a name="l00090"></a><a class="code" href="blur_8cpp.html#b9f240ebcd7065350a7b041439db28ab">00090</a> QPoint <a class="code" href="blur_8cpp.html#b9f240ebcd7065350a7b041439db28ab">displayOffset</a>;
<a name="l00091"></a><a class="code" href="blur_8cpp.html#b903d24dabd249aee4c0d5335f332d02">00091</a> QSize <a class="code" href="blur_8cpp.html#b903d24dabd249aee4c0d5335f332d02">fullRes</a>;
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 <span class="comment">//==============================================</span>
<a name="l00094"></a><a class="code" href="blur_8h.html#e7be57816a66918a26e567655f4b8e1c">00094</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#e7be57816a66918a26e567655f4b8e1c">blurImage</a>( QImage &amp;image, <span class="keywordtype">float</span> sigma )
<a name="l00095"></a>00095 {
<a name="l00096"></a>00096   <span class="comment">//supply dummy data for edges, notably NULL for the edge image pointer.</span>
<a name="l00097"></a>00097   <span class="comment">//other values have no effect</span>
<a name="l00098"></a>00098   <a class="code" href="blur_8cpp.html#e7be57816a66918a26e567655f4b8e1c">blurImage</a>( image, sigma, QPoint(0,0), image.size(), NULL, NULL, 0, false );
<a name="l00099"></a>00099 }
<a name="l00100"></a>00100 <span class="comment">//==============================================</span>
<a name="l00101"></a><a class="code" href="blur_8h.html#e42c06320d849e8fca2912fa5dd38eed">00101</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#e7be57816a66918a26e567655f4b8e1c">blurImage</a>( QImage &amp;image, <span class="keywordtype">float</span> sigma,
<a name="l00102"></a>00102                 QPoint offset, QSize fullImageRes,
<a name="l00103"></a>00103                 QImage* edges, <span class="keywordtype">int</span>* regions, <span class="keywordtype">int</span> numRegions,
<a name="l00104"></a>00104                 <span class="keywordtype">bool</span> targetEdges)
<a name="l00105"></a>00105 {
<a name="l00106"></a>00106   <a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a> = edges;
<a name="l00107"></a>00107   <a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">regionMap</a> = regions;
<a name="l00108"></a>00108   <a class="code" href="blur_8cpp.html#99011823ef56f33be976af30f313f132">regionCount</a> = numRegions;
<a name="l00109"></a>00109   <a class="code" href="blur_8cpp.html#b9f240ebcd7065350a7b041439db28ab">displayOffset</a> = offset;
<a name="l00110"></a>00110   <a class="code" href="blur_8cpp.html#b903d24dabd249aee4c0d5335f332d02">fullRes</a> = fullImageRes;
<a name="l00111"></a>00111   
<a name="l00112"></a>00112   <span class="comment">//compute blurring coeffecients</span>
<a name="l00113"></a>00113   <a class="code" href="blur_8cpp.html#05a2bdd9a08d923f1cbb51fb3c82e87a">computeCoeffs</a>(sigma);
<a name="l00114"></a>00114   
<a name="l00115"></a>00115   <span class="comment">//store image dimensions</span>
<a name="l00116"></a>00116   <a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a> = image.width();
<a name="l00117"></a>00117   <a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a> = image.height();
<a name="l00118"></a>00118   
<a name="l00119"></a>00119   <span class="comment">//Construct float buffer that is the size of the image/</span>
<a name="l00120"></a>00120   <span class="comment">//In order to conserve memory process image three times, once for</span>
<a name="l00121"></a>00121   <span class="comment">//each color channel.</span>
<a name="l00122"></a>00122   <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a> = <span class="keyword">new</span> <span class="keywordtype">float</span>[ <a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a> * <a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a> ];
<a name="l00123"></a>00123 
<a name="l00124"></a>00124   <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a> = <span class="keyword">new</span> <span class="keywordtype">float</span>[<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>];
<a name="l00125"></a>00125   <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a> = <span class="keyword">new</span> <span class="keywordtype">float</span>[<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>];
<a name="l00126"></a>00126   
<a name="l00127"></a>00127   <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a> = <span class="keyword">new</span> <span class="keywordtype">float</span>[<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a> * numRegions];
<a name="l00128"></a>00128   <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a> = <span class="keyword">new</span> <span class="keywordtype">float</span>[<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a> * numRegions];
<a name="l00129"></a>00129   
<a name="l00130"></a>00130   <span class="comment">//iterate over each color channel</span>
<a name="l00131"></a>00131   <span class="keywordtype">int</span> channel;
<a name="l00132"></a>00132   <span class="keywordflow">for</span>( channel = 0; channel &lt;=2; channel++)
<a name="l00133"></a>00133   {
<a name="l00134"></a>00134     <span class="comment">//copy color data into float buffer</span>
<a name="l00135"></a>00135     <a class="code" href="blur_8cpp.html#4f60299801c18dfeb6188d1905dc9753">fillBuffer</a>( image, channel );
<a name="l00136"></a>00136     
<a name="l00137"></a>00137     <span class="comment">//blur buffer data</span>
<a name="l00138"></a>00138     <a class="code" href="blur_8cpp.html#94205af164693648b9082eefcbb9cdbc">blurBuffer</a>();
<a name="l00139"></a>00139     
<a name="l00140"></a>00140     <span class="comment">//reset image data used blurred buffer</span>
<a name="l00141"></a>00141     <a class="code" href="blur_8cpp.html#7fbca6e5494a3008dd90ec0d6103bba0">resetImageData</a>(image, channel, targetEdges);
<a name="l00142"></a>00142   }
<a name="l00143"></a>00143   
<a name="l00144"></a>00144   <span class="comment">//delete buffer</span>
<a name="l00145"></a>00145   <span class="keyword">delete</span>[] <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>;
<a name="l00146"></a>00146   <span class="keyword">delete</span>[] <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>;
<a name="l00147"></a>00147   <span class="keyword">delete</span>[] <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>;
<a name="l00148"></a>00148 }
<a name="l00149"></a>00149 <span class="comment">//==============================================</span>
<a name="l00150"></a><a class="code" href="blur_8cpp.html#05a2bdd9a08d923f1cbb51fb3c82e87a">00150</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#05a2bdd9a08d923f1cbb51fb3c82e87a">computeCoeffs</a>( <span class="keywordtype">float</span> sigma )
<a name="l00151"></a>00151 {
<a name="l00152"></a>00152   <span class="comment">//compute q as a function of sigma</span>
<a name="l00153"></a>00153   <span class="keywordflow">if</span>( sigma &gt;= 2.5f )
<a name="l00154"></a>00154   {
<a name="l00155"></a>00155     <a class="code" href="blur_8cpp.html#0a19a0620af7373e3ddba0ce4e1058e1">q</a> = 0.98711f*sigma - 0.96330f;  
<a name="l00156"></a>00156   }
<a name="l00157"></a>00157   <span class="keywordflow">else</span>
<a name="l00158"></a>00158   {
<a name="l00159"></a>00159     <a class="code" href="blur_8cpp.html#0a19a0620af7373e3ddba0ce4e1058e1">q</a> = 3.97156f - 4.14554f * sqrt( 1.0f - 0.26891f*sigma );
<a name="l00160"></a>00160   }
<a name="l00161"></a>00161 
<a name="l00162"></a>00162   <span class="comment">//compute b0, b1, b2, and b3</span>
<a name="l00163"></a>00163   <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a> = 1.57825f + (2.44413f*<a class="code" href="blur_8cpp.html#0a19a0620af7373e3ddba0ce4e1058e1">q</a>) + (1.4281f * <a class="code" href="blur_8cpp.html#0a19a0620af7373e3ddba0ce4e1058e1">q</a>*<a class="code" href="blur_8cpp.html#0a19a0620af7373e3ddba0ce4e1058e1">q</a> ) + (0.422205f * q*q*q );
<a name="l00164"></a>00164   <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a> = (2.44413f * q) + (2.85619f * q*q) + (1.26661 * q*q*q );
<a name="l00165"></a>00165   <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> = -((1.4281 * q*q) + (1.26661 * q*q*q));
<a name="l00166"></a>00166   <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a> = 0.422205 * q*q*q;
<a name="l00167"></a>00167   
<a name="l00168"></a>00168   <span class="comment">//compute B</span>
<a name="l00169"></a>00169   <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a> = 1.0f - ((<a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a> + <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> + <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a>) / <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>); 
<a name="l00170"></a>00170 }
<a name="l00171"></a>00171 <span class="comment">//==============================================</span>
<a name="l00172"></a><a class="code" href="blur_8cpp.html#4f60299801c18dfeb6188d1905dc9753">00172</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#4f60299801c18dfeb6188d1905dc9753">fillBuffer</a>( QImage &amp;image, <span class="keywordtype">int</span> channel )
<a name="l00173"></a>00173 {
<a name="l00174"></a>00174   <span class="comment">//precompute 1/255</span>
<a name="l00175"></a>00175   <span class="keywordtype">float</span> multiplier = 1.0f / 255.0f;
<a name="l00176"></a>00176   
<a name="l00177"></a>00177   <span class="comment">//iterate over each selected scanline </span>
<a name="l00178"></a>00178   <span class="keywordtype">int</span> x, y;
<a name="l00179"></a>00179   QRgb* rgb;
<a name="l00180"></a>00180   uchar* scanLine;
<a name="l00181"></a>00181   <span class="keywordflow">for</span>( y=0; y&lt;image.height(); y++)
<a name="l00182"></a>00182   {   
<a name="l00183"></a>00183     <span class="comment">//iterate over each pixel in scanline</span>
<a name="l00184"></a>00184     scanLine = image.scanLine(y);
<a name="l00185"></a>00185     <span class="keywordflow">for</span>( x=0; x&lt;image.width(); x++)
<a name="l00186"></a>00186     {
<a name="l00187"></a>00187       <span class="comment">//get handle on rgb value in image</span>
<a name="l00188"></a>00188       rgb = ((QRgb*)scanLine+x);
<a name="l00189"></a>00189 
<a name="l00190"></a>00190       <span class="comment">//compute index where float value is stored in buffer</span>
<a name="l00191"></a>00191       <span class="keywordtype">int</span> index = x + y*image.width();
<a name="l00192"></a>00192       
<a name="l00193"></a>00193       <span class="comment">//convert and store correct channel in buffer</span>
<a name="l00194"></a>00194       <span class="keywordflow">if</span>( channel == 0 )
<a name="l00195"></a>00195         <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[index] = multiplier * qRed( *rgb );
<a name="l00196"></a>00196       <span class="keywordflow">else</span> <span class="keywordflow">if</span>( channel == 1 )
<a name="l00197"></a>00197         <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[index] = multiplier * qGreen( *rgb );
<a name="l00198"></a>00198       <span class="keywordflow">else</span>
<a name="l00199"></a>00199         <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[index] = multiplier * qBlue( *rgb );
<a name="l00200"></a>00200     } <span class="comment">//x</span>
<a name="l00201"></a>00201   } <span class="comment">//y</span>
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 <span class="comment">//==============================================</span>
<a name="l00204"></a><a class="code" href="blur_8cpp.html#94205af164693648b9082eefcbb9cdbc">00204</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#94205af164693648b9082eefcbb9cdbc">blurBuffer</a>()
<a name="l00205"></a>00205 {
<a name="l00206"></a>00206   <span class="comment">//blur rows, then columns</span>
<a name="l00207"></a>00207   <span class="keywordtype">int</span> index;
<a name="l00208"></a>00208   
<a name="l00209"></a>00209   <span class="keywordflow">if</span>(<a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">regionMap</a> == NULL || <a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a> == NULL )
<a name="l00210"></a>00210   {
<a name="l00211"></a>00211     <span class="keywordflow">for</span>(index=0; index &lt; <a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>; index++)
<a name="l00212"></a>00212     { <a class="code" href="blur_8cpp.html#91fed80947f02fc86a923a68a37fd0c9">blurRow</a>( index ); }
<a name="l00213"></a>00213     
<a name="l00214"></a>00214     <span class="keywordflow">for</span>(index=0; index&lt; <a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>; index++)
<a name="l00215"></a>00215     { <a class="code" href="blur_8cpp.html#7cf2d364e9c5bd5c66fee296c5b85784">blurColumn</a>( index ); }
<a name="l00216"></a>00216   }
<a name="l00217"></a>00217   <span class="keywordflow">else</span>
<a name="l00218"></a>00218   {
<a name="l00219"></a>00219     <span class="keywordflow">for</span>(index=0; index &lt; <a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>; index++)
<a name="l00220"></a>00220     { <a class="code" href="blur_8cpp.html#e2bd8758f167288d1f3f3be7cd77c4e3">blurRegionsInRow</a>( index ); }
<a name="l00221"></a>00221     
<a name="l00222"></a>00222     <span class="keywordflow">for</span>(index=0; index&lt; <a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>; index++)
<a name="l00223"></a>00223     { <a class="code" href="blur_8cpp.html#5b070fddaaa81dc81a431ce9741a5fc8">blurRegionsInCol</a>( index ); }
<a name="l00224"></a>00224   }
<a name="l00225"></a>00225 }
<a name="l00226"></a>00226 <span class="comment">//==============================================</span>
<a name="l00227"></a><a class="code" href="blur_8cpp.html#66793d4213f628c343f1b318e1026b73">00227</a> <span class="keywordtype">int</span> <a class="code" href="blur_8cpp.html#66793d4213f628c343f1b318e1026b73">regionIndex</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y)
<a name="l00228"></a>00228 {
<a name="l00229"></a>00229   <span class="keywordtype">int</span> edgeX = ((<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;width()-1) * (x+<a class="code" href="blur_8cpp.html#b9f240ebcd7065350a7b041439db28ab">displayOffset</a>.x())) / (<a class="code" href="blur_8cpp.html#b903d24dabd249aee4c0d5335f332d02">fullRes</a>.width()-1);
<a name="l00230"></a>00230   <span class="keywordtype">int</span> edgeY = ((<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;height()-1) * (y+<a class="code" href="blur_8cpp.html#b9f240ebcd7065350a7b041439db28ab">displayOffset</a>.y())) / (<a class="code" href="blur_8cpp.html#b903d24dabd249aee4c0d5335f332d02">fullRes</a>.height()-1);
<a name="l00231"></a>00231   <span class="keywordflow">return</span> edgeY*<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;width() + edgeX;
<a name="l00232"></a>00232 }
<a name="l00233"></a>00233 <span class="comment">//==============================================</span>
<a name="l00234"></a><a class="code" href="blur_8cpp.html#374c077a12cb98c0a52723b460079ae9">00234</a> <span class="keywordtype">float</span> <a class="code" href="blur_8cpp.html#374c077a12cb98c0a52723b460079ae9">edgeValue</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y)
<a name="l00235"></a>00235 {
<a name="l00236"></a>00236   <span class="comment">//compute floating point x and y coordinates for edge image</span>
<a name="l00237"></a>00237   <span class="keywordtype">float</span> edgeX = ((<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;width()-1.0f) * (x+<a class="code" href="blur_8cpp.html#b9f240ebcd7065350a7b041439db28ab">displayOffset</a>.x())) / (<a class="code" href="blur_8cpp.html#b903d24dabd249aee4c0d5335f332d02">fullRes</a>.width()-1);
<a name="l00238"></a>00238   <span class="keywordtype">float</span> edgeY = ((<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;height()-1.0f) * (y+<a class="code" href="blur_8cpp.html#b9f240ebcd7065350a7b041439db28ab">displayOffset</a>.y())) / (<a class="code" href="blur_8cpp.html#b903d24dabd249aee4c0d5335f332d02">fullRes</a>.height()-1);
<a name="l00239"></a>00239   
<a name="l00240"></a>00240   <span class="comment">//compute 4 int values of coordinates</span>
<a name="l00241"></a>00241   <span class="keywordtype">int</span> x1 = (int)edgeX;
<a name="l00242"></a>00242   <span class="keywordtype">int</span> y1 = (int)edgeY;
<a name="l00243"></a>00243   <span class="keywordtype">int</span> x2, y2;
<a name="l00244"></a>00244   <span class="keywordflow">if</span>( edgeX &gt; x1 )
<a name="l00245"></a>00245     x2 = x1+1;
<a name="l00246"></a>00246   <span class="keywordflow">else</span>
<a name="l00247"></a>00247     x2 = x1;
<a name="l00248"></a>00248   <span class="keywordflow">if</span>( edgeY &gt; y1 )
<a name="l00249"></a>00249     y2 = y1+1;
<a name="l00250"></a>00250   <span class="keywordflow">else</span>
<a name="l00251"></a>00251     y2 = y1;
<a name="l00252"></a>00252   
<a name="l00253"></a>00253   <span class="comment">//compute the four indices</span>
<a name="l00254"></a>00254   <span class="keywordtype">int</span> index1, index2, index3, index4;
<a name="l00255"></a>00255   index1 = x1 + y1*<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;width();
<a name="l00256"></a>00256   index2 = x2 + y1*<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;width();
<a name="l00257"></a>00257   index3 = x1 + y2*<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;width();
<a name="l00258"></a>00258   index4 = x2 + y2*<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;width();
<a name="l00259"></a>00259   
<a name="l00260"></a>00260   <span class="comment">//find edge quantity for each corner</span>
<a name="l00261"></a>00261   <span class="keywordtype">float</span> v1, v2, v3, v4; 
<a name="l00262"></a>00262   uchar* scanline = <a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;scanLine( y1 );
<a name="l00263"></a>00263   QRgb* rgb = ((QRgb*)scanline+x1);
<a name="l00264"></a>00264   v1 = ((float) qRed( *rgb )) / 255.0f;
<a name="l00265"></a>00265   rgb = ((QRgb*)scanline+x2);
<a name="l00266"></a>00266   v2 = ((float) qRed( *rgb )) / 255.0f;
<a name="l00267"></a>00267 
<a name="l00268"></a>00268   scanline = <a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;scanLine( y2 );
<a name="l00269"></a>00269   rgb = ((QRgb*)scanline+x1);
<a name="l00270"></a>00270   v3 = ((float) qRed( *rgb )) / 255.0f;
<a name="l00271"></a>00271   rgb = ((QRgb*)scanline+x2);
<a name="l00272"></a>00272   v4 = ((float) qRed( *rgb )) / 255.0f;
<a name="l00273"></a>00273   
<a name="l00274"></a>00274   <span class="comment">//blur combine left-right</span>
<a name="l00275"></a>00275   v1 = (edgeX-x1)*v2 + (1 - edgeX + x1)*v1;
<a name="l00276"></a>00276   v3 = (edgeX-x1)*v4 + (1 - edgeX + x1)*v3;
<a name="l00277"></a>00277   
<a name="l00278"></a>00278   <span class="comment">//combine top-bottom</span>
<a name="l00279"></a>00279   v1 = (edgeY-y1)*v3 + (1 - edgeY + y1)*v1;
<a name="l00280"></a>00280   
<a name="l00281"></a>00281   <span class="comment">//return result</span>
<a name="l00282"></a>00282   <span class="keywordflow">return</span> v1;
<a name="l00283"></a>00283 }
<a name="l00284"></a>00284 <span class="comment">//==============================================</span>
<a name="l00285"></a><a class="code" href="blur_8cpp.html#91fed80947f02fc86a923a68a37fd0c9">00285</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#91fed80947f02fc86a923a68a37fd0c9">blurRow</a>( <span class="keywordtype">int</span> row )
<a name="l00286"></a>00286 {
<a name="l00287"></a>00287   <span class="keywordtype">int</span> i;
<a name="l00288"></a>00288   <span class="keywordtype">int</span> rtw = row*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>;
<a name="l00289"></a>00289   
<a name="l00290"></a>00290   <span class="comment">//forward</span>
<a name="l00291"></a>00291   <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[0] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ 0 + rtw ];
<a name="l00292"></a>00292   <span class="keywordflow">for</span>(i=1; i&lt;width; i++)
<a name="l00293"></a>00293   {
<a name="l00294"></a>00294      <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[i] = <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a>*<a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ i + rtw ] +
<a name="l00295"></a>00295      ( <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a>*<a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[ QMAX(i-1, 0) ] +
<a name="l00296"></a>00296        <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> * <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[ QMAX(i-2, 0) ] +
<a name="l00297"></a>00297        <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a> * <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[ QMAX(i-3, 0) ]) / <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>;    
<a name="l00298"></a>00298     
<a name="l00299"></a>00299   }
<a name="l00300"></a>00300   
<a name="l00301"></a>00301   <span class="comment">//reverse</span>
<a name="l00302"></a>00302   <span class="keywordflow">for</span>(i=width-1; i&gt;=0; i--)
<a name="l00303"></a>00303   {
<a name="l00304"></a>00304      <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ i + rtw ] = <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a>*<a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[ i ] +
<a name="l00305"></a>00305      ( <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a> * <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ QMIN(i+1, width-1) + rtw ] +
<a name="l00306"></a>00306        <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> * <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ QMIN(i+2, width-1) + rtw ] +
<a name="l00307"></a>00307        <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a> * <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ QMIN(i+3, width-1) + rtw ]) / <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>;    
<a name="l00308"></a>00308   }
<a name="l00309"></a>00309 }
<a name="l00310"></a>00310 <span class="comment">//==============================================</span>
<a name="l00311"></a><a class="code" href="blur_8cpp.html#e2bd8758f167288d1f3f3be7cd77c4e3">00311</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#e2bd8758f167288d1f3f3be7cd77c4e3">blurRegionsInRow</a>( <span class="keywordtype">int</span> y )
<a name="l00312"></a>00312 {
<a name="l00313"></a>00313   <span class="comment">//---------------------------------</span>
<a name="l00314"></a>00314   <span class="comment">//populate region row buffer. a row has been allocated for </span>
<a name="l00315"></a>00315   <span class="comment">//each region. Pixels between regions</span>
<a name="l00316"></a>00316   <span class="comment">//take the closest pixel value in that row from that region</span>
<a name="l00317"></a>00317   <span class="keywordtype">int</span> yTimesWidth = y*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>;
<a name="l00318"></a>00318   <span class="keywordtype">int</span> regionTimesWidth;
<a name="l00319"></a>00319   <span class="keywordtype">int</span> region,x,x2;
<a name="l00320"></a>00320   
<a name="l00321"></a>00321   <span class="comment">//for each region</span>
<a name="l00322"></a>00322   <span class="keywordflow">for</span>(region=0; region&lt;<a class="code" href="blur_8cpp.html#99011823ef56f33be976af30f313f132">regionCount</a>; region++)
<a name="l00323"></a>00323   {
<a name="l00324"></a>00324     regionTimesWidth = region*width;
<a name="l00325"></a>00325     <span class="keywordtype">int</span> lastX = -1;
<a name="l00326"></a>00326     <span class="keywordflow">for</span>(x=0; x&lt;width; x++)
<a name="l00327"></a>00327     {
<a name="l00328"></a>00328       <span class="comment">//if pixel belongs to this region then update lastX index and copy value over</span>
<a name="l00329"></a>00329       <span class="comment">//if lastX is mroe than one pixel away than fill inbetween region</span>
<a name="l00330"></a>00330       <span class="keywordflow">if</span>( region == <a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">regionMap</a>[<a class="code" href="blur_8cpp.html#66793d4213f628c343f1b318e1026b73">regionIndex</a>(x, y)] )
<a name="l00331"></a>00331       {
<a name="l00332"></a>00332         <span class="comment">//fill empty region preceeding this region blob</span>
<a name="l00333"></a>00333         <span class="keywordflow">if</span>( lastX &lt; x-1)
<a name="l00334"></a>00334         {
<a name="l00335"></a>00335           <span class="comment">//no preceeding region, spread left!</span>
<a name="l00336"></a>00336           <span class="keywordflow">if</span>(lastX == -1)
<a name="l00337"></a>00337           {
<a name="l00338"></a>00338             <span class="keywordflow">for</span>(x2=0; x2&lt;x; x2++) { <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[x2 + regionTimesWidth] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + yTimesWidth]; }
<a name="l00339"></a>00339           }
<a name="l00340"></a>00340           <span class="comment">//else spread from both left and right of empty stretch</span>
<a name="l00341"></a>00341           <span class="keywordflow">else</span>
<a name="l00342"></a>00342           {
<a name="l00343"></a>00343             <span class="keywordtype">int</span> xMid = lastX + ((x-1) - lastX)/2;
<a name="l00344"></a>00344             
<a name="l00345"></a>00345             <span class="keywordflow">for</span>(x2=lastX+1; x2&lt;=xMid; x2++)
<a name="l00346"></a>00346             { <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[x2 + regionTimesWidth] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[lastX + yTimesWidth]; }
<a name="l00347"></a>00347 
<a name="l00348"></a>00348             <span class="keywordflow">for</span>(x2=xMid+1; x2&lt;x; x2++)
<a name="l00349"></a>00349             { <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[x2 + regionTimesWidth] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + yTimesWidth]; }
<a name="l00350"></a>00350           }
<a name="l00351"></a>00351         }
<a name="l00352"></a>00352         
<a name="l00353"></a>00353         <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[x + regionTimesWidth] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + yTimesWidth];
<a name="l00354"></a>00354         lastX = x;
<a name="l00355"></a>00355       } 
<a name="l00356"></a>00356     } <span class="comment">//x</span>
<a name="l00357"></a>00357     
<a name="l00358"></a>00358     <span class="comment">//if last stretch is empty, fill right</span>
<a name="l00359"></a>00359     <span class="keywordflow">if</span>( region != <a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">regionMap</a>[<a class="code" href="blur_8cpp.html#66793d4213f628c343f1b318e1026b73">regionIndex</a>(width-1, y)] )
<a name="l00360"></a>00360     {
<a name="l00361"></a>00361       <span class="keywordflow">for</span>(x2=lastX+1; x2&lt;width; x2++)
<a name="l00362"></a>00362       { <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[x2 + regionTimesWidth] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[lastX + yTimesWidth]; }
<a name="l00363"></a>00363     }
<a name="l00364"></a>00364     
<a name="l00365"></a>00365   } <span class="comment">//region</span>
<a name="l00366"></a>00366   <span class="comment">//---------------------------------</span>
<a name="l00367"></a>00367   <span class="comment">//blur the region row buffers</span>
<a name="l00368"></a>00368 
<a name="l00369"></a>00369   <span class="comment">//for each region</span>
<a name="l00370"></a>00370   <span class="keywordflow">for</span>(region=0; region&lt;regionCount; region++)
<a name="l00371"></a>00371   {
<a name="l00372"></a>00372     regionTimesWidth = region*width;
<a name="l00373"></a>00373     
<a name="l00374"></a>00374     <span class="comment">//forward</span>
<a name="l00375"></a>00375     <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[0] = <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[ 0 + regionTimesWidth ];
<a name="l00376"></a>00376     <span class="keywordflow">for</span>(x=1; x&lt;width; x++)
<a name="l00377"></a>00377     {
<a name="l00378"></a>00378       <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[x] = <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a>*<a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[ x + regionTimesWidth ] +
<a name="l00379"></a>00379       ( <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a>*<a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[ QMAX(x-1, 0) ] +
<a name="l00380"></a>00380         <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> * <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[ QMAX(x-2, 0) ] +
<a name="l00381"></a>00381         <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a> * <a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[ QMAX(x-3, 0) ]) / <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>;    
<a name="l00382"></a>00382     }
<a name="l00383"></a>00383     
<a name="l00384"></a>00384     <span class="comment">//reverse</span>
<a name="l00385"></a>00385     <span class="keywordflow">for</span>(x=width-1; x&gt;=0; x--)
<a name="l00386"></a>00386     {
<a name="l00387"></a>00387       <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[ x + regionTimesWidth ] = <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a>*<a class="code" href="blur_8cpp.html#89c34a2d7f884fa813593747fd9e4bdb">rowBuffer</a>[ x ] +
<a name="l00388"></a>00388       ( <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a> * <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[ QMIN(x+1, width-1) + regionTimesWidth ] +
<a name="l00389"></a>00389         <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> * <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[ QMIN(x+2, width-1) + regionTimesWidth ] +
<a name="l00390"></a>00390         <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a> * <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[ QMIN(x+3, width-1) + regionTimesWidth ]) / <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>;    
<a name="l00391"></a>00391     }
<a name="l00392"></a>00392   }
<a name="l00393"></a>00393   <span class="comment">//---------------------------------</span>
<a name="l00394"></a>00394   <span class="comment">//copy data from the region row buffers back to the</span>
<a name="l00395"></a>00395   <span class="comment">//buffer. for each pixel we choose the correct region</span>
<a name="l00396"></a>00396   <span class="comment">//row buffer basedon the original regionidentity of hte pixel</span>
<a name="l00397"></a>00397   <span class="keywordflow">for</span>(x=0; x&lt;width; x++)
<a name="l00398"></a>00398   {
<a name="l00399"></a>00399     <span class="keywordtype">int</span> ri = <a class="code" href="blur_8cpp.html#66793d4213f628c343f1b318e1026b73">regionIndex</a>(x,y);
<a name="l00400"></a>00400     <span class="keywordtype">int</span> region = <a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">regionMap</a>[ri];
<a name="l00401"></a>00401     <span class="keywordtype">float</span> bufferVal = <a class="code" href="blur_8cpp.html#cf497bcaec224469d3e0906be03a438b">regionRowBuffer</a>[ x + region*width ];
<a name="l00402"></a>00402     <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + yTimesWidth] = bufferVal;
<a name="l00403"></a>00403     
<a name="l00404"></a>00404 <span class="comment">//    buffer[x + yTimesWidth] = regionRowBuffer[x + regionMap[regionIndex(x,y)]*width]; </span>
<a name="l00405"></a>00405   }
<a name="l00406"></a>00406   <span class="comment">//---------------------------------</span>
<a name="l00407"></a>00407 }
<a name="l00408"></a>00408 <span class="comment">//==============================================</span>
<a name="l00409"></a><a class="code" href="blur_8cpp.html#7cf2d364e9c5bd5c66fee296c5b85784">00409</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#7cf2d364e9c5bd5c66fee296c5b85784">blurColumn</a>( <span class="keywordtype">int</span> column )
<a name="l00410"></a>00410 {
<a name="l00411"></a>00411   <span class="keywordtype">int</span> i;
<a name="l00412"></a>00412 
<a name="l00413"></a>00413   <span class="comment">//forward</span>
<a name="l00414"></a>00414   <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[0] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ column + 0*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a> ];
<a name="l00415"></a>00415   <span class="keywordflow">for</span>(i=1; i&lt;<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>; i++)
<a name="l00416"></a>00416   {
<a name="l00417"></a>00417      <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[i] = <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a>*<a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ column + i*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a> ] +
<a name="l00418"></a>00418      ( <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a> * <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[ QMAX(i-1, 0) ] +
<a name="l00419"></a>00419        <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> * <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[ QMAX(i-2, 0) ] +
<a name="l00420"></a>00420        <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a> * <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[ QMAX(i-3, 0) ]) / <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>;    
<a name="l00421"></a>00421   }
<a name="l00422"></a>00422   
<a name="l00423"></a>00423   <span class="comment">//reverse</span>
<a name="l00424"></a>00424   <span class="keywordflow">for</span>(i=height-1; i&gt;=0; i--)
<a name="l00425"></a>00425   {
<a name="l00426"></a>00426      <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ column + i*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a> ] = <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a>*<a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[ i ] +
<a name="l00427"></a>00427      ( <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a> * <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ column + QMIN(i+1, height-1)*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a> ] +
<a name="l00428"></a>00428        <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> * <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ column + QMIN(i+2, height-1)*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a> ] +
<a name="l00429"></a>00429        <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a> * <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[ column + QMIN(i+3, height-1)*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a> ]) / <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>;        
<a name="l00430"></a>00430   }
<a name="l00431"></a>00431   
<a name="l00432"></a>00432 }
<a name="l00433"></a>00433 <span class="comment">//==============================================</span>
<a name="l00434"></a><a class="code" href="blur_8cpp.html#5b070fddaaa81dc81a431ce9741a5fc8">00434</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#5b070fddaaa81dc81a431ce9741a5fc8">blurRegionsInCol</a>( <span class="keywordtype">int</span> x )
<a name="l00435"></a>00435 {
<a name="l00436"></a>00436   <span class="comment">//---------------------------------</span>
<a name="l00437"></a>00437   <span class="comment">//populate region col buffer. a col has been allocated for </span>
<a name="l00438"></a>00438   <span class="comment">//each region. Pixels between regions</span>
<a name="l00439"></a>00439   <span class="comment">//take the closest pixel value in that col from that region</span>
<a name="l00440"></a>00440 <span class="comment">//  int yTimesWidth = y*width;</span>
<a name="l00441"></a>00441   <span class="keywordtype">int</span> regionTimesHeight;
<a name="l00442"></a>00442   <span class="keywordtype">int</span> region,y,y2;
<a name="l00443"></a>00443   
<a name="l00444"></a>00444   <span class="comment">//for each region</span>
<a name="l00445"></a>00445   <span class="keywordflow">for</span>(region=0; region&lt;<a class="code" href="blur_8cpp.html#99011823ef56f33be976af30f313f132">regionCount</a>; region++)
<a name="l00446"></a>00446   {
<a name="l00447"></a>00447     regionTimesHeight = region*<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>;
<a name="l00448"></a>00448     <span class="keywordtype">int</span> lastY = -1;
<a name="l00449"></a>00449     <span class="keywordflow">for</span>(y=0; y&lt;height; y++)
<a name="l00450"></a>00450     {
<a name="l00451"></a>00451       <span class="comment">//if pixel belongs to this region then update lastY index and copy value over</span>
<a name="l00452"></a>00452       <span class="comment">//if lastY is more than one pixel away than fill inbetween region</span>
<a name="l00453"></a>00453       <span class="keywordflow">if</span>( region == <a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">regionMap</a>[<a class="code" href="blur_8cpp.html#66793d4213f628c343f1b318e1026b73">regionIndex</a>(x, y)] )
<a name="l00454"></a>00454       {
<a name="l00455"></a>00455         <span class="comment">//fill empty region preceeding this region blob</span>
<a name="l00456"></a>00456         <span class="keywordflow">if</span>( lastY &lt; y-1)
<a name="l00457"></a>00457         {
<a name="l00458"></a>00458           <span class="comment">//no preceeding region, spread left!</span>
<a name="l00459"></a>00459           <span class="keywordflow">if</span>(lastY == -1)
<a name="l00460"></a>00460           {
<a name="l00461"></a>00461             <span class="keywordflow">for</span>(y2=0; y2&lt;y; y2++) { <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[y2 + regionTimesHeight] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + y*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>]; }
<a name="l00462"></a>00462           }
<a name="l00463"></a>00463           <span class="comment">//else spread from both left and right of empty stretch</span>
<a name="l00464"></a>00464           <span class="keywordflow">else</span>
<a name="l00465"></a>00465           {
<a name="l00466"></a>00466             <span class="keywordtype">int</span> yMid = lastY + ((y-1) - lastY)/2;
<a name="l00467"></a>00467             
<a name="l00468"></a>00468             <span class="keywordflow">for</span>(y2=lastY+1; y2&lt;=yMid; y2++)
<a name="l00469"></a>00469             { <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[y2 + regionTimesHeight] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + lastY*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>]; }
<a name="l00470"></a>00470             
<a name="l00471"></a>00471             <span class="keywordflow">for</span>(y2=yMid+1; y2&lt;y; y2++)
<a name="l00472"></a>00472             { <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[y2 + regionTimesHeight] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + y*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>]; }
<a name="l00473"></a>00473           }
<a name="l00474"></a>00474         }
<a name="l00475"></a>00475         
<a name="l00476"></a>00476         <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[y + regionTimesHeight] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + y*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>];
<a name="l00477"></a>00477         lastY = y;
<a name="l00478"></a>00478       } 
<a name="l00479"></a>00479     } <span class="comment">//y</span>
<a name="l00480"></a>00480     
<a name="l00481"></a>00481     <span class="comment">//if last stretch is empty, fill right</span>
<a name="l00482"></a>00482     <span class="keywordflow">if</span>( region != <a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">regionMap</a>[<a class="code" href="blur_8cpp.html#66793d4213f628c343f1b318e1026b73">regionIndex</a>(x, height-1)] )
<a name="l00483"></a>00483     {
<a name="l00484"></a>00484       <span class="keywordflow">for</span>(y2=lastY+1; y2&lt;height; y2++)
<a name="l00485"></a>00485       { <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[y2 + regionTimesHeight] = <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + lastY*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>]; }
<a name="l00486"></a>00486     }
<a name="l00487"></a>00487     
<a name="l00488"></a>00488   } <span class="comment">//region</span>
<a name="l00489"></a>00489   <span class="comment">//---------------------------------</span>
<a name="l00490"></a>00490   <span class="comment">//blur the region col buffers</span>
<a name="l00491"></a>00491   
<a name="l00492"></a>00492   <span class="comment">//for each region</span>
<a name="l00493"></a>00493   <span class="keywordflow">for</span>(region=0; region&lt;regionCount; region++)
<a name="l00494"></a>00494   {
<a name="l00495"></a>00495     regionTimesHeight = region*<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>;
<a name="l00496"></a>00496     
<a name="l00497"></a>00497     <span class="comment">//forward</span>
<a name="l00498"></a>00498     <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[0] = <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[ 0 + regionTimesHeight ];
<a name="l00499"></a>00499     <span class="keywordflow">for</span>(y=1; y&lt;height; y++)
<a name="l00500"></a>00500     {
<a name="l00501"></a>00501       <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[y] = <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a>*<a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[ y + regionTimesHeight ] +
<a name="l00502"></a>00502       ( <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a> * <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[ QMAX(y-1, 0) ] +
<a name="l00503"></a>00503         <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> * <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[ QMAX(y-2, 0) ] +
<a name="l00504"></a>00504         <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a> * <a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[ QMAX(y-3, 0) ]) / <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>;    
<a name="l00505"></a>00505     }
<a name="l00506"></a>00506     
<a name="l00507"></a>00507     <span class="comment">//reverse</span>
<a name="l00508"></a>00508     <span class="keywordflow">for</span>(y=height-1; y&gt;=0; y--)
<a name="l00509"></a>00509     {
<a name="l00510"></a>00510       <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[ y + regionTimesHeight ] = <a class="code" href="blur_8cpp.html#8188fea1f6709096fe21a3ee084d00d0">B</a>*<a class="code" href="blur_8cpp.html#aec903fd4cc73f7ef5918cbe5ecfc1c1">colBuffer</a>[ y ] +
<a name="l00511"></a>00511       ( <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a> * <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[ QMIN(y+1, height-1) + regionTimesHeight ] +
<a name="l00512"></a>00512         <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> * <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[ QMIN(y+2, height-1) + regionTimesHeight ] +
<a name="l00513"></a>00513         <a class="code" href="blur_8cpp.html#9c6487b4db396a5910c351e126a2a3a6">b3</a> * <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[ QMIN(y+3, height-1) + regionTimesHeight ]) / <a class="code" href="blur_8cpp.html#ae36fc890ea9532f56273eb4ff3d8fc3">b0</a>;    
<a name="l00514"></a>00514     }
<a name="l00515"></a>00515   }
<a name="l00516"></a>00516   <span class="comment">//---------------------------------</span>
<a name="l00517"></a>00517   <span class="comment">//copy data from the region row buffers back to the</span>
<a name="l00518"></a>00518   <span class="comment">//buffer. for each pixel we choose the correct region</span>
<a name="l00519"></a>00519   <span class="comment">//row buffer basedon the original regionidentity of hte pixel</span>
<a name="l00520"></a>00520   <span class="keywordflow">for</span>(y=0; y&lt;<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>; y++)
<a name="l00521"></a>00521   {
<a name="l00522"></a>00522     <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[x + y*<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>] = <a class="code" href="blur_8cpp.html#2cce1ac8bdf75e631a3cc099d7444c7a">regionColBuffer</a>[y + <a class="code" href="blur_8cpp.html#9752978c7e4bd6f4fbdedbce54b5776d">regionMap</a>[<a class="code" href="blur_8cpp.html#66793d4213f628c343f1b318e1026b73">regionIndex</a>(x,y)]*height]; 
<a name="l00523"></a>00523   }
<a name="l00524"></a>00524   <span class="comment">//---------------------------------</span>
<a name="l00525"></a>00525 }
<a name="l00526"></a>00526 <span class="comment">//==============================================</span>
<a name="l00527"></a><a class="code" href="blur_8cpp.html#7fbca6e5494a3008dd90ec0d6103bba0">00527</a> <span class="keywordtype">void</span> <a class="code" href="blur_8cpp.html#7fbca6e5494a3008dd90ec0d6103bba0">resetImageData</a>( QImage &amp;image, <span class="keywordtype">int</span> channel, <span class="keywordtype">bool</span> blurEdges)
<a name="l00528"></a>00528 {
<a name="l00529"></a>00529   <span class="comment">//iterate over each selected scanline </span>
<a name="l00530"></a>00530   <span class="keywordtype">int</span> x, y;
<a name="l00531"></a>00531   QRgb *rgb;
<a name="l00532"></a>00532   uchar* imageScanline = NULL;
<a name="l00533"></a>00533   <span class="keywordflow">for</span>( y=0; y&lt;image.height(); y++)
<a name="l00534"></a>00534   {   
<a name="l00535"></a>00535     imageScanline = image.scanLine(y);
<a name="l00536"></a>00536     <span class="keywordflow">for</span>( x=0; x&lt;image.width(); x++)
<a name="l00537"></a>00537     {
<a name="l00538"></a>00538       <span class="comment">//get handle on rgb value in image</span>
<a name="l00539"></a>00539       rgb = ((QRgb*)imageScanline+x);
<a name="l00540"></a>00540       
<a name="l00541"></a>00541       <span class="comment">//compute index where float value is stored in buffer</span>
<a name="l00542"></a>00542       <span class="keywordtype">int</span> index = x + y*image.width();
<a name="l00543"></a>00543 
<a name="l00544"></a>00544       <span class="comment">//convert blured value to 0-255 range</span>
<a name="l00545"></a>00545       <span class="keywordtype">int</span> blurredColor = QMAX( QMIN( ((<span class="keywordtype">int</span>) (255*<a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>[index])), 255 ), 0 );
<a name="l00546"></a>00546       
<a name="l00547"></a>00547       <span class="comment">//blur the entire thing!</span>
<a name="l00548"></a>00548       <span class="keywordtype">float</span> alpha;
<a name="l00549"></a>00549       <span class="keywordflow">if</span>( <a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a> == NULL)
<a name="l00550"></a>00550         alpha = 1.0f;
<a name="l00551"></a>00551       <span class="keywordflow">else</span>
<a name="l00552"></a>00552       {
<a name="l00553"></a>00553         alpha = <a class="code" href="blur_8cpp.html#374c077a12cb98c0a52723b460079ae9">edgeValue</a>( x, y ); 
<a name="l00554"></a>00554         <span class="keywordflow">if</span>(!blurEdges)
<a name="l00555"></a>00555           alpha = 1.0f - alpha;
<a name="l00556"></a>00556       }
<a name="l00557"></a>00557 
<a name="l00558"></a>00558       <span class="comment">//convert and store correct channel in buffer</span>
<a name="l00559"></a>00559       <span class="keywordflow">if</span>( channel == 0 )
<a name="l00560"></a>00560         *rgb = qRgb( (<span class="keywordtype">int</span>) (alpha*blurredColor + (1-alpha)*qRed(*rgb)),
<a name="l00561"></a>00561                      qGreen(*rgb), qBlue(*rgb) );
<a name="l00562"></a>00562       <span class="keywordflow">else</span> <span class="keywordflow">if</span>( channel == 1 )
<a name="l00563"></a>00563         *rgb = qRgb( qRed(*rgb), 
<a name="l00564"></a>00564                      (<span class="keywordtype">int</span>) (alpha*blurredColor + (1-alpha)*qGreen(*rgb)),
<a name="l00565"></a>00565                      qBlue(*rgb) );
<a name="l00566"></a>00566       <span class="keywordflow">else</span>
<a name="l00567"></a>00567         *rgb = qRgb( qRed(*rgb), qGreen(*rgb), 
<a name="l00568"></a>00568                      (<span class="keywordtype">int</span>) (alpha*blurredColor + (1-alpha)*qBlue(*rgb)) );
<a name="l00569"></a>00569     } <span class="comment">//x</span>
<a name="l00570"></a>00570   } <span class="comment">//y</span>
<a name="l00571"></a>00571 }
<a name="l00572"></a>00572 <span class="comment">//==============================================</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 23 02:34:25 2009 for AlbumShaper by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>