Images and 2D Graphics COMP

Slides:



Advertisements
Similar presentations
Lecture 7 2D Transformation. What is a transformation? Exactly what it says - an operation that transforms or changes a shape (line, shape, drawing etc.)
Advertisements

Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
Computational Biology, Part 23 Biological Imaging II Robert F. Murphy Copyright  1996, 1999, All rights reserved.
Transforming images to images
Advanced Computer Graphics CSE 190 [Spring 2015], Lecture 4 Ravi Ramamoorthi
Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce.
Image Filtering CS485/685 Computer Vision Prof. George Bebis.
7. Neighbourhood operations A single pixel considered in isolation conveys information on the intensity and colour at a single location in an image, but.
Computer Vision Introduction to Image formats, reading and writing images, and image environments Image filtering.
Programming Assignment 1 CS302 Data Structures. Goals Improve your skills with manipulating dynamic arrays. Improve your understanding of constructors,
Course Website: Computer Graphics 3: 2D Transformations.
April Geometric Transformations for Computer Graphics Shmuel Wimer Bar Ilan Univ., School of Engineering.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
CS448f: Image Processing For Photography and Vision Wavelets Continued.
CS559: Computer Graphics Lecture 3: Digital Image Representation Li Zhang Spring 2008.
Image Preprocessing: Geometric Correction Image Preprocessing: Geometric Correction Jensen, 2003 John R. Jensen Department of Geography University of South.
Basic Image Manipulation Raed S. Rasheed Agenda Region of Interest (ROI) Basic geometric manipulation. – Enlarge – shrink – Reflection Arithmetic.
Computational Biology, Part 23 Biological Imaging III G. Steven Vanni Robert F. Murphy Copyright  1998, All rights reserved.
EE663 Image Processing Dr. Samir H. Abdul-Jauwad Electrical Engineering Department King Fahd University of Petroleum & Minerals.
Lecture 03 Area Based Image Processing Lecture 03 Area Based Image Processing Mata kuliah: T Computer Vision Tahun: 2010.
infinity-project.org Engineering education for today’s classroom 2 Outline How Can We Use Digital Images? A Digital Image is a Matrix Manipulating Images.
GEOMETRIC OPERATIONS. Transformations and directions Affine (linear) transformations Translation, rotation and scaling Non linear (Warping transformations)
CSC508 Convolution Operators. CSC508 Convolution Arguably the most fundamental operation of computer vision It’s a neighborhood operator –Similar to the.
Image Transforms Transforming images to images. Classification of Image Transforms Point transforms –modify individual pixels –modify pixels’ locations.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Images and 2D Graphics COMP # 17.
Image Processing 고려대학교 컴퓨터 그래픽스 연구실 cgvr.korea.ac.kr.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
Computer Graphics Matrices
Instructor: Mircea Nicolescu Lecture 5 CS 485 / 685 Computer Vision.
Non-linear filtering Example: Median filter Replaces pixel value by median value over neighborhood Generates no new gray levels.
Image Processing Intro2CS – week 6 1. Image Processing Many devices now have cameras on them Lots of image data recorded for computers to process. But.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae & david streader, VUW Images and 2D Graphics COMP.
Filters– Chapter 6. Filter Difference between a Filter and a Point Operation is that a Filter utilizes a neighborhood of pixels from the input image to.
Geometric Transformations for Computer Graphics
Geometric Transformations for Computer Graphics
CMSC5711 Image processing and computer vision
Computer Graphics 2D Transformations
Modeling Transformations
Transforms.
Computer Graphics 3: 2D Transformations
Computer Graphics Transformations.
Computer Graphics 3: 2D Transformations
CSE 455 HW 1 Notes.
Chapter 5 2-D Transformations.
Clipping Polygon Clipping Polygon : Area primitive
Computer Graphics Transformations.
Image Warping (Geometric Transforms)
CMSC5711 Revision (1) (v.7.b) revised
Histogram Histogram is a graph that shows frequency of anything. Histograms usually have bars that represent frequency of occuring of data. Histogram has.
CMSC5711 Revision 3 CMSC5711 revision 3 ver.x67.8c.
COMP 175: Computer Graphics February 9, 2016
CMSC5711 Image processing and computer vision
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
EE/CSE 576 HW 1 Notes.
Chapters 5/4 part2 understanding transformations working with matrices
More Image Manipulation
9th Lecture - Image Filters
Image Processing, Lecture #8
Geometric Transformations for Computer Graphics
(c) 2002 University of Wisconsin, CS 559
Image Processing, Lecture #8
Resolution Resolution: 6 x 4.
EE/CSE 576 HW 1 Notes.
Geometric Objects and Transformations (II)
Lecture 8: 3D Transforms Li Zhang Spring 2008
Image Processing 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
ECE/CSE 576 HW 1 Notes.
Graphics Laboratory Korea University
Translation in Homogeneous Coordinates
Image Processing 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Presentation transcript:

Images and 2D Graphics COMP 112 2017

