Image Scaling Jackie Van Ryzin

Slides:



Advertisements
Similar presentations
5.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 5 – Drawing A Line.
Advertisements

Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Drawing Elementary Figures Dr. Eng. Farag Elnagahy.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Experiments and Variables
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
1 Transportation Model. 2 Basic Problem The basic idea in a transportation problem is that there are sites or sources of product that need to be shipped.
The Assembly Language Level
Ted Adelson’s checkerboard illusion. Motion illusion, rotating snakes.

Virtual Dart: An Augmented Reality Game on Mobile Device Supervisor: Professor Michael R. Lyu Prepared by: Lai Chung Sum Siu Ho Tung.
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
Complexity Analysis (Part I)
CS533 - Concepts of Operating Systems
ROBOTIC GUIDANCE Joe Stawicki. PROJECT DESCRIPTION  Teach a robot to guide a person to a predefined destination.  The robot must use a cam and a vision.
Systems of Linear Equations
Visual Studio: Custom debugger visualizers. Creating Debugger Visualizers with Visual Studio : Introduction Code debugging is one of the most important.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Fundamentals of GIS Lecture Materials by Austin Troy except where noted © 2008 Lecture 14: More Raster and Surface Analysis in Spatial Analyst Using.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
Interpolation, extrapolation, etc. Prof. Ramin Zabih
RESEARCH POSTER PRESENTATION DESIGN © m QUICK TIPS (--THIS SECTION DOES NOT PRINT-- ) This PowerPoint template requires.
Graphing Linear Equations
By: Joel Rodriguez.  International student from Mexico  Delicias, Chihuahua Mexico  Spanish  Sports and Music.
Microsoft Excel How to make a SPREADSHEET. Microsoft Excel IT is recommended that you have EXCEL running at the same time. You can try what you are reading.
Object Matching With Faces CS460 Project Presentation By Sam Buyarski.
ICS220 – Data Structures and Algorithms Lecture 10 Dr. Ken Cosh.
Scan Conversion. Also known as rasterization In our programs objects are represented symbolically –3D coordinates representing an object’s position –Attributes.
Dr. S.M. Malaek Assistant: M. Younesi
1 Decrease-and-Conquer Approach Lecture 06 ITS033 – Programming & Algorithms Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing.
Motoring a Web Cam By Kevin Papreck. Definition & Requirements I had to develop a two-axis web cam that can be controlled over the internet. Along with.
JRN 440 Adv. Online Journalism Resizing and resampling Monday, 2/6/12.
WEBCAS (WEBCAM BASED CLASSROOM ATTENDANCE SYSTEM)
Intelligent Scissors for Image Composition Anthony Dotterer 01/17/2006.
 A line segment in a scene is defined by the coordinate positions of the line end-points x y (2, 2) (7, 5)
Computer Organization and Assembly Language Bitwise Operators.
30/10/ Iteration Loops Do While (condition is true) … Loop.
CSC 211 Data Structures Lecture 13
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Fitting: The Hough transform
1 Project Management Example Solving Sudoku 2 What is Sudoku?  Sudoku is a game with 9 columns and 9 rows and 9 “boxes” composed of a 3 x 3 Grid  Numbers.
The Software Development Process
Joe Cohen Presentation Overview  Project definition and requirements  Solution process and explanation  Methodology.
10/15/02 (c) 2002 University of Wisconsin, CS559 Who Am I? Prof Stephen Chenney These notes will be online after the lecture – in fact they’re online already.
10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework.
Graphing Most people at one time or another during their careers will have to interpret data presented in graphical form. This means of presenting.
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Signaling on the CCR Tyler Raulin. Overview of Signals Rules: – Red Light There is a train in the next section of track The turnout is not turned correctly.
OBJECT TRACKING USING PARTICLE FILTERS. Table of Contents Tracking Tracking Tracking as a probabilistic inference problem Tracking as a probabilistic.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Computer/Human Interaction Spring 2013 Northeastern University1 Name of Interface Tagline if you have one (80 chars max, including spaces) Team member.
Image hole-filling. Agenda Project 2: Will be up tomorrow Due in 2 weeks Fourier – finish up Hole-filling (texture synthesis) Image blending.
: Chapter 5: Image Filtering 1 Montri Karnjanadecha ac.th/~montri Image Processing.
Image Interpolator Supervisor By: Dr. Rajeev Srivastava Prashant Bhutani Associate Professor CSE, IIT-BHU.
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
John Rappel. Description  Demonstrate advanced control of the iRobot Create  Use light sensors to guide the robot to a light source  Read bump sensors.
Rotoscoping Senior Capstone Project | Ted Trisco
Presented by Yuting Liu
CSC391/691 Intro to OpenCV Dr. Rongzhong Li Fall 2016
Systems of Linear Equations
Decrease-and-Conquer Approach
Prepared by Vince Zaccone
Image Processing, Lecture #8
Do While (condition is true) … Loop
Image Processing, Lecture #8
Getting serious about “going fast” on the TigerSHARC
Presentation transcript:

