## Re: [Algorithms] Computing row means of a texture

 Re: [Algorithms] Computing row means of a texture From: Adrian Bentley - 2005-05-30 17:52:39 ```You can actually make bilinear adding do all the adds for you if you combine the two above mentioned algorithms: for ceil( log n ) passes pixel[i] =3D 0.5*pixel[2i] + 0.5*pixel[2i+1] //the bilinear filter at coord 2i + 0.5 And that's it. Each pass will use the previously averaged values from the previous ones. All you have to do is make sure that if you sample off the boundary of the texture you get no contribution (i.e. border color of black, 0 alpha). You could also optimize by utilizing things like alpha testing and vertex interpolation for 2i + 0.5 coordinate. I don't think there's a particularly good way to fix the "demeaning" alg. The question is why would you want to demean texture A if you already have texture D? Some numerical test? Adrian On 5/30/05, Tony Cox wrote: > And you can coerce the texture sampler to do half of the adds for you by > using bilinear filtering. >=20 > A better question is: why wouldn't you just do this once, offline? Or is > this for an offline tool and you're just trying to speed it up? >=20 > - Tony >=20 > -----Original Message----- > From: gdalgorithms-list-admin@... > [mailto:gdalgorithms-list-admin@...] On Behalf Of > Anders Nilsson > Sent: Monday, May 30, 2005 7:29 AM > To: gdalgorithms-list@... > Subject: Re: [Algorithms] Computing row means of a texture >=20 > Hm could this be faster: Add the right half of the texture to the left > half of the texture (so added[0]=3Dpixel[0]+pixel[128] for a pixel with > 256 in width). Then recurse for the left 128 pixels. Pretty soon you > should have the row-sums in one column (needs to be float or something > to not overflow though, but it seems your texture D should overflow > with your algorithm as well so I've guess you've got that covered!). > For a row-width of 2^k you need k divisions and they are dependant, ie > you need to add from what you are creating. They size of the added > texture however halfs each time. >=20 > Just a thought. >=20 > Anders Nilsson >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by Yahoo. > Introducing Yahoo! Search Developer Network - Create apps using Yahoo! > Search APIs Find out how you can build Yahoo! directly into your own > Applications - visit http://developer.yahoo.net/?froffad-ysdn-ostg-q22005 > _______________________________________________ > GDAlgorithms-list mailing list > GDAlgorithms-list@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_ida88 > ```

 RE: [Algorithms] Computing row means of a texture From: Tony Cox - 2005-05-30 15:46:40 ```And you can coerce the texture sampler to do half of the adds for you by using bilinear filtering. A better question is: why wouldn't you just do this once, offline? Or is this for an offline tool and you're just trying to speed it up? - Tony -----Original Message----- From: gdalgorithms-list-admin@... [mailto:gdalgorithms-list-admin@...] On Behalf Of Anders Nilsson Sent: Monday, May 30, 2005 7:29 AM To: gdalgorithms-list@... Subject: Re: [Algorithms] Computing row means of a texture Hm could this be faster: Add the right half of the texture to the left half of the texture (so added[0]=3Dpixel[0]+pixel[128] for a pixel with 256 in width). Then recurse for the left 128 pixels. Pretty soon you should have the row-sums in one column (needs to be float or something to not overflow though, but it seems your texture D should overflow with your algorithm as well so I've guess you've got that covered!). For a row-width of 2^k you need k divisions and they are dependant, ie you need to add from what you are creating. They size of the added texture however halfs each time. Just a thought. Anders Nilsson ```
 Re: [Algorithms] Computing row means of a texture From: Adrian Bentley - 2005-05-30 17:52:39 ```You can actually make bilinear adding do all the adds for you if you combine the two above mentioned algorithms: for ceil( log n ) passes pixel[i] =3D 0.5*pixel[2i] + 0.5*pixel[2i+1] //the bilinear filter at coord 2i + 0.5 And that's it. Each pass will use the previously averaged values from the previous ones. All you have to do is make sure that if you sample off the boundary of the texture you get no contribution (i.e. border color of black, 0 alpha). You could also optimize by utilizing things like alpha testing and vertex interpolation for 2i + 0.5 coordinate. I don't think there's a particularly good way to fix the "demeaning" alg. The question is why would you want to demean texture A if you already have texture D? Some numerical test? Adrian On 5/30/05, Tony Cox wrote: > And you can coerce the texture sampler to do half of the adds for you by > using bilinear filtering. >=20 > A better question is: why wouldn't you just do this once, offline? Or is > this for an offline tool and you're just trying to speed it up? >=20 > - Tony >=20 > -----Original Message----- > From: gdalgorithms-list-admin@... > [mailto:gdalgorithms-list-admin@...] On Behalf Of > Anders Nilsson > Sent: Monday, May 30, 2005 7:29 AM > To: gdalgorithms-list@... > Subject: Re: [Algorithms] Computing row means of a texture >=20 > Hm could this be faster: Add the right half of the texture to the left > half of the texture (so added[0]=3Dpixel[0]+pixel[128] for a pixel with > 256 in width). Then recurse for the left 128 pixels. Pretty soon you > should have the row-sums in one column (needs to be float or something > to not overflow though, but it seems your texture D should overflow > with your algorithm as well so I've guess you've got that covered!). > For a row-width of 2^k you need k divisions and they are dependant, ie > you need to add from what you are creating. They size of the added > texture however halfs each time. >=20 > Just a thought. >=20 > Anders Nilsson >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by Yahoo. > Introducing Yahoo! Search Developer Network - Create apps using Yahoo! > Search APIs Find out how you can build Yahoo! directly into your own > Applications - visit http://developer.yahoo.net/?froffad-ysdn-ostg-q22005 > _______________________________________________ > GDAlgorithms-list mailing list > GDAlgorithms-list@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_ida88 > ```
 RE: [Algorithms] Computing row means of a texture From: Chris Haarmeijer - 2005-05-30 18:34:57 ```Ah, sounds cool. I am going to test it tomorrow and see what it does to performance, should be better than current performance. The thing with demeaning is that I have an input frame from a video camera and want to remove the mean value of each row from each pixel to get a de-meaned texture. This is input for another filter pass. Chris --- Keep IT Simple Software P: P.O.Box 548, 7500 AM Enschede, The Netherlands W: http://www.keepitsimple.nl E: mailto:info@... T: +31 53 4356687 > -----Original Message----- > From: gdalgorithms-list-admin@... > [mailto:gdalgorithms-list-admin@...] On > Behalf Of Adrian Bentley > Sent: maandag 30 mei 2005 19:53 > To: gdalgorithms-list@... > Subject: Re: [Algorithms] Computing row means of a texture > > You can actually make bilinear adding do all the adds for you > if you combine the two above mentioned algorithms: > > for ceil( log n ) passes > pixel[i] = 0.5*pixel[2i] + 0.5*pixel[2i+1] //the bilinear > filter at coord 2i + 0.5 > > And that's it. Each pass will use the previously averaged > values from the previous ones. All you have to do is make > sure that if you sample off the boundary of the texture you > get no contribution (i.e. border color of black, 0 alpha). > You could also optimize by utilizing things like alpha > testing and vertex interpolation for 2i + 0.5 coordinate. > > I don't think there's a particularly good way to fix the "demeaning" > alg. The question is why would you want to demean texture A > if you already have texture D? Some numerical test? > > Adrian > > On 5/30/05, Tony Cox wrote: > > And you can coerce the texture sampler to do half of the > adds for you > > by using bilinear filtering. > > > > A better question is: why wouldn't you just do this once, > offline? Or > > is this for an offline tool and you're just trying to speed it up? > > > > - Tony > > > > -----Original Message----- > > From: gdalgorithms-list-admin@... > > [mailto:gdalgorithms-list-admin@...] On Behalf Of > > Anders Nilsson > > Sent: Monday, May 30, 2005 7:29 AM > > To: gdalgorithms-list@... > > Subject: Re: [Algorithms] Computing row means of a texture > > > > Hm could this be faster: Add the right half of the texture > to the left > > half of the texture (so added[0]=pixel[0]+pixel[128] for a > pixel with > > 256 in width). Then recurse for the left 128 pixels. Pretty > soon you > > should have the row-sums in one column (needs to be float > or something > > to not overflow though, but it seems your texture D should overflow > > with your algorithm as well so I've guess you've got that covered!). > > For a row-width of 2^k you need k divisions and they are > dependant, ie > > you need to add from what you are creating. They size of the added > > texture however halfs each time. > > > > Just a thought. > > > > Anders Nilsson > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by Yahoo. > > Introducing Yahoo! Search Developer Network - Create apps > using Yahoo! > > Search APIs Find out how you can build Yahoo! directly into > your own > > Applications - visit > > http://developer.yahoo.net/?froffad-ysdn-ostg-q22005 > > _______________________________________________ > > GDAlgorithms-list mailing list > > GDAlgorithms-list@... > > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > > Archives: > > http://sourceforge.net/mailarchive/forum.php?forum_ida88 > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Yahoo. > Introducing Yahoo! Search Developer Network - Create apps using Yahoo! > Search APIs Find out how you can build Yahoo! directly into > your own Applications - visit > http://developer.yahoo.net/?fr________________________________ > _______________ > GDAlgorithms-list mailing list > GDAlgorithms-list@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_ida88 ```
 RE: [Algorithms] Computing row means of a texture From: Chris Haarmeijer - 2005-05-30 18:32:53 ```Hi Tony, Offline is not possible. The algorithm is going to be used in realtime video analysis.... :( That's why I need it to be fast. Chris --- Keep IT Simple Software P: P.O.Box 548, 7500 AM Enschede, The Netherlands W: http://www.keepitsimple.nl E: mailto:info@... T: +31 53 4356687 > -----Original Message----- > From: gdalgorithms-list-admin@... > [mailto:gdalgorithms-list-admin@...] On > Behalf Of Tony Cox > Sent: maandag 30 mei 2005 17:47 > To: gdalgorithms-list@... > Subject: RE: [Algorithms] Computing row means of a texture > > And you can coerce the texture sampler to do half of the adds > for you by using bilinear filtering. > > A better question is: why wouldn't you just do this once, > offline? Or is this for an offline tool and you're just > trying to speed it up? > > - Tony > > -----Original Message----- > From: gdalgorithms-list-admin@... > [mailto:gdalgorithms-list-admin@...] On > Behalf Of Anders Nilsson > Sent: Monday, May 30, 2005 7:29 AM > To: gdalgorithms-list@... > Subject: Re: [Algorithms] Computing row means of a texture > > Hm could this be faster: Add the right half of the texture to > the left half of the texture (so added[0]=pixel[0]+pixel[128] > for a pixel with > 256 in width). Then recurse for the left 128 pixels. Pretty > soon you should have the row-sums in one column (needs to be > float or something to not overflow though, but it seems your > texture D should overflow with your algorithm as well so I've > guess you've got that covered!). > For a row-width of 2^k you need k divisions and they are > dependant, ie you need to add from what you are creating. > They size of the added texture however halfs each time. > > Just a thought. > > Anders Nilsson > > > ------------------------------------------------------- > This SF.Net email is sponsored by Yahoo. > Introducing Yahoo! Search Developer Network - Create apps using Yahoo! > Search APIs Find out how you can build Yahoo! directly into > your own Applications - visit > http://developer.yahoo.net/?fr________________________________ > _______________ > GDAlgorithms-list mailing list > GDAlgorithms-list@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_ida88 ```