Image Filtering Advanced

Slides:



Advertisements
Similar presentations
POST-PROCESSING SET09115 Intro Graphics Programming.
Advertisements

COMPUTER GRAPHICS SOFTWARE.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Lecture 5 Rendering lines 1.Steps of line rendering 2.Scan-conversion for line segments 3.A1 tutorial CP411 Computer Graphics Fall 2007 Wilfrid Laurier.
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
Graphics Pipeline.
Damon Rocco.  Tessellation: The filling of a plane with polygons such that there is no overlap or gap.  In computer graphics objects are rendered as.
Image Filtering Advanced Image Filtering Advanced Image filtering with GDI and DX HW accelerations.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE408, University of Illinois, Urbana-Champaign 1 Programming Massively Parallel Processors Chapter.
Shading Languages By Markus Kummerer. Markus Kummerer 2 / 19 State of the Art Shading.
Direct Show Introduction Direct Show Introduction to DirectShow And, I wish, a discussion.
Klas Skogmar, Lund Institute of Technology Real-time Video Effects Using Programmable Graphics Cards Master of Science Thesis Klas Skogmar
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
COMP 175: Computer Graphics March 24, 2015
Topics Introduction Hardware and Software How Computers Store Data
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
4.7. I NSTANCING Introduction to geometry instancing.
Object Oriented Programming Graphics and Multimedia Dr. Mike Spann
OpenGL Shading Language (Advanced Computer Graphics) Ernest Tatum.
COMP 261 Lecture 16 3D Rendering. input: set of polygons viewing direction direction of light source(s) size of window. output: an image Actions rotate.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
Interactive Time-Dependent Tone Mapping Using Programmable Graphics Hardware Nolan GoodnightGreg HumphreysCliff WoolleyRui Wang University of Virginia.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Week 2 - Friday.  What did we talk about last time?  Graphics rendering pipeline  Geometry Stage.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics SEN Introduction to OpenGL Graphics Applications.
Computer Graphics I, Fall 2008 Introduction to Computer Graphics.
1 Graphics CSCI 343, Fall 2015 Lecture 4 More on WebGL.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic Light Source.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
2009 GRAPHICS : PROJECT 1 BASED ON DX9 BASICS. Documented by Dongjoon Kim SNU CS Ph.D Course Student Contact : NOTE.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
Our Graphics Environment Landscape Rendering. Hardware  CPU  Modern CPUs are multicore processors  User programs can run at the same time as other.
How to use a Pixel Shader CMT3317. Pixel shaders There is NO requirement to use a pixel shader for the coursework though you can if you want to You should.
Graphics Pipeline Bringing it all together. Implementation The goal of computer graphics is to take the data out of computer memory and put it up on the.
From VIC (VRVS) to ViEVO (EVO) 3 years of experiences with developing of video application VIC for VRVS allowed us to develop a new video application.
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
- Introduction - Graphics Pipeline
Week 2 - Monday CS361.
Topics Introduction Hardware and Software How Computers Store Data
Week 2 - Friday CS361.
Real-Time Rendering Buffers in OpenGL 3.3
Chapter 10 Computer Graphics
Graphics Processing Unit
Deferred Lighting.
3D Graphics Rendering PPT By Ricardo Veguilla.
From Turing Machine to Global Illumination
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Michael Tanaya , Hua ming Chen
Introduction to Computer Graphics with WebGL
Graphics Processing Unit
Topics Introduction Hardware and Software How Computers Store Data
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Introduction to geometry instancing
Introduction to Computer Graphics
Introduction to Computer Graphics
RADEON™ 9700 Architecture and 3D Performance
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
03 | Creating, Texturing and Moving Objects
Presentation transcript:

Image Filtering Advanced Image filtering with GDI and DX HW accelerations

An introduction : domain terms Bitmap (let’s assume Bitmap == GDI+ Bitmap) System memory portion containing Pixel as color’s byte DX Surface System or Video memory portion representing a bitmap Texture Mainly Video memory portion containing a bitmap that will be mapped onto a polygon Image Filtering Advanced

Enhanced Image Filter Library What does a filter do? What is a filter? What is a filter chain? A filter is a function from image to image, A filter chain is a functional composition so, it’s a function again. Image Filtering Advanced