Image Scaling Jackie Van Ryzin

Outline Project Description –Definition & Requirements –Solutions (what I did) –Exceptions (what I didn’t get to) –Methodology (how I did it) Demonstration – Zooming fun! Learning & Development Process –Strategies (what works for me) –Knowledge (useful CS concepts) –Extensions (where to from here) –Advice (for those yet to come) Q & A

Project Description Develop algorithms for real-time scaling that maintains quality Study and implement smooth Bresenham nearest neighbor interpolation method Look at ways to improve these methods Develop new algorithms or alter existing Implement a user interface that would allow someone to zoom in and out as they watch a streaming video

Overall Plan Read, research, understand existing algorithms Implement those algorithms using general arrays Create program to read and alter images Combine image program and algorithms Develop interface to test and compare algorithms and variations of existing one Alter programs & interface to scale real-time streaming video in addition to still images

In the beginning… Thiadmer Riemersma was unhappy with: –Quality of fast image scaling algorithms –Slow processing for high quality scaling routines He developed smooth Bresenham algorithm (Dr. Dobb’s Journal, May 2002) Used concept of Bresenham’s line algorithm to scale a horizontal line of pixels

Background in Bresenham Determine which points of an n-dimensional grid to plot to best approximate a straight line between two given points (x 0,y 0 ) and (x 1,y 1 ) For each x between x 0 and x 1, choose row y that most nearly matches fcn value to plot pixel (x,y)

To determine y General line formula is Know column x so solve for row y as Can pre-calculate constant Since slope between 0 & 1 by assumption, after rounding we either use same y or add 1 to it

Tracking Error User error value to track difference between current y value and exact y value for current x As increment x++, increase error by slope When error > 0.5, line is closer to next y value rather than current/previous –y++ and error--

Bresenham for Images Pixels are picked up from discrete positions in source image and placed at discrete locations in the destination image Nearest neighbor sampling –Magnifying: pixels duplicated –Minifying: pixels dropped –Both leave artifacts in destination image More accurate sampling requires reading pixels from fractional positions in source image Techniques exist that incorporate weighted averages – computation-intensive

A “Lightweight” Alternative Compromise between linear interpolation & coarse Bresenham scaling Destination pixel set to: –Value of closest source pixel –Unweighted average of neighbors –Based on proximity to source pixel Original 150% 75%

Smooth Bresenham (cont’d) Merit: –Standard (unweighted) averages = simpler calculations –Increased performance speed – important for real- time applications –Dropped pixels & excessive “jaggies” of fast nearest- neighbor techniques (such as coarse Bresenham) are absent or kept to a minimum Adjust this algorithm for 2D images –Nested for loops –Call horizontal line scaling algorithm –Average scaled lines with each other

