Sophie

Sophie

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

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: sharpen.h File Reference</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>
</div>
<div class="contents">
<h1>sharpen.h File Reference</h1>
<p>
<div class="dynheader">
This graph shows which files directly or indirectly include this file:</div>
<div class="dynsection">
</div>

<p>
<a href="sharpen_8h_source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="sharpen_8h.html#92c3a61ec589ffe5d0aa1811add7a22e">sharpenImage</a> (QImage &amp;image, float sigma, QPoint offset, QSize fullImageRes, QImage *<a class="el" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>, bool blurEdges)</td></tr>

</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="92c3a61ec589ffe5d0aa1811add7a22e"></a><!-- doxytag: member="sharpen.h::sharpenImage" ref="92c3a61ec589ffe5d0aa1811add7a22e" args="(QImage &amp;image, float sigma, QPoint offset, QSize fullImageRes, QImage *edgeImage, bool blurEdges)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void sharpenImage           </td>
          <td>(</td>
          <td class="paramtype">QImage &amp;&nbsp;</td>
          <td class="paramname"> <em>image</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&nbsp;</td>
          <td class="paramname"> <em>sigma</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">QPoint&nbsp;</td>
          <td class="paramname"> <em>offset</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">QSize&nbsp;</td>
          <td class="paramname"> <em>fullImageRes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">QImage *&nbsp;</td>
          <td class="paramname"> <em>edgeImage</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>blurEdges</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>

<p>Definition at line <a class="el" href="sharpen_8cpp_source.html#l00092">92</a> of file <a class="el" href="sharpen_8cpp_source.html">sharpen.cpp</a>.</p>

<p>References <a class="el" href="blur_8cpp_source.html#l00078">b1</a>, <a class="el" href="blur_8cpp_source.html#l00078">b2</a>, <a class="el" href="blur_8cpp_source.html#l00094">blurImage()</a>, <a class="el" href="imageTools_8cpp_source.html#l00264">HSVtoRGB()</a>, and <a class="el" href="imageTools_8cpp_source.html#l00231">RGBtoHSV()</a>.</p>

<p>Referenced by <a class="el" href="grainEditor_8cpp_source.html#l00262">GrainEditor::adjustImage()</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00095"></a>00095 {
<a name="l00096"></a>00096   <span class="comment">//construct blur copy</span>
<a name="l00097"></a>00097   QImage blurredImage = image.copy();
<a name="l00098"></a>00098   <a class="code" href="blur_8cpp.html#e7be57816a66918a26e567655f4b8e1c">blurImage</a>( blurredImage, sigma );
<a name="l00099"></a>00099   
<a name="l00100"></a>00100   <span class="comment">//iterate over each pixel and adjust luminance value</span>
<a name="l00101"></a>00101   <span class="keywordtype">int</span> x, y;
<a name="l00102"></a>00102   QRgb *origRgb, *blurredRgb, *edgeRgb;
<a name="l00103"></a>00103   uchar *origScanline;
<a name="l00104"></a>00104   uchar *blurredScanline;
<a name="l00105"></a>00105   uchar *edgesScanline = NULL;
<a name="l00106"></a>00106   
<a name="l00107"></a>00107   <span class="keywordflow">for</span>(y=0; y&lt;image.height(); y++)
<a name="l00108"></a>00108   {
<a name="l00109"></a>00109     origScanline = image.scanLine(y);
<a name="l00110"></a>00110     blurredScanline = blurredImage.scanLine(y);
<a name="l00111"></a>00111     <span class="keywordflow">if</span>( <a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a> != NULL )
<a name="l00112"></a>00112     {
<a name="l00113"></a>00113       <span class="keywordtype">int</span> edgeY = ((<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;height()-1) * (y+offset.y())) / (fullImageRes.height()-1);
<a name="l00114"></a>00114       edgesScanline = <a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;scanLine(edgeY);
<a name="l00115"></a>00115     }
<a name="l00116"></a>00116     
<a name="l00117"></a>00117     <span class="keywordflow">for</span>(x=0; x&lt;image.width(); x++)
<a name="l00118"></a>00118     {
<a name="l00119"></a>00119       <span class="comment">//get rgb triplets</span>
<a name="l00120"></a>00120       origRgb = ((QRgb*)origScanline+x);
<a name="l00121"></a>00121       <span class="keywordtype">double</span> r1 = ((double)qRed(*origRgb)   )/255.0;
<a name="l00122"></a>00122       <span class="keywordtype">double</span> g1 = ((double)qGreen(*origRgb) )/255.0;
<a name="l00123"></a>00123       <span class="keywordtype">double</span> <a class="code" href="blur_8cpp.html#0a909289ec9fbfaa70c0e112ec9e3b15">b1</a> = ((double)qBlue(*origRgb)  )/255.0;
<a name="l00124"></a>00124       
<a name="l00125"></a>00125       blurredRgb = ((QRgb*)blurredScanline+x);
<a name="l00126"></a>00126       <span class="keywordtype">double</span> r2 = ((double)qRed(*blurredRgb)   )/255.0;
<a name="l00127"></a>00127       <span class="keywordtype">double</span> g2 = ((double)qGreen(*blurredRgb) )/255.0;
<a name="l00128"></a>00128       <span class="keywordtype">double</span> <a class="code" href="blur_8cpp.html#746bcb222044619e5a9b335d242a2a92">b2</a> = ((double)qBlue(*blurredRgb)  )/255.0;
<a name="l00129"></a>00129 
<a name="l00130"></a>00130       <span class="comment">//sharpen the entire thing!</span>
<a name="l00131"></a>00131       <span class="keywordtype">float</span> alpha;
<a name="l00132"></a>00132       <span class="keywordflow">if</span>( <a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a> == NULL)
<a name="l00133"></a>00133         alpha = 1.0f;
<a name="l00134"></a>00134       <span class="keywordflow">else</span>
<a name="l00135"></a>00135       {
<a name="l00136"></a>00136         <span class="keywordtype">int</span> edgeX = ((<a class="code" href="blur_8cpp.html#8bb23dbf5a4b8bb7e3e90e0567712bdd">edgeImage</a>-&gt;width()-1) * (x+offset.x())) / (fullImageRes.width()-1);
<a name="l00137"></a>00137         edgeRgb = ((QRgb*)edgesScanline+edgeX);
<a name="l00138"></a>00138         
<a name="l00139"></a>00139         alpha = ((float) qRed( *edgeRgb )) / 255.0f;
<a name="l00140"></a>00140         
<a name="l00141"></a>00141         <span class="comment">//blur regions, not edges</span>
<a name="l00142"></a>00142         <span class="keywordflow">if</span>(!blurEdges)
<a name="l00143"></a>00143           alpha = 1.0f - alpha;
<a name="l00144"></a>00144       }
<a name="l00145"></a>00145       
<a name="l00146"></a>00146       <span class="comment">//convert to hsv</span>
<a name="l00147"></a>00147       <span class="keywordtype">double</span> h1,s1,v1;
<a name="l00148"></a>00148       <a class="code" href="imageTools_8cpp.html#7769c25727d6caedf20321d238b3828d" title="Convert a RGB color triplet to HSV.">RGBtoHSV</a>(r1,g1,b1,&amp;h1,&amp;s1,&amp;v1);
<a name="l00149"></a>00149 
<a name="l00150"></a>00150       <span class="keywordtype">double</span> h2,s2,v2;
<a name="l00151"></a>00151       <a class="code" href="imageTools_8cpp.html#7769c25727d6caedf20321d238b3828d" title="Convert a RGB color triplet to HSV.">RGBtoHSV</a>(r2,g2,b2,&amp;h2,&amp;s2,&amp;v2);
<a name="l00152"></a>00152       
<a name="l00153"></a>00153       <span class="comment">//reset v</span>
<a name="l00154"></a>00154       v1  = (alpha * QMIN( QMAX(2*v1 - v2, 0), 1.0 )) + (1-alpha)*v1;
<a name="l00155"></a>00155       
<a name="l00156"></a>00156       <span class="comment">//convert adjusted color back to rgb colorspace and clamp</span>
<a name="l00157"></a>00157       <a class="code" href="imageTools_8cpp.html#a4ea508b635b1a7648bb5834132d4681" title="Convert a HSV color triplet to RGB.">HSVtoRGB</a>( &amp;r1,&amp;g1,&amp;b1, h1,s1,v1);         
<a name="l00158"></a>00158       <span class="keywordtype">int</span> rp = (int) QMIN( QMAX((r1*255), 0), 255 );
<a name="l00159"></a>00159       <span class="keywordtype">int</span> gp = (int) QMIN( QMAX((g1*255), 0), 255 );
<a name="l00160"></a>00160       <span class="keywordtype">int</span> bp = (int) QMIN( QMAX((b1*255), 0), 255 );
<a name="l00161"></a>00161       
<a name="l00162"></a>00162       <span class="comment">//set adjusted color value</span>
<a name="l00163"></a>00163       *origRgb = qRgb(rp,gp,bp);
<a name="l00164"></a>00164     } <span class="comment">//x</span>
<a name="l00165"></a>00165   } <span class="comment">//y</span>
<a name="l00166"></a>00166 
<a name="l00167"></a>00167 }
</pre></div>
<p>

</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 23 02:34:32 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>