Image Filtering Advanced The speed part 1 : unsafe protected override void filter(Bitmap b, Bitmap[] temp) { BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); int stride = bmData.Stride; System.IntPtr Scan0 = bmData.Scan0; unsafe { byte * p = (byte *)(void *)Scan0; int nOffset = stride - b.Width*3; int nWidth = b.Width * 3; for(int y=0;y<b.Height;++y) { for(int x=0; x < nWidth; ++x ) { p[0] = (byte)(255-p[0]); ++p; } p += nOffset; b.UnlockBits(bmData); This way is faster than accessing pixels through the GetPixel GDI function Image Filtering Advanced

Image Filtering Advanced Library structure Image Filtering Advanced

The key for success : the filter base class design Create all the temporary Images before your filter chain goes with its work! [Serializable] public abstract class Filter { private Filter next; protected Filter(Filter f) { next = f; } protected Filter() { next = null; protected abstract void filter(Bitmap b, Bitmap[] temp); protected abstract int NumCopies { get; } public BaseConf GetConfig(){ return new BaseConf(); public void Apply(Bitmap b) { int n = this.NumCopies; Filter p = next; while (p != null) { n = Math.Max(n, p.NumCopies); p = p.next; } Bitmap[] tmp = new Bitmap[n]; for (int i = 0; i < n; i++) tmp[i] = new Bitmap(b.Width, b.Height); p = this; do { p.filter(b, tmp); } while (p != null); foreach (Bitmap bm in tmp) { bm.Dispose(); Image Filtering Advanced

Image Filtering Advanced The speed part 2 : ngen Let’s get native! Run the ngen tool on the filter library assembly to get it compiled once for all. Image Filtering Advanced

Image => plane => polygon The speed part 3 : Get HW! A little trick to achieve the real magic Let’s pretend : Remember you gain speed but you get also limitations! Image => plane => polygon Image Filtering Advanced

Image Filtering Advanced DX Structure We can use the HW 3D acceleration to boost 2D image filtering using the Programmable Pixel Shader Image Filtering Advanced

Image Filtering Advanced HSL with DX 9 Cross Hardware language! Can contains multiple techniques and passes! Exposes a large number of common function as lerp and so on Image Filtering Advanced

Image Filtering Advanced HSL Stupid Example float4 Light(float3 LightDir : TEXCOORD1, uniform float4 LightColor, float2 texcrd : TEXCOORD0, uniform sampler samp) : COLOR { float3 Normal = tex2D(samp,texcrd); return dot((Normal*2 - 1), LightDir)*LightColor; } Image Filtering Advanced

Image Filtering Advanced The Idea Create a DX device on a control Create a 3D plane Put the image you want to process on the plane as a texture Use the Pixel Shader Program to make the GPU works for you Use the Control Graphics class to save your processed image. Image Filtering Advanced

A simple but real FX example Image Filtering Advanced

Image Filtering Advanced And the cons? Here we are . . . You can use only power of 2 sized bitmap The display size is the maximum size for the output image . . . But you get a common PC running as it’s got a real expensive (and dedicated) DSP! Image Filtering Advanced

Image Filtering Advanced The Direct Show way DShow use a graph from sources to renderes (audio and video) Along the graph you can have filters 2 approaches In place transformations Not in place transformations Only C++ (the unmanaged one!) Image Filtering Advanced

CTransformFilter::Transform This filter uses the CTransformInputPin class for its input pin, and the CTransformOutputPin class for its output pin. Use this base class if you want to try filter and then pass it through the graph Beware of memory leak! Image Filtering Advanced

Image Filtering Advanced Example of transform HRESULT CRleFilter::Transform(IMediaSample *pSource, IMediaSample *pDest) { // Get pointers to the underlying buffers. BYTE *pBufferIn, *pBufferOut; hr = pSource->GetPointer(&pBufferIn); if (FAILED(hr)) { return hr; } hr = pDest->GetPointer(&pBufferOut); // Process the data. DWORD cbDest = EncodeFrame(pBufferIn, pBufferOut); KASSERT((long)cbDest <= pDest->GetSize()); pDest->SetActualDataLength(cbDest); pDest->SetSyncPoint(TRUE); return S_OK; Image Filtering Advanced

CTransInPlaceFilter::Transform Transform the input sample in place Use it for real real-time processing What do you want more? Image Filtering Advanced

The Frame Dispatcer Class If you want to apply filter to a real time camera or to an avi file in C# there’s an utility from the Medialab (university of Pisa) that can help you to get your frames inside a managed application! Image Filtering Advanced

Image Filtering Advanced References Enhanced Filter Library and Frame Dispatcer http://dotnet.di.unipi.it Image Filtering Advanced