
<?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>The Visioneers</title>
	<atom:link href="http://www.oliveragustin.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oliveragustin.com</link>
	<description>Tech, IT, Security, Research, Trends and  Tips</description>
	<lastBuildDate>Thu, 26 Jan 2012 10:45:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Background Subtraction in C# Part 2</title>
		<link>http://www.oliveragustin.com/background-subtraction-in-c-part-2/</link>
		<comments>http://www.oliveragustin.com/background-subtraction-in-c-part-2/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 10:59:05 +0000</pubDate>
		<dc:creator>whaldsz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.oliveragustin.com/?p=101</guid>
		<description><![CDATA[My old post has been receiving lots of hits requesting for the source code of the background subtraction in this post.  The code below is an improved implementation,  much faster and less code.  Please note that this method is excellent for the type of images where foreground and background object is contrasting. Additional image post-processing [...]]]></description>
			<content:encoded><![CDATA[<p>My old post has been receiving lots of hits requesting for the source code of the background subtraction in this <a title="Background Subtraction" href="http://www.oliveragustin.com/tag/background-subtraction/">post</a>.  The code below is an improved implementation,  much faster and less code.  Please note that this method is excellent for the type of images where foreground and background object is contrasting. Additional image post-processing may be needed to remove small blobs.</p>
<pre class="brush: csharp; ">

var image= new Image&lt;Bgr,byte&gt;(filename);

// threshold values for each channel
var thresholds = new [] {new TRange&lt;int&gt;(70,255), new TRange&lt;int&gt;(0,255), new TRange&lt;int&gt;(0,255)};

Image&lt;Gray, byte&gt;[] grays = image.Convert&lt;Lab, byte&gt;().Split();

// threshold each channel
for (int i = 0; i &lt; 3; i++)

{
grays[i]._ThresholdToZero(new Gray(thresholds [i].LowerValue));
grays[i]._ThresholdToZeroInv(new Gray(thresholds [i].UpperValue));
grays[i]._ThresholdBinary(new Gray(1), new Gray(255));
}

// merge the thresholded array of binary images above
var  mask = grays[0].And(grays[1].And(grays[2]));

// result
var resultImage = image.Copy(mask);
</pre>
<p style="white-space:nowrap"><img style="border:0px" src="http://tarpipe.com/img/tarpipe.png" />&nbsp;<a target="_blank" href="http://tarpipe.com/share/?t=Background+Subtraction+in+C%23+Part+2&u=http%3A%2F%2Fwww.oliveragustin.com%2Fbackground-subtraction-in-c-part-2%2F&b=Reading %22Background+Subtraction+in+C%23+Part+2%22">Share now!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.oliveragustin.com/background-subtraction-in-c-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB Creator in SQLITE and C#</title>
		<link>http://www.oliveragustin.com/db-creator-in-sqlite-and-c/</link>
		<comments>http://www.oliveragustin.com/db-creator-in-sqlite-and-c/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 09:53:54 +0000</pubDate>
		<dc:creator>whaldsz</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.oliveragustin.com/?p=98</guid>
		<description><![CDATA[In one of my projects, there is a need to implement a server-less SQL database.  The result of my exploration led me to SQLITE.  I&#8217;m lucky to have found a good wrapper since I&#8217;m using C#.  All is well until the need to re-create the database arises. This is required when the application is being [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my projects, there is a need to implement a server-less SQL database.  The result of my exploration led me to <a title="SQLITE" href="http://www.google.com.ph/url?sa=t&amp;rct=j&amp;q=sqlite&amp;source=web&amp;cd=1&amp;ved=0CDEQFjAA&amp;url=http%3A%2F%2Fwww.sqlite.org%2F&amp;ei=eGAfT56vMYPoggeF-dGCDw&amp;usg=AFQjCNEakQjCFFXx7pu-fq8qk9wUOlC1Bg&amp;sig2=sfEHzvajIYeRpADqpMUXtw">SQLITE</a>.  I&#8217;m lucky to have found a good wrapper since I&#8217;m using C#.  All is well until the need to re-create the database arises. This is required when the application is being readied for deployment.  In my application, one of the requirements was to be able to reset the database  or re create the database inside the application.</p>
<p>To serve this purpose, I developed a small C#console application to create the database for me.  The code is quiet simple , far from optimized and buggy but of course it is up to you to improve it.</p>
<pre class="brush: csharp; ">

public static class Util
&lt;pre&gt; {
public static bool CreateDb(string db)
{
try
{
Console.WriteLine(&quot;Please wait creating database &quot; + db);
SQLiteConnection.CreateFile(db);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}

return true;
}

public static bool ExecuteScript(string script, string connectionString)
{
try
{
if (!File.Exists(script)) throw new FileNotFoundException(script);

DbProviderFactory fact = DbProviderFactories.GetFactory(&quot;System.Data.SQLite&quot;);
using (DbConnection cnn = fact.CreateConnection())
{
cnn.ConnectionString = connectionString;

using (var cmd = cnn.CreateCommand())
{
var fileInfo = new FileInfo(script);
var sql = fileInfo.OpenText().ReadToEnd();

var tables = System.Text.RegularExpressions.Regex.Split(sql, &quot;\r\n\r\n&quot;);

if (tables.Length &gt; 0)
{
cnn.Open();

foreach (var table in tables)
{
Console.WriteLine(&quot;Writing TABLE: \n&quot; + table);
cmd.CommandText = table;
cmd.CommandType = CommandType.Text;

cmd.ExecuteNonQuery();
}
}

cnn.Close();
return true;
}
}

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
}&lt;/pre&gt;
&lt;pre&gt;
</pre>
<pre></pre>
<pre>In your app.config, you need the following entry:</pre>
<pre>
<pre class="brush: xml; ">
&lt;/pre&gt;
&lt;pre&gt;&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;configuration&gt;
  &lt;startup useLegacyV2RuntimeActivationPolicy=&quot;true&quot;&gt;
    &lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.0&quot;/&gt;
  &lt;/startup&gt;

  &lt;system.data&gt;
    &lt;DbProviderFactories&gt;
      &lt;remove invariant=&quot;System.Data.SQLite&quot;/&gt;
      &lt;add name=&quot;SQLite Data Provider&quot; invariant=&quot;System.Data.SQLite&quot;?
      description=&quot;.Net Framework Data Provider for SQLite&quot;
      type=&quot;System.Data.SQLite.SQLiteFactory, System.Data.SQLite&quot;/&gt;&lt;/pre&gt;
&lt;pre&gt;    &lt;/DbProviderFactories&gt;
  &lt;/system.data&gt;
&lt;startup&gt;&lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.0&quot;/&gt;&lt;/startup&gt;
&lt;/configuration&gt;&lt;/pre&gt;
&lt;pre&gt;
</pre>
</pre>
<pre>Finally, add a reference to the first file, the second file below should be in the same location as the executable:</pre>
<ol>
<li>System.Data.SQLite.dll</li>
<li>System.Data.SQLite.lib</li>
</ol>
<p style="white-space:nowrap"><img style="border:0px" src="http://tarpipe.com/img/tarpipe.png" />&nbsp;<a target="_blank" href="http://tarpipe.com/share/?t=DB+Creator+in+SQLITE+and+C%23&u=http%3A%2F%2Fwww.oliveragustin.com%2Fdb-creator-in-sqlite-and-c%2F&b=Reading %22DB+Creator+in+SQLITE+and+C%23%22">Share now!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.oliveragustin.com/db-creator-in-sqlite-and-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>We got 2nd during the 32nd R&amp;D Review</title>
		<link>http://www.oliveragustin.com/we-got-2nd-during-the-32nd-rd-review/</link>
		<comments>http://www.oliveragustin.com/we-got-2nd-during-the-32nd-rd-review/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 21:24:19 +0000</pubDate>
		<dc:creator>whaldsz</dc:creator>
				<category><![CDATA[projects]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[Milled Rice]]></category>
		<category><![CDATA[philmech]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://www.oliveragustin.com/?p=92</guid>
		<description><![CDATA[During the 32nd In-house Research and Development Review last May10-11, 2011 held at Munoz City, Philippines. Our on-going research on Milled Rice Computer Vision garnered an award. For more information, follow this link - http://www.philmech.gov.ph/?page=news&#38;action=details&#38;code01=NP11050002 &#160;Share now!]]></description>
			<content:encoded><![CDATA[<p>During the 32nd In-house Research and Development Review last May10-11, 2011 held at Munoz City, Philippines. Our on-going research on Milled Rice Computer Vision garnered an award.</p>
<p>For more information, follow this link - <a href="http://www.philmech.gov.ph/?page=news&amp;action=details&amp;code01=NP11050002">http://www.philmech.gov.ph/?page=news&amp;action=details&amp;code01=NP11050002</a></p>
<p style="white-space:nowrap"><img style="border:0px" src="http://tarpipe.com/img/tarpipe.png" />&nbsp;<a target="_blank" href="http://tarpipe.com/share/?t=We+got+2nd+during+the+32nd+R%26D+Review&u=http%3A%2F%2Fwww.oliveragustin.com%2Fwe-got-2nd-during-the-32nd-rd-review%2F&b=Reading %22We+got+2nd+during+the+32nd+R%26D+Review%22">Share now!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.oliveragustin.com/we-got-2nd-during-the-32nd-rd-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AFMA Best R&amp;D Paper for Technology/Information Generation</title>
		<link>http://www.oliveragustin.com/afma-best-rd-paper-for-technologyinformation-generation/</link>
		<comments>http://www.oliveragustin.com/afma-best-rd-paper-for-technologyinformation-generation/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 16:56:01 +0000</pubDate>
		<dc:creator>whaldsz</dc:creator>
				<category><![CDATA[news]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[research]]></category>

		<guid isPermaLink="false">http://www.oliveragustin.com/?p=85</guid>
		<description><![CDATA[Our study, &#8220;Development of a Computer Vision System for Milled Rice Quality Analysis&#8221; won the AFMA Best R&#038;D Paper for Technology/Information Generation &#8211; Agriculture category. The event was held during the 21st National Research Symposium last October 9, 2009 at the Fernando Lopez Hall of the Bureau of Soils and Water Management (BSWM) Bldg., Visayas [...]]]></description>
			<content:encoded><![CDATA[<p>Our study, &#8220;Development of a Computer Vision System for Milled Rice Quality Analysis&#8221; won the AFMA Best R&#038;D Paper for Technology/Information Generation &#8211; Agriculture category.</p>
<p>The event was held during the 21st National Research Symposium last October 9, 2009 at the Fernando Lopez Hall of the Bureau of Soils and Water Management (BSWM) Bldg., Visayas Avenue, Diliman, Quezon City.</p>
<p>Check the full article @ <a href="http://www.bar.gov.ph/news/21stnrswinners.asp">http://www.bar.gov.ph/news/21stnrswinners.asp</a></p>
<p style="white-space:nowrap"><img style="border:0px" src="http://tarpipe.com/img/tarpipe.png" />&nbsp;<a target="_blank" href="http://tarpipe.com/share/?t=AFMA+Best+R%26D+Paper+for+Technology%2FInformation+Generation&u=http%3A%2F%2Fwww.oliveragustin.com%2Fafma-best-rd-paper-for-technologyinformation-generation%2F&b=Reading %22AFMA+Best+R%26D+Paper+for+Technology%2FInformation+Generation%22">Share now!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.oliveragustin.com/afma-best-rd-paper-for-technologyinformation-generation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Background Subtraction in C#</title>
		<link>http://www.oliveragustin.com/background-subtraction-in-c/</link>
		<comments>http://www.oliveragustin.com/background-subtraction-in-c/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 17:16:27 +0000</pubDate>
		<dc:creator>whaldsz</dc:creator>
				<category><![CDATA[emgu]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[background subtraction]]></category>
		<category><![CDATA[emgu.cv]]></category>
		<category><![CDATA[opencv]]></category>

		<guid isPermaLink="false">http://www.oliveragustin.com/background-subtraction-in-c</guid>
		<description><![CDATA[I have been trying to learn OpenCV for a while now and I came across Emgu.CV, a C# wrapper.  Although the Emgu.CV is still under development, it has a many features that will make your work a lot easier if you&#8217;re doing a project in computer vision and image processing areas.  Some of its capabilities [...]]]></description>
			<content:encoded><![CDATA[<p>I have been trying to learn <a href="http://sourceforge.net/projects/opencvlibrary/" rel="nofollow">OpenCV</a> for a while now and I came across <a href="http://www.emgu.com" rel="nofollow">Emgu.CV</a>, a C# wrapper.  Although the Emgu.CV is still under development, it has a many features that will make your work a lot easier if you&#8217;re doing a project in computer vision and image processing areas.  Some of its capabilities enable you to develop  web applications that can do processing of video and images via TCP/IP.</p>
<p>My goal in this article is to demonstrate simple background segmentation techniques using Emgu.CV.  Background segmentation is important if you are trying to extract features from an image and you want to remove or filter out unwanted objects.  You may also find this technique important when the recovery of color information from foreground objects is important.</p>
<p>Our objective is to remove the background from the rice image below. We want to get the color information from the rice kernels and be able to extract features for for each kernel, maybe for shape analysis or classification purposes.</p>
<p>&nbsp;</p>
<p><a href="http://www.oliveragustin.com/wp-content/uploads/2008/11/image.png"><img style="border-width: 0px;" src="http://www.oliveragustin.com/wp-content/uploads/2008/11/image-thumb.png" alt="Original image" width="244" height="204" border="0" /></a></p>
<p>I am sure there are other ways to perform background subtraction but this article will cover three methods that .</p>
<ol>
<li>Color filtering in Cielab color space</li>
<li>Image masking (as i call it)</li>
<li>Cielab + image masking</li>
</ol>
<p>The three methods will be explained shortly and the link to the source code is available at the visioneer forum.</p>
<p><strong>Color Filtering in Cielab Color Space</strong></p>
<p>In this method, a copy of RGB image in Cielab space is obtained, and then process this image (in Cielab space) pixel by pixel.  Each pixel is checked if its color value is within specified range, otherwise, the pixel in the corresponding RGB image is set to black color.  An implementation is visible below:</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border: gray 1px solid; padding: 4px;">
<div style="font-size: 8pt; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 1:</span> <span style="color: #008000;">// background subtraction in cielab color space</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 2:</span> <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> CielabColorFilteringBGSubtraction(<span style="color: #0000ff;">string</span> filename, <span style="color: #0000ff;">bool</span> displayResult)</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 3:</span> {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 4:</span>     <span style="color: #008000;">// create new image from file</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 5:</span>     Image&lt;Bgr, Byte&gt; rgbimage = <span style="color: #0000ff;">new</span> Image&lt;Bgr, <span style="color: #0000ff;">byte</span>&gt;(filename);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 6:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 7:</span>     <span style="color: #008000;">// make a copy of the image in lab color space</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 8:</span>     Image&lt;Lab, Byte&gt; labimage = rgbimage.Convert&lt;Lab, Byte&gt;();</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 9:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 10:</span>     <span style="color: #008000;">// get the width and size</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 11:</span>     <span style="color: #0000ff;">int</span> width = labimage.Width;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 12:</span>     <span style="color: #0000ff;">int</span> height = labimage.Height;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 13:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 14:</span>     <span style="color: #008000;">// get the filter range for each channel in lab color space</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 15:</span>     IntRange l = <span style="color: #0000ff;">new</span> IntRange(Byte.Parse(min1TextBox.Text), Byte.Parse(max1TextBox.Text));</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 16:</span>     IntRange a = <span style="color: #0000ff;">new</span> IntRange(Byte.Parse(min2TextBox.Text), Byte.Parse(max2TextBox.Text));</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 17:</span>     IntRange b = <span style="color: #0000ff;">new</span> IntRange(Byte.Parse(min3TextBox.Text), Byte.Parse(max3TextBox.Text));</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 18:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 19:</span>     <span style="color: #008000;">// process each row in the image</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 20:</span>     <span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> i = 0; i &lt; width; i++)</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 21:</span>     {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 22:</span>         <span style="color: #008000;">// process each pixel</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 23:</span>         <span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> j = 0; j &lt; height; j++)</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 24:</span>         {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 25:</span>             <span style="color: #0000ff;">if</span> (</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 26:</span>                 (labimage[j, i].X &gt;=l.Max ) || (labimage[j, i].X &lt;= l.Min) ||</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 27:</span>                  (labimage[j, i].Y &gt;= a.Max) || (labimage[j, i].Y &lt;= a.Min) ||</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 28:</span>                  (labimage[j, i].Z &gt;= b.Max) || (labimage[j, i].Z &lt;= b.Min)</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 29:</span>                 )</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 30:</span>             {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 31:</span>                 <span style="color: #008000;">// if outside the filter range, set the pixel to black color</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 32:</span>                 rgbimage[j, i] = <span style="color: #0000ff;">new</span> Bgr(0, 0, 0);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 33:</span>             }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 34:</span>         }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 35:</span>     }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 36:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 37:</span>     <span style="color: #008000;">// display</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 38:</span>     <span style="color: #0000ff;">if</span> (displayResult) <span style="color: #0000ff;">this</span>.NewImage(<span style="color: #006080;">"Cielab-based background segmented image"</span>, rgbimage);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 39:</span> }</pre>
</div>
</div>
<p>The resulting image looks like this.  In my PC, it took about 3.20 sec to perform background segmentation.</p>
<p><a href="http://www.oliveragustin.com/wp-content/uploads/2008/11/output.png"><img style="border-width: 0px;" src="http://www.oliveragustin.com/wp-content/uploads/2008/11/output-thumb.png" alt="output" width="244" height="204" border="0" /></a></p>
<p><strong>Image Masking</strong></p>
<p>In this method, what we do is convert an RGB image into binary via binary thresholding.  (The choice of threshold value depends on the image, so you have to experiment on this.)  This binary image will serve as the mask image to copy pixels from the original image to the destination image, if the corresponding pixel in the mask image is nonzero. This is given by the following representation:</p>
<p>DestinatioImage(x,y) = SourceImage(x,y) if MaskImage(x,y) &lt;&gt; 0</p>
<p>where x and y is the pixel coordinates of the image. Source, destination and mask image have the same size.</p>
<p>Code implementation is as follows:</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border: gray 1px solid; padding: 4px;">
<div style="font-size: 8pt; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 1:</span> <span style="color: #008000;">// background subtraction by converting the RGB image to binary to create the mask</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 2:</span> <span style="color: #008000;">// then use this mask to copy foreground objects in the image</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 3:</span> <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> RGBImageMaskBGSubtraction(<span style="color: #0000ff;">string</span> filename, <span style="color: #0000ff;">bool</span> displayResult)</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 4:</span> {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 5:</span>     <span style="color: #008000;">// load the threshold value for grayscale image</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 6:</span>     <span style="color: #0000ff;">double</span> threshold = <span style="color: #0000ff;">double</span>.Parse(max2TextBox.Text);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 7:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 8:</span>     <span style="color: #008000;">// create new image</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 9:</span>     Image&lt;Bgr, Byte&gt; img = <span style="color: #0000ff;">new</span> Image&lt;Bgr, <span style="color: #0000ff;">byte</span>&gt;(filename);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 10:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 11:</span>     <span style="color: #008000;">//convert to grayscale</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 12:</span>     Image&lt;Gray, Byte&gt; gray = img.Convert&lt;Gray, Byte&gt;();</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 13:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 14:</span>     <span style="color: #008000;">//convert to binary image using the threshold</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 15:</span>     gray = gray.ThresholdBinary(<span style="color: #0000ff;">new</span> Gray(threshold), <span style="color: #0000ff;">new</span> Gray(255));</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 16:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 17:</span>     <span style="color: #008000;">// copy pixels from the original image where pixels in </span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 18:</span>     <span style="color: #008000;">// mask image is nonzero</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 19:</span>     Image&lt;Bgr, Byte&gt; newimg = img.Copy(gray);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 20:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 21:</span>     <span style="color: #008000;">// display result</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 22:</span>     <span style="color: #0000ff;">if</span> (displayResult) <span style="color: #0000ff;">this</span>.NewImage(<span style="color: #006080;">"Background segmented"</span>, newimg);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 23:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 24:</span> }</pre>
</div>
</div>
<p>One thing we should be aware of is that, all channels in RGB image is used to convert the image in grayscale image, then eventually binary image.  The output image is shown below:</p>
<p><a href="http://www.oliveragustin.com/wp-content/uploads/2008/11/output1.png"><img style="border-width: 0px;" src="http://www.oliveragustin.com/wp-content/uploads/2008/11/output-thumb1.png" alt="output" width="244" height="204" border="0" /></a></p>
<p>Obviously, this is far worst then the first method.  But the advantage of segmentation using this technique is the speed.  The image was segmented for only 0.25 sec with more than 12X improvement, but we have to live with the quality. According to my tests, the performance improvement increases as the image size increased.  If we are very much concerned with the pixels in foreground objects, then the Image Masking method will not satisfy our requirements.</p>
<p>However, there is another method to achieve the segmentation quality of cielab color filtering method, and the speed of the image masking method.</p>
<p><strong>Cielab + Image masking</strong></p>
<p>In this method, we combine the first two techniques to get the cream of both ice creams. <img src='http://www.oliveragustin.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   What we do is to perform the processing as in image masking method, but instead of using 3 channels (in RGB format) to convert the image to grayscale, we convert the image into Cielab space, select the a*-channel of the image, and use this channel to derive the mask image.</p>
<p>Code implementation here:</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border: gray 1px solid; padding: 4px;">
<div style="font-size: 8pt; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 1:</span> <span style="color: #008000;">// background subtraction by extracting one channel in cielab image to </span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 2:</span>  <span style="color: #008000;">// create binary mask, and use this mask to copy foreground objects in </span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 3:</span>  <span style="color: #008000;">// the original image</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 4:</span>  <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> CielabChannelMaskBGSubtraction(<span style="color: #0000ff;">string</span> filename, <span style="color: #0000ff;">bool</span> displayResult)</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 5:</span>  {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 6:</span>      <span style="color: #0000ff;">double</span> threshold = <span style="color: #0000ff;">double</span>.Parse(max2TextBox.Text);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 7:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 8:</span>      Image&lt;Bgr, <span style="color: #0000ff;">byte</span>&gt; rgb = <span style="color: #0000ff;">new</span> Image&lt;Bgr, <span style="color: #0000ff;">byte</span>&gt;(filename);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 9:</span>      Image&lt;Lab, Byte&gt; img = rgb.Convert&lt;Lab, Byte&gt;();</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 10:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 11:</span>      <span style="color: #008000;">//get the a* channel </span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 12:</span>      Image&lt;Gray, Byte&gt; gray = img[channel];</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 13:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 14:</span>      <span style="color: #008000;">//threshold and invert</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 15:</span>      gray = gray.ThresholdBinary(<span style="color: #0000ff;">new</span> Gray(threshold), <span style="color: #0000ff;">new</span> Gray(255)).Not();</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 16:</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 17:</span>     <span style="color: #008000;">// display the result</span></pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060;"> 18:</span>      <span style="color: #0000ff;">if</span> (displayResult) <span style="color: #0000ff;">this</span>.NewImage(<span style="color: #006080;">"Background segmented"</span>, image);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: white; border-style: none; padding: 0px;"><span style="color: #606060;"> 19:</span>  }</pre>
</div>
</div>
<p>Resulting output image here, note that it has almost the same quality as in the first method but with little performance penalty (processing takes around 0.03 sec longer than the second method).</p>
<p><a href="http://www.oliveragustin.com/wp-content/uploads/2008/11/output2.png"><img style="border-width: 0px;" src="http://www.oliveragustin.com/wp-content/uploads/2008/11/output-thumb2.png" alt="output" width="244" height="204" border="0" /></a></p>
<p>Please note that you need to tweak the filter range(threshold value) for this to work in your problem area. Also,</p>
<ol>
<li>In Method 1, all three channels are used as filter ranges.</li>
<li>Method 2, uses channel 1(maximum) for grayscale threshold value</li>
<li>In method 3, you can select among the radio buttons (on the right) which channels to choose as the source for the mask image.  Then modify the filter range for that selected channel mask. You can also modify the source code to select one or more channels if it gives better performance.</li>
<li>I have included two images located in the source code folder for testing purposes.</li>
</ol>
<p>Screenshot is given below:</p>
<p><a href="http://www.oliveragustin.com/wp-content/uploads/2008/11/image1.png"><img style="border: 0px;" src="http://www.oliveragustin.com/wp-content/uploads/2008/11/image-thumb1.png" alt="image" width="244" height="202" border="0" /></a></p>
<p>[attachments force_saveas="0" logged_users="0"]</p>
<p style="white-space:nowrap"><img style="border:0px" src="http://tarpipe.com/img/tarpipe.png" />&nbsp;<a target="_blank" href="http://tarpipe.com/share/?t=Background+Subtraction+in+C%23&u=http%3A%2F%2Fwww.oliveragustin.com%2Fbackground-subtraction-in-c%2F&b=Reading %22Background+Subtraction+in+C%23%22">Share now!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.oliveragustin.com/background-subtraction-in-c/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
	</channel>
</rss>