How we use this… b (0,0) g (0,0) r (0,0) b (1,0) g (1,0) r (1,0) b (2,0) g (2,0) r (2,0) : : b (0,1) g (0,1) r (0,1) b (1,1) g (1,1) r (1,1) : : b (width-1,height-1) g (width-1,height-1) r (width-1,height-1) Use CV’s split fcn to get 3 single-channel images from a 3-channel image Run algorithm on each before remerging with CV’s merge fcn CAREFUL with averaging! OpenCV Platform Images in IplImage format which has char* pointing to data Data stored linearly as bytes as shown

Zooming! At first could capture keys (used 1 & 2) with cvWaitKey for user to scale up or down Discovered cvTrackBar –Attaches nicely to window –Auto updates the variable (scale factor) –Very user-friendly & visually appealing!

Analysis First scale image using Bresenham, then “undo” the scaling by using Bresenham on scaled image to get back to original size Compare with original image (calculate average difference between pixels of original and “un-scaled” images) Do same with cvResize functions & compare results

I Wish I Could/Would Have... Been better able to convert bytes to ints and back –Would have condensed processing time by calling algorithm only once (on 3-channel image rather than separately on 3 1-channel images) Been able to implement more alterations to the algorithm for comparison and analysis Looked into MIP mapping as mentioned in DDJ –Quick scaling by factor of 2 Used actual calculations to determine speed rather than simply visual

Methods Some mini-lectures/discussions with Dr. Pankratz & Dr. McVey in beginning to understand basic algorithm Test algorithms on arrays of ints first! (it was a while before I tried images) Tried using VB at first because Professor Blahnik provided code for reading from a webcam –Converting algorithm into VB (pointers) –DLL to leave it in C code –Picture box didn’t resize when image did

Methods (cont’d) OpenCV –Started with sample program from developers –Strip it down to minimum with John’s help –Add features and functions in baby steps Always had two versions –Still images using LoadImage –Webcam using Capture Wrote functions in small test program to run on arrays of ints before adding to interfaces

Let’s Scale! Real-time scrolling from webcam –HALLELUJAH!\scroll_webcam\scroll_webcam.dswHALLELUJAH!\scroll_webcam\scroll_webcam.dsw Compare with CV resizing using still image –HALLELUJAH!\diff_cv\diff_cv.dswHALLELUJAH!\diff_cv\diff_cv.dsw How well does it “undo” the scaling? –HALLELUJAH!\rescale_cmp\rescale_cmp.dswHALLELUJAH!\rescale_cmp\rescale_cmp.dsw Does a different threshold matter? –HALLELUJAH!\cmp_threshold\cmp_threshold.dswHALLELUJAH!\cmp_threshold\cmp_threshold.dsw

Where did this stuff come from? Dr. Dobb’s Journal OpenCV manual Dr. Pankratz & Dr. McVey Forums and online tutorials for OpenCV Practice, experimenting, trial-and-error John, Ted, Ryan P

Important CS Concepts Data Structures –Arrays, pointers, structures, chars vs. unsigned chars! –Dynamic memory allocation & de-allocation Machine Org. & Assembly Language –Fast calculations for dividing & masking Programming Languages –Designing abstractly without a language All classes –General learning, experimenting, researching techniques

Where to From Here? Be able to convert to array of ints & back to reduce calls to scaling algorithm Test & compare speed using actual clock calculations Find a better mathematical/computational method for comparing how “nice” a picture looks scaled Alter algorithm in some way to improve quality and/or speed Investigate MIP mapping and using a combination of MIP & Bresenham

For Those Who Follow Meet with DCP and other profs OFTEN and right away Ask questions of anyone and everyone –Someone may have a unique solution you wouldn’t think of –Could make you discover a solution with a simple comment about how chars in C aren’t fun When you get stuck, admit it and ask for help Write your journal! It keeps you accountable and encourages progress. Paper can be useful! Draw images, diagrams, etc. It helps to see it before you program it Baby steps…starting small is easier, and every little milestone is rewarding. It also makes testing & debugging easier.

Q & A Thanks to Dr. Pankratz and Dr. McVey for the guidance and ideas! Thank you to classmates for ideas, answers, and suggestions.