DK Whit Papr Filtr Blit WP-397--v July
Abstract Filtr Blit Exampl This xampl dmonstrats how to implmnt custom imag procssing with iltrs using pixl shadrs to procss th imag. This tchniqu can b usd or a wid rang o intrsting iltring cts, such as blur, sharpn, and luminanc dg dtction. This discussion assums basic knowldg o graphics, and shadr programming. This xampl is implmntd using DirctX9.b and will run on all P/V. class hardwar. Bryan Dudash bdudash@nvidia.com NVIDIA Corporation 7 an Tomas Exprssway anta Clara, CA 955 WP-397-_v 7/3/
WP-397-_v 7/3/ Filtr Blit Introduction You can accomplish a wid array o intrsting iltring cts using a iltr krnl. A iltr krnl is a matrix o wights or sampls around th sourc pixl. A numbr o xtra sampls ar mad around ach sourc pixl, and th rsults o th sampls ar combind using th sampl wights. This is rpatd or ach sourc pixl. Th sourc UV is varid whn picking sampls. For xampl, considr th iltr krnl in Figur. It sampls our valus on diagonals rom th sourc pixl and avrags thm togthr vnly. This rsults in a blurrd vrsion o th sourc imag. Figur. impl Blur Box Filtr Thr is anothr pic o inormation to considr whn implmnting this iltr krnl. Th hardwar dos bilinar iltring whn rading ach sampl. Thus by varying th distanc ost in ach dirction or ach sampl, you can gt dirnt ctiv krnls. Figur shows th actual and ctiv sampls whn using a txl distanc o.5. Th rason or this bcoms clar whn you look at th quations or ach sampl. With ach diagonal qually avraging th our txls it touchs, and thn ach sampl bing avragd qually, you obtain th rsultant ctiv 9 sampl con iltr in Figur. c b d b a 3 i h h g d /6 / 8 / 3 / i g c a h d b P P
Filtr Blit Figur. impl Box Filtr and Ectiv Filtr Krnl ampls In Figur, th diagram on th lt shows th actual sampls as dind by th simpl box iltr. Th diagram on th right shows th ctiv iltr krnl obtaind whn using a.5 txl ost on th sampls. Othr Blur Filtrs A gnral quation or th actual iltring quation using th simpl box iltr with a varying sampl distanc is: P s s s a c g i b d h s By changing th sampl ost distanc to /3, you ctivly chang th wight o all 9 sampls, and gt th box iltr shown in Figur 3. Figur 3. Nin ampl Box Filtr Obtaind with a Txl Ost o /3 A 6 sampl iltr can b obtaind by xtnding th txl distanc vn urthr and placing ach sampl on th cornr o indpndnt sampls. In that cas, th bilinar hardwar will vnly iltr : or ach sampl, and th pixl shadr can combin thos sampls. WP-397-_v 3 7/3/
Filtr Blit Luminanc Edg Dtction Basics Th Luminanc Edg Dtct algorithm as implmntd to show 3 dirnt luminanc implmntations as indicatd in Figur blow.. Color to Luminanc Luminanc. Luminanc multi-sampl dg calculation LuminancnsitivDiagEdg 3. Luminanc multi-sampl dg calculation and blnding LuminancDiagEdg All th abov implmntations us a luminanc convrsion vctor to convrt a color valu to a luminanc valu. Th dg dtct calculation sampls th diagonals o th cntr, and thn calculats slops on thos diagonals. It multiplis th rsult by a larg numbr to mak th valus visibl, and outputs th rsult. Plas rr to th shadr or mor spciics. Figur. Luminanc Edg Dtction implmntations WP-397-_v 7/3/
Notic ALL NVIDIA DEIGN PECIFICATION, REFERENCE BOARD, FILE, DRAWING, DIAGNOTIC, LIT, AND OTHER DOCUMENT TOGETHER AND EPARATELY, MATERIAL ARE BEING PROVIDED A I." NVIDIA MAKE NO WARRANTIE, EXPREED, IMPLIED, TATUTORY, OR OTHERWIE WITH REPECT TO THE MATERIAL, AND EXPRELY DICLAIM ALL IMPLIED WARRANTIE OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNE FOR A PARTICULAR PURPOE. Inormation urnishd is blivd to b accurat and rliabl. Howvr, NVIDIA Corporation assums no rsponsibility or th consquncs o us o such inormation or or any inringmnt o patnts or othr rights o third partis that may rsult rom its us. No licns is grantd by implication or othrwis undr any patnt or patnt rights o NVIDIA Corporation. pciications mntiond in this publication ar subjct to chang without notic. This publication suprsds and rplacs all inormation prviously supplid. NVIDIA Corporation products ar not authorizd or us as critical componnts in li support dvics or systms without xprss writtn approval o NVIDIA Corporation. Tradmarks NVIDIA and th NVIDIA logo ar tradmarks or rgistrd tradmarks o NVIDIA Corporation in th Unitd tats and othr countris. Othr company and product nams may b tradmarks o th rspctiv companis with which thy ar associatd. Copyright NVIDIA Corporation. All rights rsrvd NVIDIA Corporation 7 an Tomas Exprssway anta Clara, CA 955 www.nvidia.com