<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tanner Helland (dot) Com&#187; Graphics Code</title>
	<atom:link href="http://www.tannerhelland.com/category/vb6/graphics-vb6/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tannerhelland.com</link>
	<description>Home of the award-winning author, VG composer, and programmer</description>
	<lastBuildDate>Thu, 11 Mar 2010 05:11:59 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sepia / &#8220;Antique&#8221; Image Effect (in VB6)</title>
		<link>http://www.tannerhelland.com/vb6/sepia-antique-effect-vb6/</link>
		<comments>http://www.tannerhelland.com/vb6/sepia-antique-effect-vb6/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 02:23:31 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[graphics programming]]></category>
		<category><![CDATA[Photoshop]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=1138</guid>
		<description><![CDATA[I'm guessing you've seen this style of image before - a sort of pseudo-antique filter than can make any image look like it was taken with a very old camera.  There are many ways to programmatically generate images like this, and in this article I've put together one that does more than just make the image look "brown."  This filter involves several steps (fading, multiplicative brightness, and gamma correction, among others) and results in a conversion that not only adds a sepia coloring, but also gives an image a histogram more in keeping with older photos.]]></description>
			<content:encoded><![CDATA[<div class="captionfull">
<div id="attachment_1141" class="wp-caption aligncenter" style="width: 480px"><img class="size-full wp-image-1141" title="Sepia_Big_Bang_Theory" src="http://www.tannerhelland.com/wp-content/uploads/2009/08/Sepia_Big_Bang_Theory.jpg" alt="&quot;Antiquified&quot; version of a BBT promo photo" width="470" height="353" /><p class="wp-caption-text">&quot;Antiquified&quot; version of a BBT promo photo</p></div>
</div>
<p>I&#8217;m guessing you&#8217;ve seen this style of image before &#8211; a sort of pseudo-antique filter than can make any photo look like it was taken with a very old camera (or even a <a  href="http://en.wikipedia.org/wiki/Daguerreotype" target="_blank">daguerreotype</a> &#8211; how&#8217;s that for a cool word?).  There are many ways to programmatically generate images like this, and in this article I&#8217;ve put together one that does more than just make the image look &#8220;brown.&#8221;  This filter involves several steps (fading, multiplicative brightness, and gamma correction, among others) and results in a conversion that not only adds a sepia coloring, but also gives an image a histogram more in keeping with older photos.</p>
<p>As with all graphics code on this site, the algorithm is fast enough to be applied in real-time.  Full source code and a sample executable are provided.</p>
<p style="text-align: center;"><strong><a  href="http://www.tannerhelland.com/code/Sepia.zip">Download Sepia/Antique Image Filter Code (186 kb)</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/sepia-antique-effect-vb6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nature-Inspired Image Filters (in VB6)</title>
		<link>http://www.tannerhelland.com/vb6/nature-inspired-image-effects-vb6/</link>
		<comments>http://www.tannerhelland.com/vb6/nature-inspired-image-effects-vb6/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 00:22:21 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[graphics programming]]></category>
		<category><![CDATA[Photoshop]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=1118</guid>
		<description><![CDATA[Today's article brings a collection of random image effects that can be quickly (and programmatically) generated. In an attempt to give the project some coherency, I've named each effect after something "nature-themed" so as to help distinguish them.  As always, full source code and a sample .exe is provided...]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s article brings a collection of random image effects that can be quickly (and programmatically) generated.  In an attempt to give the project some coherency, I&#8217;ve named each effect after something &#8220;nature-themed&#8221; so as to help distinguish them.</p>
<p>As always, full source code and a sample .exe is provided in the download link below.</p>
<p style="text-align: center;"><strong><a  href="http://www.tannerhelland.com/code/NatureFilters.zip">Download Nature-Inspired Image Filter Code (318 kb)</a></strong></p>
<p>Below, you can see how each filter looks on a promotional image from <a  href="http://en.wikipedia.org/wiki/Final_Fantasy_Versus_XIII" target="_blank"><em>Final Fantasy Versus XIII</em></a>.</p>
<p>Original:</p>
<div class="captionfull">
<div id="attachment_1115" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1115" title="FFVS13" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13-600x337.jpg" alt="Final Fantasy Versus XIII" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII</p></div>
</div>
<p>Atmosphere:</p>
<div class="captionfull">
<div id="attachment_1116" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1116" title="FFVS13_Atmosphere" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13_Atmosphere-600x337.jpg" alt="Final Fantasy Versus XIII - Atmosphere Effect" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII - Atmosphere Effect</p></div>
</div>
<p>Burn:</p>
<div class="captionfull">
<div id="attachment_1117" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1117" title="FFVS13_Burn" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13_Burn-600x337.jpg" alt="Final Fantasy Versus XIII - Burn Effect" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII - Burn Effect</p></div>
</div>
<p>Fog:</p>
<div class="captionfull">
<div id="attachment_1119" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1119" title="FFVS13_Fog" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13_Fog-600x337.jpg" alt="Final Fantasy Versus XIII - Fog Effect" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII - Fog Effect</p></div>
</div>
<p>Freeze:</p>
<div class="captionfull">
<div id="attachment_1120" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1120" title="FFVS13_Freeze" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13_Freeze-600x337.jpg" alt="Final Fantasy Versus XIII - Freeze Effect" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII - Freeze Effect</p></div>
</div>
<p>Lava:</p>
<div class="captionfull">
<div id="attachment_1121" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1121" title="FFVS13_Lava" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13_Lava-600x337.jpg" alt="Final Fantasy Versus XIII - Lava Effect" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII - Lava Effect</p></div>
</div>
<p>Ocean:</p>
<div class="captionfull">
<div id="attachment_1122" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1122" title="FFVS13_Ocean" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13_Ocean-600x337.jpg" alt="Final Fantasy Versus XIII - Ocean Effect" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII - Ocean Effect</p></div>
</div>
<p>Rainbow:</p>
<div class="captionfull">
<div id="attachment_1123" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1123" title="FFVS13_Rainbow" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13_Rainbow-600x337.jpg" alt="Final Fantasy Versus XIII - Rainbow Effect" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII - Rainbow Effect</p></div>
</div>
<p>Metal:</p>
<div class="captionfull">
<div id="attachment_1124" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1124" title="FFVS13_Metal" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13_Steel-600x337.jpg" alt="Final Fantasy Versus XIII - Metal Effect" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII - Metal Effect</p></div>
</div>
<p>Underwater:</p>
<div class="captionfull">
<div id="attachment_1125" class="wp-caption aligncenter" style="width: 610px"><img class="size-large wp-image-1125" title="FFVS13_Water" src="http://www.tannerhelland.com/wp-content/uploads/2009/07/FFVS13_Water-600x337.jpg" alt="Final Fantasy Versus XIII - Underwater Effect" width="600" height="337" /><p class="wp-caption-text">Final Fantasy Versus XIII - Underwater Effect</p></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/nature-inspired-image-effects-vb6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Image Filter Engine (in VB6)</title>
		<link>http://www.tannerhelland.com/vb6/custom-image-filters-vb6/</link>
		<comments>http://www.tannerhelland.com/vb6/custom-image-filters-vb6/#comments</comments>
		<pubDate>Tue, 05 May 2009 06:00:48 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[graphics programming]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[Photoshop Code]]></category>
		<category><![CDATA[photoshop programming]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=982</guid>
		<description><![CDATA[The ability to create custom filters is a mainstay of any quality graphics application.  A robust matrix-based filter engine can be used to create tens - even hundreds - of unique image effects by simply manipulating the matrices that get passed into the engine.  In this project, I've provided a 5x5 custom filter engine with support for both scaling and biasing.  This is identical to the custom filter engine provided by Photoshop, and mine is even slightly faster (at least for the screen-sized images I've been testing)...]]></description>
			<content:encoded><![CDATA[<p>The ability to create custom filters is a mainstay of any quality graphics application.  A robust matrix-based filter engine can generate hundreds of unique effects by simply adjusting the matrices that get passed into the engine.</p>
<p>In this project, I&#8217;ve provided a 5&#215;5 custom filter engine with support for scaling/weighting and biasing/offsetting.   This is identical to the custom filter engine provided by Photoshop, and mine is even slightly faster (at least for the screen-sized images I&#8217;ve been testing).</p>
<p>Besides being fast, the engine is also smart.   It is clever enough to estimate edge pixels correctly &#8211; even for scaled/weighted filters &#8211; and it will automatically validate all input values to make sure they&#8217;re appropriate.</p>
<p>Finally, I&#8217;ve included 7 sample filters for you to play with, including blur, sharpen, emboss, engrave, grease, unfocus, and vibrate.</p>
<p style="text-align: center;"><strong><a  href="http://www.tannerhelland.com/code/Custom_Filters.zip">Download Custom Filter Engine Code (91 kb)</a></strong></p>
<p>Below, you can see how each filter looks on a promotional image from <a  href="http://abc.go.com/primetime/castle/index?pn=index" target="_blank"><em>Castle</em></a>, an excellent new NYPD dramedy on ABC.</p>
<p>Original:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-974" title="castle" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/castle.jpg" alt="castle" width="400" height="300" /></div>
<p>Blur:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-975" title="castle_blur" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/castle_blur.jpg" alt="castle_blur" width="400" height="300" /></div>
<p>Sharpen:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-976" title="castle_sharpen" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/castle_sharpen.jpg" alt="castle_sharpen" width="400" height="300" /></div>
<p>Emboss:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-977" title="castle_emboss" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/castle_emboss.jpg" alt="castle_emboss" width="400" height="300" /></div>
<p>Engrave:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-978" title="castle_engrave" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/castle_engrave.jpg" alt="castle_engrave" width="400" height="300" /></div>
<p>Grease:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-979" title="castle_grease" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/castle_grease.jpg" alt="castle_grease" width="400" height="300" /></div>
<p>Unfocus:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-980" title="castle_unfocus" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/castle_unfocus.jpg" alt="castle_unfocus" width="400" height="300" /></div>
<p>Vibrate:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-981" title="castle_vibrate" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/castle_vibrate.jpg" alt="castle_vibrate" width="400" height="300" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/custom-image-filters-vb6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Edge Detection (in VB6)</title>
		<link>http://www.tannerhelland.com/vb6/edge-detection-vb6/</link>
		<comments>http://www.tannerhelland.com/vb6/edge-detection-vb6/#comments</comments>
		<pubDate>Sat, 02 May 2009 04:09:13 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[graphics programming]]></category>
		<category><![CDATA[Photoshop]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=952</guid>
		<description><![CDATA[Edge detection (also called "boundary detection") is a fundamental problem in image processing.  The ability to accurately detect visible "edges" in an image has many applications - from missile targeting to OCR to cool Photoshop effects.  In this project, I've compiled 6 well-known edge detection algorithms (along with two of my own for fun).  Full VB6 source code is provided, as well as an .exe for those just interested in the effects alone...]]></description>
			<content:encoded><![CDATA[<p>Edge detection (also called &#8220;boundary detection&#8221;) is a fundamental problem in image processing.  The ability to accurately detect visible &#8220;edges&#8221; in an image has many applications &#8211; ranging from missile targeting to OCR to cool Photoshop effects.  In this project I&#8217;ve compiled 6 well-known edge detection algorithms (along with two of my own for fun).  Full VB6 source code is provided, along with an .exe for those interested in just the effect.</p>
<p style="text-align: center;"><strong><a  href="http://www.tannerhelland.com/code/Edge_Detection.zip">Download Edge Detection Code (86 kb)</a></strong></p>
<p>For those who have never used edge detection algorithms before, here&#8217;s an idea of the output:</p>
<p>Original image:</p>
<p>
<div class="captionfull"><img class="aligncenter size-full wp-image-953" title="Lost_TV" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/wa_lost-cast_02.jpg" alt="Lost_TV" width="400" height="300" /></div>
</p>
<p>Prewitt method (horizontal):</p>
<p>
<div class="captionfull"><img class="aligncenter size-full wp-image-954" title="lost_1" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/lost_1.jpg" alt="lost_1" width="400" height="300" /></div>
</p>
<p>Prewitt method (vertical):</p>
<p>
<div class="captionfull"><img class="aligncenter size-full wp-image-955" title="lost_2" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/lost_2.jpg" alt="lost_2" width="400" height="300" /></div>
</p>
<p>Sobel method (horizontal):</p>
<p>
<div class="captionfull"><img class="aligncenter size-full wp-image-956" title="lost_3" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/lost_3.jpg" alt="lost_3" width="400" height="300" /></div>
</p>
<p>Sobel method (vertical):</p>
<p>
<div class="captionfull"><img class="aligncenter size-full wp-image-957" title="lost_4" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/lost_4.jpg" alt="lost_4" width="400" height="300" /></div>
</p>
<p>Laplacian method:</p>
<p>
<div class="captionfull"><img class="aligncenter size-full wp-image-958" title="lost_5" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/lost_5.jpg" alt="lost_5" width="400" height="300" /></div>
</p>
<p>Hilite method:</p>
<p>
<div class="captionfull"><img class="aligncenter size-full wp-image-959" title="lost_6" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/lost_6.jpg" alt="lost_6" width="400" height="300" /></div>
</p>
<p>Tanner&#8217;s method 1:</p>
<p>
<div class="captionfull"><img class="aligncenter size-full wp-image-960" title="lost_7" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/lost_7.jpg" alt="lost_7" width="400" height="300" /></div>
</p>
<p>Tanner&#8217;s method 2:</p>
<p>
<div class="captionfull"><img class="aligncenter size-full wp-image-961" title="lost_8" src="http://www.tannerhelland.com/wp-content/uploads/2009/05/lost_8.jpg" alt="lost_8" width="400" height="300" /></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/edge-detection-vb6/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Advanced Image Histograms in VB6 &#8211; Stretching and Equalizing</title>
		<link>http://www.tannerhelland.com/vb6/vb6-image-histograms-2/</link>
		<comments>http://www.tannerhelland.com/vb6/vb6-image-histograms-2/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 14:00:57 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[advanced graphics]]></category>
		<category><![CDATA[histograms]]></category>
		<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=810</guid>
		<description><![CDATA[As promised, here is the second half of my histogram code project.  In this project, I'll show you how to stretch a histogram, equalize individual channels, and - most useful of all - equalize an image's overall luminance.  Cool, eh?]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><em>This is the 2nd half of a two-part project.  Part 1 is available <a  href="http://www.tannerhelland.com/vb6/vb6-image-histograms-1/">here</a>.</em></p>
<p>As promised, here is the second half of my histogram code project.  In this project, I&#8217;ll show you how to stretch a histogram, equalize individual channels, and &#8211; most useful of all &#8211; equalize an image&#8217;s overall luminance.  Cool, eh?</p>
<p><strong>Stretching a Histogram</strong></p>
<p>The most straightforward of these functions is stretching a histogram.  The idea is this: many images stretch from pretty-dark colors to pretty-light colors, but they don&#8217;t take advantage of the full luminance spectrum by stretching all the way from pure black to pure light.  (For example, a &#8220;washed-out&#8221; image typically fails to utilize the entire luminance spectrum.)  To help fix an image like this, it is necessary to adjust the image&#8217;s colors to better span all possible brightness values.</p>
<p>Stretching does this by finding the darkest and lightest values in an image, then performing an automatic conversion between that color range (max &#8211; min) and the ideal color range (pure white &#8211; pure black).</p>
<p>As an example, here is an image that doesn&#8217;t span the full brightness spectrum:</p>
<div class="captionfull"><img class="aligncenter size-large wp-image-812" title="Normal Clouds" src="http://www.tannerhelland.com/wp-content/uploads/2009/03/cloudsnormal-600x449.jpg" alt="Normal Clouds" width="600" height="449" /></div>
<p>Notice how the top half of the histogram is empty?  The brightest pixels in this image are only a mid-level gray.</p>
<p>Here is the same image after running a stretch histogram algorithm:</p>
<div class="captionfull"><img class="aligncenter size-large wp-image-813" title="Stretched Clouds" src="http://www.tannerhelland.com/wp-content/uploads/2009/03/cloudsstretched-600x449.jpg" alt="Stretched Clouds" width="600" height="449" /></div>
<p>Notice how the histogram now stretches all the way to pure white?  Admittedly, this picture is not the best example of how stretching can be useful &#8211; but it&#8217;s a good demonstration of what stretching does.</p>
<p>Stretching is a fast and simple function, but its useful is limited.  Take the following image, for example:</p>
<div class="captionfull"><img class="aligncenter size-large wp-image-814" title="Normal Tiger" src="http://www.tannerhelland.com/wp-content/uploads/2009/03/normaltiger-600x449.jpg" alt="Normal Tiger" width="600" height="449" /></div>
<p>The colors in this tiger picture stretch all the way from pure black to pure white, but they seem to be more heavily concentrated toward the dark end of the luminance spectrum.  To really fix this picture, we need to redistribute its colors across the spectrum in a more equal way.</p>
<p>Enter equalization.</p>
<p><strong>Equalizing a Histogram</strong></p>
<p>Equalizing is a more complex and time-consuming function than stretching, but it is able to fix problems outside the reach of stretching alone.</p>
<p>Here is the tiger image post-equalization:</p>
<div class="captionfull"><img class="aligncenter size-large wp-image-815" title="Equalized Tiger" src="http://www.tannerhelland.com/wp-content/uploads/2009/03/equalizedtiger-600x449.jpg" alt="Equalized Tiger" width="600" height="449" /></div>
<p>See how much more balanced the histogram has become?  As another example, here is the cloud picture from above after both stretching and equalizing:</p>
<div class="captionfull"><img class="aligncenter size-large wp-image-816" title="Stretched and Equalized Clouds" src="http://www.tannerhelland.com/wp-content/uploads/2009/03/cloudsstretchequalize-600x449.jpg" alt="Stretched and Equalized Clouds" width="600" height="449" /></div>
<p>Equalizing has brought out a bunch of details that weren&#8217;t apparent in the original image.</p>
<p>Rather than going through the gory details of how histogram equalizing works, I&#8217;m going to refer you to the excellent Wikipedia article on the subject:</p>
<p><a  href="http://en.wikipedia.org/wiki/Histogram_equalization" target="_blank">http://en.wikipedia.org/wiki/Histogram_equalization</a></p>
<p>Also, I&#8217;d like to quote one very applicable comment from the above article (emphasis added by me):</p>
<blockquote><p>The above describes histogram equalization on a greyscale image. However, it can also be used on color images by applying the same method separately to the Red, Green and Blue components of the RGB color values of the image. Still, <strong>it should be noted that applying the same method on the Red, Green, and Blue components of an RGB image may yield dramatic changes in the image&#8217;s color balance</strong> since the relative distributions of the color channels change as a result of applying the algorithm. <strong>However, if the image is first converted to another color space, Lab color space, or HSL/HSV color space in particular, then the algorithm can be applied to the luminance or value channel without resulting in changes to the hue and saturation of the image</strong>.</p></blockquote>
<p>Because of this, I have supplied two equalizing algorithms in this project &#8211; one that equalizes any combination of color channels, and another that equalizes only luminance.  The luminance method provides the code for converting between RGB and HSL color spaces&#8230;and that code is very complex.  It&#8217;s probably worth your while to take that code on faith for now, and maybe at a future date I&#8217;ll discuss color space transformations in more detail.</p>
<p><strong>Get the Code!</strong></p>
<p>But enough chat!  Here&#8217;s the link for the code:</p>
<p><strong></strong><strong><a  href="http://www.tannerhelland.com/code/AdvancedHistograms.zip">Download Advanced Histogram Code (91 kb)</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/vb6-image-histograms-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Histograms in VB6 &#8211; Part 1</title>
		<link>http://www.tannerhelland.com/vb6/vb6-image-histograms-1/</link>
		<comments>http://www.tannerhelland.com/vb6/vb6-image-histograms-1/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 07:19:26 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[histograms]]></category>
		<category><![CDATA[vb6 graphics]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=747</guid>
		<description><![CDATA[Today's project demonstrates how to quickly and efficiently generate an image histogram.  Histograms are invaluable for understanding and implementing a multitude of image processing techniques - including brightness, contrast, levels, curves, equalizing, and more - so it's worth taking some time to experiment with them.  As always, DIB sections are used to generate and render the histograms in real-time...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><em>This is the 1st half of a two-part project.  Part 2 is available <a  href="http://www.tannerhelland.com/vb6/vb6-image-histograms-2/">here</a>.</em></p>
<p>I realized today that while I use image histograms in several of the projects on this site (particularly my <a  href="http://www.tannerhelland.com/vb6/graphics-vb6/image-levels-vb6/">Real-Time Image Levels</a> demo), I don&#8217;t actually provide a stand-alone image histogram viewer.</p>
<p>&#8230;Until now, that is.  :)</p>
<p>Image histograms are HUGELY useful in image processing.  In fact, the most basic image processing algorithm &#8211; adjusting brightness &#8211; is entirely an image histogram process, theoretically speaking.  Many other functions (including contrast, invert, levels, curves, and more) can be described in terms of an image histogram as well.</p>
<p>So what is an image histogram, and why is it useful?</p>
<p><strong>What is a histogram?</strong></p>
<p><a  href="http://www.answers.com" target="_self">Answers.com</a> defines histograms as:</p>
<p><em>A bar graph of a frequency distribution in which the widths of the bars are proportional to the classes into which the variable has been divided and the heights of the bars are proportional to the class frequencies.</em></p>
<p>I realize this definition is not entirely useful, but it is important to note that histograms are not used <strong>only</strong> in image processing.  Histograms are simply a type of graph &#8211; nothing more, nothing less.</p>
<p>A simpler way to define histograms is this: <strong>a histogram is a bar graph that shows population by category</strong>.  Categories are listed, in order, along the x-axis (or horizontally).  The population (or, alternatively, number of occurrences) of each category is listed along the y-axis (or vertically).  In this graph from the 2000 U.S. census, travel time of working Americans is shown as a histogram:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-748" title="histogram_demo" src="http://www.tannerhelland.com/wp-content/uploads/2009/03/histogram_demo.png" alt="histogram_demo" width="600" height="387" /></div>
<p>Simple, eh?</p>
<p><strong>So what is an Image Histogram?</strong></p>
<p>As you can imagine, an image histogram is a type of histogram that tells us something about an image.  In most cases, the categories in an image histogram are brightness levels (from black to white), while the &#8220;population&#8221; of each category is the number of pixels with that brightness.</p>
<p>To demonstrate, let&#8217;s look at two different image histograms.</p>
<p>First, here is a histogram of a dark, cloudy image:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-749" title="dark_histogram" src="http://www.tannerhelland.com/wp-content/uploads/2009/03/dark_histogram.jpg" alt="dark_histogram" width="600" height="406" /></div>
<p>Notice how the image histogram is heavily weighted to the left?  Because this image is quite dark, the histogram shows much more pixels on the left side of the graph (the dark side) than it does on the right side of the graph (the light side).</p>
<p>Conversely, here is the histogram of a bright image:</p>
<div class="captionfull"><img class="aligncenter size-full wp-image-751" title="light_histogram" src="http://www.tannerhelland.com/wp-content/uploads/2009/03/light_histogram.jpg" alt="light_histogram" width="600" height="406" /></div>
<p>While there are some dark regions in the center of the image (indicated by the spike on the far left of our histogram), the bulk of the image is lighter, and as a result the bulk of our histogram is shifted toward the right.</p>
<p>Now that you know what image histograms represent, try out the attached histogram code and see if you can predict rough histogram outlines before loading an image.  (Note that as with all VB6 picture-box-based code, the program will not load images larger than ~2mb.)</p>
<p>The forthcoming &#8220;Image Histograms Part 2&#8243; project will showcase stretching a histogram and equalizing a histogram, so stay tuned!</p>
<p><strong><a  href="http://www.tannerhelland.com/code/Histograms.zip">Download Histogram Code (85 kb)</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/vb6-image-histograms-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code for Filling Image Regions (VB6)</title>
		<link>http://www.tannerhelland.com/vb6/fill-image-regions/</link>
		<comments>http://www.tannerhelland.com/vb6/fill-image-regions/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 22:56:21 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[fill]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[paint bucket]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=649</guid>
		<description><![CDATA[This little program demonstrates two key graphics programming principles: 1) simple "painting" code - basically, connecting a series of lines together as the user drags their mouse around, and 2) an implementation of the hard-to-find (and poorly documented) dll call for filling a contiguous region of an image.  (Photoshop users should know this as the "paint bucket" tool.)  As always, sample code and full documentation is provided...]]></description>
			<content:encoded><![CDATA[<p>This little program demonstrates two key graphics programming principles:</p>
<p>1) Simple &#8220;painting&#8221; code &#8211; basically, connecting a series of lines together as the user drags their mouse around.</p>
<p>2) An implementation of the hard-to-find (and poorly documented) API call for filling a contiguous region of an image.  (Photoshop users should know this as the &#8220;paint bucket&#8221; tool.)</p>
<p>The API call used to perform the fill operation is ExtFloodFill, with a VB6 declaration and parameters like so:</p>
<pre><code>Private Declare Function ExtFloodFill Lib "GDI32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long</code></pre>
<p>To use the program, draw several lines using the left mouse button, then fill contiguous regions (with random colors) via the right button.  Simple, eh?</p>
<p style="text-align: center;"><a  href="http://www.tannerhelland.com/code/Fill.zip"><strong>Download Code (7 kb)</strong></a></p>
<div class="captionfull"><img class="aligncenter size-medium wp-image-650" title="fill_screenshot" src="http://www.tannerhelland.com/wp-content/uploads/2009/03/fill_screenshot-300x252.png" alt="fill_screenshot" width="300" height="252" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/fill-image-regions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mathematically Generated Fire &#8211; REVISED</title>
		<link>http://www.tannerhelland.com/vb6/mathematical-fire-code-2/</link>
		<comments>http://www.tannerhelland.com/vb6/mathematical-fire-code-2/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 06:15:18 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Game Code]]></category>
		<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[fire]]></category>
		<category><![CDATA[game programming]]></category>
		<category><![CDATA[math is fun]]></category>
		<category><![CDATA[optimized version]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=640</guid>
		<description><![CDATA[Because the first draft of this project has become so popular, I've gone ahead and built a new and MUCH faster version.  Updates include: DIB sections for flame drawing, look-up tables, optimized randomization, and custom flame coloring.  On my old 1.6ghz laptop this version runs over 4x faster than version 1.0.  Enjoy!]]></description>
			<content:encoded><![CDATA[<div class="captionfull"><img class="aligncenter size-full wp-image-536" title="Mathematical Fire" src="http://www.tannerhelland.com/wp-content/uploads/2009/02/fire_program.jpg" alt="A demonstration of mathematically-generated fire" width="750" height="118" />This fire image was mathematically generated using the code available below.</div>
<p>Because <a  href="http://www.tannerhelland.com/vb6/mathematical-fire-code/" target="_blank">the first draft of this project</a> has become so popular, I&#8217;ve written a new and MUCH faster version of the source code.  As before, no pre-built images or palettes are used, meaning that both coloring and flame generation are done using only math (and ingenuity!).</p>
<p>Updates to this version include the following:</p>
<ul>
<li>DIB sections are now used in place of Get/SetPixel.  This alone nearly tripled the frame rate on my old 1.6ghz laptop.</li>
<li>Flame coloring is now done via look-up tables.  Previously this was calculated on the fly, which required way too many duplicate calculations.</li>
<li>Random horizontal movement of individual flames is now calculated for every 4th pixel (instead of every single one).  Random number generation is costly, and visually this method looks almost identical (but is markedly faster).</li>
<li>Scrollbars are now available so that you can color the flames however you&#8217;d like.  Red flames, blue flames, green flames, or any combination in-between &#8211; so knock yourself out.</li>
</ul>
<p>On my aforementioned 1.6ghz laptop, the original version of this code ran (compiled) at 6-7 fps for a 512&#215;256 image.  The new code runs between 27 and 28 fps &#8211; or a 400+% increase.</p>
<p>As usual, the sample code was written for VB6, but an .exe is included for those just wanting screenshots (or if you just want to see the effect in action).  Enjoy, and if you have any recommendations for Fire v.3, leave a comment!</p>
<p style="text-align: center;"><a  href="http://www.tannerhelland.com/code/Faster_Fire.zip"><strong>Download Code (18 kb)</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/mathematical-fire-code-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Use Math to Create Fire</title>
		<link>http://www.tannerhelland.com/vb6/mathematical-fire-code/</link>
		<comments>http://www.tannerhelland.com/vb6/mathematical-fire-code/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 07:10:24 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Game Code]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[fire]]></category>
		<category><![CDATA[game programming]]></category>
		<category><![CDATA[math is fun]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=535</guid>
		<description><![CDATA[Whether working on an old-school RPG or a state-of-the-art FPS, every game programmer needs a fast, cool fire effect at some point in his/her career.  In this example, I've opted for a straightforward and easy-to-understand method for generating real-time flames.  No pre-built images or palettes are used, making the code quite small (only 11kb, including a demo exe) and very easy to reuse.  Coloring and flame generation is done using only math and a little cleverness...]]></description>
			<content:encoded><![CDATA[<div class="captionfull"><img class="aligncenter size-full wp-image-536" title="Mathematical Fire" src="http://www.tannerhelland.com/wp-content/uploads/2009/02/fire_program.jpg" alt="A demonstration of mathematically-generated fire" width="750" height="118" />This fire image was mathematically generated using the code available below.</div>
<p><strong><span style="color: #ff0000;">(NOTE: as of February 26th, 2009, version 2.0 of this code is available at <a  href="http://www.tannerhelland.com/vb6/mathematical-fire-code-2/">http://www.tannerhelland.com/vb6/mathematical-fire-code-2/</a>)</span></strong></p>
<p>Whether working on an old-school RPG or a state-of-the-art FPS, every game programmer needs to be able to generate a fast, cool fire effect at some point in his/her career.  In this example, I&#8217;ve opted for a straightforward and easy-to-understand method for generating real-time flames.  No pre-built images or palettes are used, making the code quite small and easy to reuse.  Coloring and flame generation is done using only math and a little cleverness.  :)</p>
<p>As usual, the sample code was written for VB6, but an .exe is included for those just wanting screenshots (or if you just want to see the effect in action).  To simplify the code, I&#8217;ve used SetPixelV for drawing the fire.  This slows the demo down significantly, but <a  href="http://www.tannerhelland.com/vb6/vb-graphics-programming-4/" target="_self">DIB sections could easily be dropped into place</a> if speed is a major factor for you.</p>
<p style="text-align: center;"><a  href="http://www.tannerhelland.com/code/Fast_Fire.zip"><strong>Download Code (11 kb)</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/mathematical-fire-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real-Time Image Blending/Transparency (VB6)</title>
		<link>http://www.tannerhelland.com/vb6/image-blending-transparency/</link>
		<comments>http://www.tannerhelland.com/vb6/image-blending-transparency/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 03:26:35 +0000</pubDate>
		<dc:creator>Tanner</dc:creator>
				<category><![CDATA[Graphics Code]]></category>
		<category><![CDATA[VB6]]></category>
		<category><![CDATA[fx]]></category>
		<category><![CDATA[transparency]]></category>
		<category><![CDATA[vb6 graphics]]></category>

		<guid isPermaLink="false">http://www.tannerhelland.com/?p=490</guid>
		<description><![CDATA[Real-time transparency has become so commonplace in modern games and PC applications that it&#8217;s almost taken for granted.  However, the specific formula that performs this now-ubiquitous effect is worth understanding.
Transparency is simply a weighted average between the color values of two pixels.  As an example, consider the following two colors:
Pure red, or RGB(255, 0, 0)
Pure [...]]]></description>
			<content:encoded><![CDATA[<p>Real-time transparency has become so commonplace in modern games and PC applications that it&#8217;s almost taken for granted.  However, the specific formula that performs this now-ubiquitous effect is worth understanding.</p>
<p>Transparency is simply a weighted average between the color values of two pixels.  As an example, consider the following two colors:</p>
<p><strong><span style="color: #ff0000;">Pure red, or RGB(255, 0, 0)</span></strong></p>
<p><strong><span style="color: #0000ff;">Pure blue, or RGB(0, 0, 255)</span></strong></p>
<p>At 50% transparency &#8211; or a pure blending between these two colors &#8211; we would simply add the individual color amounts together and divide by two.  This gives us a new color -</p>
<p><strong><span style="color: #880088;">Purple, or RGB(127, 0, 127)</span></strong></p>
<p>Not entirely surprising, eh?</p>
<p>The effect is certainly more impressive when applied pixel-by-pixel across an entire image.  The provided code does exactly that using VB6, and an .exe is included for those merely interested in the effect itself.</p>
<p><a  href="http://www.tannerhelland.com/code/Transparency.zip"><strong>Download code (144kb)</strong></a></p>
<div id="attachment_491" class="wp-caption aligncenter" style="width: 435px"><img class="size-full wp-image-491" title="transparency_screenshot" src="http://www.tannerhelland.com/wp-content/uploads/2009/01/transparency_screenshot.jpg" alt="Squall and Rinoa meet a large flower (insert Garden joke of your choice :)" width="425" height="384" /><p class="wp-caption-text">Squall and Rinoa meet a large flower (insert Garden joke of your choice :)</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tannerhelland.com/vb6/image-blending-transparency/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
