<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Adaptive Thresholding using Integral Image [source]</title>
	<atom:link href="http://blog.inspirit.ru/?feed=rss2&#038;p=322" rel="self" type="application/rss+xml" />
	<link>http://blog.inspirit.ru/?p=322</link>
	<description>Adobe Flash experiments and stuff</description>
	<lastBuildDate>Sun, 22 Aug 2010 15:15:54 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: João Real</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-3439</link>
		<dc:creator>João Real</dc:creator>
		<pubDate>Thu, 29 Apr 2010 20:14:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-3439</guid>
		<description>I&#039;m building one augmented reality application, using MyARtoolkit C#, and I&#039;m trying to improve the thresholding algorithm.  I have tried your code but I’m not getting the same results as you get in the demo. I’m I missing something? 

Thanks in advance

This is the code:  

   public void integralThresh(byte[] in_buf, NyARIntSize i_size,INyARBufferReader i_output) //im -&gt; source/dest image
            {
                int h = i_size.h;  //image height
                int w = i_size.w;  //image width
     
                int size = w * h;
                int S = w &gt;&gt; 3;
                int S2 = S &gt;&gt; 1;
                float T = 0.15f;
                float IT = 1.0f - T;
     
                int[] integral = new int[size];
                int[] threshold = new int[size];
                int[] data = new int[size];
                int bp = 0;
                int aux = 0;
                int[] out_buf = (int[])i_output.getBuffer();
     
                //Note: copying source image(im) to a vector to use the same code from Eugene
                int index = 0;
                for (int l = 0; l &lt; h; l++)
                    for (int c = 0; c &lt; w; c++)
                    {
                        aux = ((in_buf[bp] &amp; 0xFF) + (in_buf[bp + 1] &amp; 0xFF) + (in_buf[bp + 2] &amp; 0xFF));
                        bp += 4;

                        data[index++] = aux;
                    }
     
                int i, j, diff;
	            int x1, y1, x2, y2, ind1, ind2, ind3 = 0;
	            int sum = 0, ind = 0;
     
	            while( ind &lt; size )
	            {
		            sum += data[ind] &amp; 0xFF;
		            integral[ind] = sum;
		            ind += w;
	            }

                x1 = 0;
                for (i = 1; i  S) x1 = i - S;
                    diff = i - x1;
                    for (j = 0; j &lt; h; ++j)
                    {
                        sum += data[ind] &amp; 0xFF;
                        integral[ind] = integral[(int)(ind - 1)] + sum;
                        ind += w;

                        if (i &lt; S2) continue;
                        if (j &lt; S2) continue;

                        y1 = (j &lt; S ? 0 : j - S);

                        ind1 = y1 * w;
                        ind2 = j * w;

                        if (((data[ind3] &amp; 0xFF) * (diff * (j - y1))) &lt; ((integral[(int)(ind2 + i)] - integral[(int)(ind1 + i)] - integral[(int)(ind2 + x1)] + integral[(int)(ind1 + x1)]) * IT))
                        {
                            threshold[ind3] = 0xFF;// 0x00;
                            out_buf[ind3] = 0xFF;// 0x00;
                        }
                        else
                        {
                            threshold[ind3] = 0x00;//0xFF;
                            out_buf[ind3] = 0x00;//0xFF;
                        }
                        ind3 += w;
                    }
                }

                y1 = 0;
                for( j = 0; j &lt; h; ++j )
                {
                    i = 0;
                    y2 = h - 1;
                    if( j  S2 ) y1 = j - S2;
                    ind1 = y1 * w;
                    ind2 = y2 * w;
                    diff = y2 - y1;

                    for( ; i &lt; w; ++i, ++ind )
                    {

                        x1 = (i = w) x2 = w - 1;
                         
                        if (((data[ind]&amp;0xFF)*((x2 - x1) * diff)) &lt; ((integral[(int)(ind2 + x2)] - integral[(int)(ind1 + x2)] - integral[(int)(ind2 + x1)] + integral[(int)(ind1 + x1)])*IT))
                        {
                            threshold[ind] = 0xFF;// 0x00;
                            out_buf[ind] = 0xFF;// 0x00;
                        } else
                        {
                            threshold[ind] = 0x00;//0xFF;
                            out_buf[ind] = 0x00;//0xFF;
                        }
                    }
                }
     
            }
        }</description>
		<content:encoded><![CDATA[<p>I&#8217;m building one augmented reality application, using MyARtoolkit C#, and I&#8217;m trying to improve the thresholding algorithm.  I have tried your code but I’m not getting the same results as you get in the demo. I’m I missing something? </p>
<p>Thanks in advance</p>
<p>This is the code:  </p>
<p>   public void integralThresh(byte[] in_buf, NyARIntSize i_size,INyARBufferReader i_output) //im -&gt; source/dest image<br />
            {<br />
                int h = i_size.h;  //image height<br />
                int w = i_size.w;  //image width</p>
<p>                int size = w * h;<br />
                int S = w &gt;&gt; 3;<br />
                int S2 = S &gt;&gt; 1;<br />
                float T = 0.15f;<br />
                float IT = 1.0f &#8211; T;</p>
<p>                int[] integral = new int[size];<br />
                int[] threshold = new int[size];<br />
                int[] data = new int[size];<br />
                int bp = 0;<br />
                int aux = 0;<br />
                int[] out_buf = (int[])i_output.getBuffer();</p>
<p>                //Note: copying source image(im) to a vector to use the same code from Eugene<br />
                int index = 0;<br />
                for (int l = 0; l &lt; h; l++)<br />
                    for (int c = 0; c &lt; w; c++)<br />
                    {<br />
                        aux = ((in_buf[bp] &amp; 0xFF) + (in_buf[bp + 1] &amp; 0xFF) + (in_buf[bp + 2] &amp; 0xFF));<br />
                        bp += 4;</p>
<p>                        data[index++] = aux;<br />
                    }</p>
<p>                int i, j, diff;<br />
	            int x1, y1, x2, y2, ind1, ind2, ind3 = 0;<br />
	            int sum = 0, ind = 0;</p>
<p>	            while( ind &lt; size )<br />
	            {<br />
		            sum += data[ind] &amp; 0xFF;<br />
		            integral[ind] = sum;<br />
		            ind += w;<br />
	            }</p>
<p>                x1 = 0;<br />
                for (i = 1; i  S) x1 = i &#8211; S;<br />
                    diff = i &#8211; x1;<br />
                    for (j = 0; j &lt; h; ++j)<br />
                    {<br />
                        sum += data[ind] &amp; 0xFF;<br />
                        integral[ind] = integral[(int)(ind - 1)] + sum;<br />
                        ind += w;</p>
<p>                        if (i &lt; S2) continue;<br />
                        if (j &lt; S2) continue;</p>
<p>                        y1 = (j &lt; S ? 0 : j &#8211; S);</p>
<p>                        ind1 = y1 * w;<br />
                        ind2 = j * w;</p>
<p>                        if (((data[ind3] &amp; 0xFF) * (diff * (j &#8211; y1))) &lt; ((integral[(int)(ind2 + i)] &#8211; integral[(int)(ind1 + i)] &#8211; integral[(int)(ind2 + x1)] + integral[(int)(ind1 + x1)]) * IT))<br />
                        {<br />
                            threshold[ind3] = 0xFF;// 0&#215;00;<br />
                            out_buf[ind3] = 0xFF;// 0&#215;00;<br />
                        }<br />
                        else<br />
                        {<br />
                            threshold[ind3] = 0&#215;00;//0xFF;<br />
                            out_buf[ind3] = 0&#215;00;//0xFF;<br />
                        }<br />
                        ind3 += w;<br />
                    }<br />
                }</p>
<p>                y1 = 0;<br />
                for( j = 0; j &lt; h; ++j )<br />
                {<br />
                    i = 0;<br />
                    y2 = h &#8211; 1;<br />
                    if( j  S2 ) y1 = j &#8211; S2;<br />
                    ind1 = y1 * w;<br />
                    ind2 = y2 * w;<br />
                    diff = y2 &#8211; y1;</p>
<p>                    for( ; i &lt; w; ++i, ++ind )<br />
                    {</p>
<p>                        x1 = (i = w) x2 = w &#8211; 1;</p>
<p>                        if (((data[ind]&amp;0xFF)*((x2 &#8211; x1) * diff)) &lt; ((integral[(int)(ind2 + x2)] &#8211; integral[(int)(ind1 + x2)] &#8211; integral[(int)(ind2 + x1)] + integral[(int)(ind1 + x1)])*IT))<br />
                        {<br />
                            threshold[ind] = 0xFF;// 0&#215;00;<br />
                            out_buf[ind] = 0xFF;// 0&#215;00;<br />
                        } else<br />
                        {<br />
                            threshold[ind] = 0&#215;00;//0xFF;<br />
                            out_buf[ind] = 0&#215;00;//0xFF;<br />
                        }<br />
                    }<br />
                }</p>
<p>            }<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Willkopf</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-2951</link>
		<dc:creator>Willkopf</dc:creator>
		<pubDate>Fri, 26 Feb 2010 01:52:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-2951</guid>
		<description>Hi everyone. Great work Eugene! I was testing various Edge Detector algorithm for grayscale images, and this code was really useful.
With your permission, I´d like to post a C# code.

&lt;pre lang=&quot;c&quot; line=&quot;1&quot;&gt;
        public void IntegralThresh(ref int[,] im) //im -&gt; source/dest image
        {
            int h = im.GetLength(0);  //image height
            int w = im.GetLength(1);  //image width

            int size = w * h;
            int S = w &gt;&gt; 3;
            int S2 = S &gt;&gt; 1;
            float T = 0.15f;
            float IT = 1.0f - T;

            int[] integral = new int[size];
            int[] threshold = new int[size];
            int[] data = new int[size];

            //Note: copying source image(im) to a vector to use the same code from Eugene
            int index = 0;
            for (int l = 0; l &lt; h; l++)
                for (int c = 0; c &lt; w; c++)
                    data[index++] = im[l, c];


            int i, j, diff;
	        int x1, y1, x2, y2, ind1, ind2, ind3;
	        int sum = 0, ind = 0;
 
	        while( ind &lt; size )
	        {
		        sum += data[ind] &amp; 0xFF;
		        integral[ind] = sum;
		        ind += w;
	        }

           	x1 = 0;
	        for( i = 1; i  S ) x1 = i - S;
		        diff = i - x1;
		        for( j = 0; j &lt; h; ++j )
		        {
			        sum += data[ind] &amp; 0xFF;
			        integral[ind] = integral[(int)(ind-1)] + sum;
			        ind += w;
         
			        if(i &lt; S2) continue;
			        if(j &lt; S2) continue;
         
			        y1 = (j &lt; S ? 0 : j - S);
         
			        ind1 = y1 * w;
			        ind2 = j * w;
         
			        if (((data[ind3]&amp;0xFF)*(diff * (j - y1))) &lt; ((integral[(int)(ind2 + i)] - integral[(int)(ind1 + i)] - integral[(int)(ind2 + x1)] + integral[(int)(ind1 + x1)])*IT))
			        {
				        threshold[ind3] = 0x00;
			        } else 
                    {
				        threshold[ind3] = 0xFF;
			        }
			        ind3 += w;
		        }
	        }
 	        y1 = 0;
	        for( j = 0; j &lt; h; ++j )
	        {
		        i = 0;
		        y2 = h - 1;
		        if( j  S2 ) y1 = j - S2;
		        ind1 = y1 * w;
		        ind2 = y2 * w;
		        diff = y2 - y1;
		        for( ; i &lt; w; ++i, ++ind )
		        {
         
			        x1 = ( i = w) x2 = w - 1;
         
			        if (((data[ind]&amp;0xFF)*((x2 - x1) * diff)) &lt; ((integral[(int)(ind2 + x2)] - integral[(int)(ind1 + x2)] - integral[(int)(ind2 + x1)] + integral[(int)(ind1 + x1)])*IT))
			        {
				        threshold[ind] = 0x00;
			        } else 
                    {
				        threshold[ind] = 0xFF;
			        }
		        }
	        }

            //Note: Copying the vector to dest(im)
            index = 0;
            for (int l = 0; l &lt; h; l++)
                for (int c = 0; c &lt; w; c++)
                    im[l, c] = threshold[index++];
        }

&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hi everyone. Great work Eugene! I was testing various Edge Detector algorithm for grayscale images, and this code was really useful.<br />
With your permission, I´d like to post a C# code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">        public <span style="color: #993333;">void</span> IntegralThresh<span style="color: #009900;">&#40;</span>ref <span style="color: #993333;">int</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#93;</span> im<span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//im -&amp;gt; source/dest image</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #993333;">int</span> h <span style="color: #339933;">=</span> im.<span style="color: #202020;">GetLength</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//image height</span>
            <span style="color: #993333;">int</span> w <span style="color: #339933;">=</span> im.<span style="color: #202020;">GetLength</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//image width</span>
&nbsp;
            <span style="color: #993333;">int</span> size <span style="color: #339933;">=</span> w <span style="color: #339933;">*</span> h<span style="color: #339933;">;</span>
            <span style="color: #993333;">int</span> S <span style="color: #339933;">=</span> w <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000dd;">3</span><span style="color: #339933;">;</span>
            <span style="color: #993333;">int</span> S2 <span style="color: #339933;">=</span> S <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
            <span style="color: #993333;">float</span> T <span style="color: #339933;">=</span> <span style="color:#800080;">0.15f</span><span style="color: #339933;">;</span>
            <span style="color: #993333;">float</span> IT <span style="color: #339933;">=</span> <span style="color:#800080;">1.0f</span> <span style="color: #339933;">-</span> T<span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #993333;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> integral <span style="color: #339933;">=</span> new <span style="color: #993333;">int</span><span style="color: #009900;">&#91;</span>size<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #993333;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> threshold <span style="color: #339933;">=</span> new <span style="color: #993333;">int</span><span style="color: #009900;">&#91;</span>size<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #993333;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> data <span style="color: #339933;">=</span> new <span style="color: #993333;">int</span><span style="color: #009900;">&#91;</span>size<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">//Note: copying source image(im) to a vector to use the same code from Eugene</span>
            <span style="color: #993333;">int</span> index <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> l <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> l <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> h<span style="color: #339933;">;</span> l<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
                <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> c <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> c <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> w<span style="color: #339933;">;</span> c<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
                    data<span style="color: #009900;">&#91;</span>index<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> im<span style="color: #009900;">&#91;</span>l<span style="color: #339933;">,</span> c<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
            <span style="color: #993333;">int</span> i<span style="color: #339933;">,</span> j<span style="color: #339933;">,</span> diff<span style="color: #339933;">;</span>
	        <span style="color: #993333;">int</span> x1<span style="color: #339933;">,</span> y1<span style="color: #339933;">,</span> x2<span style="color: #339933;">,</span> y2<span style="color: #339933;">,</span> ind1<span style="color: #339933;">,</span> ind2<span style="color: #339933;">,</span> ind3<span style="color: #339933;">;</span>
	        <span style="color: #993333;">int</span> sum <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> ind <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
	        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span> ind <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> size <span style="color: #009900;">&#41;</span>
	        <span style="color: #009900;">&#123;</span>
		        sum <span style="color: #339933;">+=</span> data<span style="color: #009900;">&#91;</span>ind<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #208080;">0xFF</span><span style="color: #339933;">;</span>
		        integral<span style="color: #009900;">&#91;</span>ind<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> sum<span style="color: #339933;">;</span>
		        ind <span style="color: #339933;">+=</span> w<span style="color: #339933;">;</span>
	        <span style="color: #009900;">&#125;</span>
&nbsp;
           	x1 <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
	        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> i  S <span style="color: #009900;">&#41;</span> x1 <span style="color: #339933;">=</span> i <span style="color: #339933;">-</span> S<span style="color: #339933;">;</span>
		        diff <span style="color: #339933;">=</span> i <span style="color: #339933;">-</span> x1<span style="color: #339933;">;</span>
		        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span> j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> h<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j <span style="color: #009900;">&#41;</span>
		        <span style="color: #009900;">&#123;</span>
			        sum <span style="color: #339933;">+=</span> data<span style="color: #009900;">&#91;</span>ind<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #208080;">0xFF</span><span style="color: #339933;">;</span>
			        integral<span style="color: #009900;">&#91;</span>ind<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> integral<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>ind<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> sum<span style="color: #339933;">;</span>
			        ind <span style="color: #339933;">+=</span> w<span style="color: #339933;">;</span>
&nbsp;
			        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> S2<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
			        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> S2<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
&nbsp;
			        y1 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> S <span style="color: #339933;">?</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">:</span> j <span style="color: #339933;">-</span> S<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			        ind1 <span style="color: #339933;">=</span> y1 <span style="color: #339933;">*</span> w<span style="color: #339933;">;</span>
			        ind2 <span style="color: #339933;">=</span> j <span style="color: #339933;">*</span> w<span style="color: #339933;">;</span>
&nbsp;
			        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>ind3<span style="color: #009900;">&#93;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #208080;">0xFF</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>diff <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">-</span> y1<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>integral<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>ind2 <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> integral<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>ind1 <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> integral<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>ind2 <span style="color: #339933;">+</span> x1<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> integral<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>ind1 <span style="color: #339933;">+</span> x1<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>IT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			        <span style="color: #009900;">&#123;</span>
				        threshold<span style="color: #009900;">&#91;</span>ind3<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>
			        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> 
                    <span style="color: #009900;">&#123;</span>
				        threshold<span style="color: #009900;">&#91;</span>ind3<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0xFF</span><span style="color: #339933;">;</span>
			        <span style="color: #009900;">&#125;</span>
			        ind3 <span style="color: #339933;">+=</span> w<span style="color: #339933;">;</span>
		        <span style="color: #009900;">&#125;</span>
	        <span style="color: #009900;">&#125;</span>
 	        y1 <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
	        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span> j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> h<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j <span style="color: #009900;">&#41;</span>
	        <span style="color: #009900;">&#123;</span>
		        i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
		        y2 <span style="color: #339933;">=</span> h <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
		        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> j  S2 <span style="color: #009900;">&#41;</span> y1 <span style="color: #339933;">=</span> j <span style="color: #339933;">-</span> S2<span style="color: #339933;">;</span>
		        ind1 <span style="color: #339933;">=</span> y1 <span style="color: #339933;">*</span> w<span style="color: #339933;">;</span>
		        ind2 <span style="color: #339933;">=</span> y2 <span style="color: #339933;">*</span> w<span style="color: #339933;">;</span>
		        diff <span style="color: #339933;">=</span> y2 <span style="color: #339933;">-</span> y1<span style="color: #339933;">;</span>
		        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> w<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #339933;">,</span> <span style="color: #339933;">++</span>ind <span style="color: #009900;">&#41;</span>
		        <span style="color: #009900;">&#123;</span>
&nbsp;
			        x1 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> i <span style="color: #339933;">=</span> w<span style="color: #009900;">&#41;</span> x2 <span style="color: #339933;">=</span> w <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
&nbsp;
			        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>ind<span style="color: #009900;">&#93;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #208080;">0xFF</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>x2 <span style="color: #339933;">-</span> x1<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> diff<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>integral<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>ind2 <span style="color: #339933;">+</span> x2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> integral<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>ind1 <span style="color: #339933;">+</span> x2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> integral<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>ind2 <span style="color: #339933;">+</span> x1<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> integral<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>ind1 <span style="color: #339933;">+</span> x1<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>IT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			        <span style="color: #009900;">&#123;</span>
				        threshold<span style="color: #009900;">&#91;</span>ind<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>
			        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> 
                    <span style="color: #009900;">&#123;</span>
				        threshold<span style="color: #009900;">&#91;</span>ind<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0xFF</span><span style="color: #339933;">;</span>
			        <span style="color: #009900;">&#125;</span>
		        <span style="color: #009900;">&#125;</span>
	        <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">//Note: Copying the vector to dest(im)</span>
            index <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> l <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> l <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> h<span style="color: #339933;">;</span> l<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
                <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> c <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> c <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> w<span style="color: #339933;">;</span> c<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
                    im<span style="color: #009900;">&#91;</span>l<span style="color: #339933;">,</span> c<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> threshold<span style="color: #009900;">&#91;</span>index<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: イナヅマtvログ &#187; 気になるサイト, astatic notes @inspirit</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-2811</link>
		<dc:creator>イナヅマtvログ &#187; 気になるサイト, astatic notes @inspirit</dc:creator>
		<pubDate>Wed, 27 Jan 2010 08:35:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-2811</guid>
		<description>[...] 3Dなどの記事など面白い記事ばかり、なかでも Adaptive Thresholding using Integral Image [...]</description>
		<content:encoded><![CDATA[<p>[...] 3Dなどの記事など面白い記事ばかり、なかでも Adaptive Thresholding using Integral Image [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eugene</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-2800</link>
		<dc:creator>Eugene</dc:creator>
		<pubDate>Fri, 22 Jan 2010 15:57:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-2800</guid>
		<description>Hi! I guess you should update other variables to work with new size of the bitmap object. look carefully through the source and find what vars are connected to bitmap object properties.</description>
		<content:encoded><![CDATA[<p>Hi! I guess you should update other variables to work with new size of the bitmap object. look carefully through the source and find what vars are connected to bitmap object properties.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-2799</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Fri, 22 Jan 2010 15:41:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-2799</guid>
		<description>Hey there :) First of all, great work! It&#039;s been really useful for my work. I&#039;m having a problem however. I have a BitmapData containing the current video frame from the webcam. I apply the function you created and it works perfect. However, I don&#039;t want to perform the function on the entire image but only a smaller portion in the image. So i use copyPixels to store it into a new BitmapData object, then pass the new object into the function. However, the new BitmapData becomes black.

Is there something I am missing or should be doing? Thanks!</description>
		<content:encoded><![CDATA[<p>Hey there <img src='http://blog.inspirit.ru/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  First of all, great work! It&#8217;s been really useful for my work. I&#8217;m having a problem however. I have a BitmapData containing the current video frame from the webcam. I apply the function you created and it works perfect. However, I don&#8217;t want to perform the function on the entire image but only a smaller portion in the image. So i use copyPixels to store it into a new BitmapData object, then pass the new object into the function. However, the new BitmapData becomes black.</p>
<p>Is there something I am missing or should be doing? Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Playing with chroma key and thresholding in Flash (with Pixel Bender) &#124; Andy Li&#39;s Blog</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-2729</link>
		<dc:creator>Playing with chroma key and thresholding in Flash (with Pixel Bender) &#124; Andy Li&#39;s Blog</dc:creator>
		<pubDate>Thu, 10 Dec 2009 10:18:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-2729</guid>
		<description>[...] method should be more easily to incorporate with other filters developed for AR (like the very hot adaptive thresholding), but the second method can be more precise.  Finally I tried both [...]</description>
		<content:encoded><![CDATA[<p>[...] method should be more easily to incorporate with other filters developed for AR (like the very hot adaptive thresholding), but the second method can be more precise.  Finally I tried both [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashanth</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-2560</link>
		<dc:creator>Prashanth</dc:creator>
		<pubDate>Wed, 25 Nov 2009 09:45:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-2560</guid>
		<description>Hi, I am trying to port this code to C#, but I have a few doubts regarding certain lines of code. It would be helpful if you can explain the meaning to me.
1. How are you considering the pixels? As x,y or any other way?
2. var data:Vector. = bmp.getVector(bmp.rect); : what does this do?</description>
		<content:encoded><![CDATA[<p>Hi, I am trying to port this code to C#, but I have a few doubts regarding certain lines of code. It would be helpful if you can explain the meaning to me.<br />
1. How are you considering the pixels? As x,y or any other way?<br />
2. var data:Vector. = bmp.getVector(bmp.rect); : what does this do?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eugene</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-2458</link>
		<dc:creator>Eugene</dc:creator>
		<pubDate>Mon, 16 Nov 2009 14:12:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-2458</guid>
		<description>@Prashanth I think it is very easy to port it to C#. This is Flash Action Script version.</description>
		<content:encoded><![CDATA[<p>@Prashanth I think it is very easy to port it to C#. This is Flash Action Script version.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashanth</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-2457</link>
		<dc:creator>Prashanth</dc:creator>
		<pubDate>Mon, 16 Nov 2009 13:09:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-2457</guid>
		<description>I am sorry to ask, but what language is this? Is it possible to get an equivalent C# code</description>
		<content:encoded><![CDATA[<p>I am sorry to ask, but what language is this? Is it possible to get an equivalent C# code</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: VK</title>
		<link>http://blog.inspirit.ru/?p=322&#038;cpage=1#comment-1801</link>
		<dc:creator>VK</dc:creator>
		<pubDate>Thu, 13 Aug 2009 20:00:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.inspirit.ru/?p=322#comment-1801</guid>
		<description>я так понимаю, именно это позволит сделать AR более стабильной, да?</description>
		<content:encoded><![CDATA[<p>я так понимаю, именно это позволит сделать AR более стабильной, да?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