Menu Graphics Images and image manipulation see GIMP (free open source) Matrices for translation, rotation, scaling, .. Transformations can be easily combined and inverted Affine transformations are widly used in robitics, computer graphics and vision (here we only use very simple transformations) bluring, sharpening, edgdetection, … One convolution algorithm many effects Latest advances in Deep Learning make use of Convolution Neural Nets. Consequently Convolution Filters have become more important!

Image manipulation What kinds of manipulation are there? Independent pixels: changing colors: (brightness, contrast, redness,…..) Geometric transformations translate, rotate, reflect, skew, scale/resize parts of images may involve interpolation to find new pixel values Selecting and modifying regions spread fill representing non-rectangular regions Applying “filters” blur, sharpen, ….. Image recognition - image search.

Geometric Transforms If you translate, rotate, scale, etc the pixels may not line up: pixel (3,1)  pixel (2.7, 2.2) pixel (1,4)  pixel (1.3, 2.8) What value do you use for the new pixels? Options: use truncated pixel coordinates use rounded pixel coordinates take average of overlapping pixels interpolate overlapping pixels (average weighted by distance or degree of overlap)

Geometric Transforms If you translate, rotate, scale, etc the pixels may not line up: pixel (3,1)  pixel (2.7, 2.2) pixel (1,4)  pixel (1.3, 2.8) What about pixels over the edge? What about missing pixel values? Options: drop pixels outside change dimensions of image blank missing pixels (white/black/grey….) use original pixel values.

Computing new pixel value Easier doing reverse direction than forward direction Truncate/Round coordinates: To compute new pixel value at (i, j) work out the pixel that it came from (eg if translate by dx and dy, came from (i-dx, j-dy)) round/truncate to integers. oi = (int) (i-dx); oj = (int) (j-dy); check coords are within image (oi>= 0 && oi<=width, …) use pixel value at those cords of original image. How do you make sure that the new values don’t mess up the old values during the calculation? Always have two image arrays: original image new image. Construct values in new image from values in old image Then copy over.

Transforming int [ ][ ][ ] newImage = new int [image.length] [image[0].length] [3]; for (int i = 0; i< newImage.length; i++){ for (int j = 0; j< newImage.length; j++){ int oi = (int)(i - translateX)); // or whatever transformation int oj = (int)(i - translateY); if (oi>=0 && oi<= image.length && oj >= 0 && ok <= image[0].length) { newImage[ i ][ j ] = image[oi][oj]; // not safe ? newImage[ i ][ j ] = Arrays.copyOf(image[oi][oj], 3); } else { newImage [ i ][ j ] = = new int[ ]{ 0, 0 ,0}; } } image = newImage;

Rotation How can we rotate image by  degrees? Must specify the center of rotation: xCenter, yCenter Need trigonometry: forward xNew = xCenter + (x-xCenter) cos() – (y-yCenter) sin() yNew = yCenter + (x-xCenter) sin() + (y-yCenter) cos() reverse x = xCenter + (xNew-xCenter) cos() + (yNew-yCenter) sin() y = yCenter - (xNew-xCenter) sin() + (yNew-yCenter) cos() x,y xNew, yNew  xCenter,yCenter

Interpolating double ox = (….i ….. j…); double oy = (…. i …..j…); int oi = (int) ox; double oy = (int) oy; newImage[ i ][ j ] = image[oi][oj] * (1-Math.hypot(ox-oi, oy-oj) + image[oi+1][oj] * + image[oi][oj+1] * + image[oi+1][oj+1] * +

Transformation composition Rotation about the origin Clockwise rotation Anticlockwise The composition of a clockwise followed by an anticlockwise rotation is the composition of the two matrices. Which if you remember you trigonometry give you the identity matrix. Which is what you should expect. It is efficient to compose two transformation matrices and apply the result rather than sequential apply each matrix.

Blur, Filters, Convolution Many image transformations involve replacing each pixel with some function of the pixel values in its neighbourhood: Blur, changing resolution: pixel → average of neighbourhood Sharpening, edge detection pixel → "difference" between pixel and neighbours

Convolution Matrix Convolution image transformations replace each pixel with the weighted sum of its neighbouring pixel values: Convolution: Apply "neighbour weights" to each pixel in image then sum: 0.2(0.05+0.05+0.05+0.1+0.1+0.4) + 0.8(0.05+0.1+0.1) = If the matrix values sum to 1 the result is allways an color. 0.2 0.8 0.05 0.1 0.4 0.4 0.35

Convolution Filtering input: image: rows x cols array of pixel filter: height x width array of weights, usually height & width are odd, and weights sum to 1.0 output: newImage: rows x cols array of pixel for row ← 0 .. rows-1 for col ← 0 .. cols-1 ht2 ← (height-1)/2, wd2 ← (width-1)/2 for r ← –ht2 .. ht2 for c ← –wd2 .. wd2 newImage[row, col] += image[row+r][col+c] * filter[r+ht2] [c+w2] Problems: Have to take care at the edges How do you multiply colours? 0.05 0.1 0.4

Filters Blur: Edge detection Sharpen 0.05 0.1 0.4 -1 8 -1 -1 5 -1 -1

Edge Detection Simple: sum to 0 ⇒ constant areas → 0 only "edge" regions bright -1 8