CS 111: Programing Assignment 4

Similar documents
Digital Image Processing

Intensity Transformations and Spatial Filtering

Image Enhancement 3-1

Sampling and Reconstruction

Basic Algorithms for Digital Image Analysis: a course

CS 335 Graphics and Multimedia. Geometric Warping

Biometrics Technology: Image Processing & Pattern Recognition (by Dr. Dickson Tong)

EE795: Computer Vision and Intelligent Systems

Lecture 4. Digital Image Enhancement. 1. Principle of image enhancement 2. Spatial domain transformation. Histogram processing

Announcements. Image Matching! Source & Destination Images. Image Transformation 2/ 3/ 16. Compare a big image to a small image

Ulrik Söderström 17 Jan Image Processing. Introduction

Image Enhancement: To improve the quality of images

Binary representation and data

The simplest and most obvious method to go from a continuous to a discrete image is by point sampling,

INTENSITY TRANSFORMATION AND SPATIAL FILTERING

Feature Descriptors. CS 510 Lecture #21 April 29 th, 2013

Brightness and geometric transformations

CS1114 Assignment 5 Part 1

3.3 Histogram Processing(page 142) h(r k )=n k. p(r k )=1

Digital Image Processing, 2nd ed. Digital Image Processing, 2nd ed. The principal objective of enhancement

Page 129 Exercise 5: Suppose that the joint p.d.f. of two random variables X and Y is as follows: { c(x. 0 otherwise. ( 1 = c. = c

1. (10 pts) Order the following three images by how much memory they occupy:

Interpolation, extrapolation, etc.

SIFT - scale-invariant feature transform Konrad Schindler

Introduction to Digital Image Processing

Digital Image Processing

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as

Problem 1 (10 Points)

Chapter 3: Intensity Transformations and Spatial Filtering

Chapter 18. Geometric Operations

Lecture 4: Spatial Domain Transformations

Comparative Study of Linear and Non-linear Contrast Enhancement Techniques

Lecture 10: Tutorial Sakrapee (Paul) Paisitkriangkrai Evan Tan A/Prof. Jian Zhang

CS 112: Computer System Modeling Fundamentals. Prof. Jenn Wortman Vaughan April 21, 2011 Lecture 8

Line Drawing Week 6, Lecture 9

Introduction. Introduction. Related Research. SIFT method. SIFT method. Distinctive Image Features from Scale-Invariant. Scale.

Lecture #5. Point transformations (cont.) Histogram transformations. Intro to neighborhoods and spatial filtering

Lab 1: Elementary image operations

Circle inversion fractals are based on the geometric operation of inversion of a point with respect to a circle, shown schematically in Fig. 1.

How to Use the Explore Service Area Tool: By Geography.

Department of Computer Sciences Graphics Fall 2003 (Lecture 2) Pixels

1. Introduction to the OpenCV library

1. Complete these exercises to practice creating user functions in small sketches.

ECG782: Multidimensional Digital Signal Processing

Voronoi Region. K-means method for Signal Compression: Vector Quantization. Compression Formula 11/20/2013

ECG782: Multidimensional Digital Signal Processing

Last week. Multi-Frame Structure from Motion: Multi-View Stereo. Unknown camera viewpoints

Institute of Biocybernetics & Biomedical Engineering Polish Academy of Sciences. The MeMoExplorer

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as

Local Features: Detection, Description & Matching

Sampling, Aliasing, & Mipmaps

Digital Image Processing

RASTER ANALYSIS GIS Analysis Winter 2016

CS 445 HW#6 Solutions

Programming for Blood, Spring 2008 Set #3 P. N. Hilfinger. ±0.d 1 d m 2 e,

Image transformations. Prof. Noah Snavely CS Administrivia

How to Use SVG Cut Files

SIFT: SCALE INVARIANT FEATURE TRANSFORM SURF: SPEEDED UP ROBUST FEATURES BASHAR ALSADIK EOS DEPT. TOPMAP M13 3D GEOINFORMATION FROM IMAGES 2014

CS231A Section 6: Problem Set 3

Clustering Color/Intensity. Group together pixels of similar color/intensity.

ELEN E4830 Digital Image Processing. Homework 3 Solution

Edges, interpolation, templates. Nuno Vasconcelos ECE Department, UCSD (with thanks to David Forsyth)

EEM 463 Introduction to Image Processing. Week 3: Intensity Transformations

Digital Image Analysis and Processing

C E N T E R A T H O U S T O N S C H O O L of H E A L T H I N F O R M A T I O N S C I E N C E S. Image Operations I

Sampling: Application to 2D Transformations

Image Processing. Chapter(3) Part 3:Intensity Transformation and spatial filters. Prepared by: Hanan Hardan. Hanan Hardan 1

AMCS / CS 247 Scientific Visualization Lecture 10: (GPU) Texture Mapping. Markus Hadwiger, KAUST

Operators-Based on Second Derivative double derivative Laplacian operator Laplacian Operator Laplacian Of Gaussian (LOG) Operator LOG

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

EECS 556 Image Processing W 09. Interpolation. Interpolation techniques B splines

Digital Image Processing COSC 6380/4393

Gray level histograms

Computer and Machine Vision

Extraction of Level Sets from 2D Images

Today s outline: pp

Linear Algebra and Image Processing: Additional Theory regarding Computer Graphics and Image Processing not covered by David C.

Probability Models.S4 Simulating Random Variables

CS 231A Computer Vision (Winter 2014) Problem Set 3

Obtaining Feature Correspondences

7.5 Dictionary-based Coding

Distribution-free Predictive Approaches

How to use the open-access scanners 1. Basic instructions (pg 2) 2. How to scan a document and perform OCR (pg 3 7) 3. How to scan a document and

Computer Graphics and Image Processing

Exercise Computer graphics (till October 30, 2007)

IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN

Image Processing. David Kauchak cs160 Fall Empirical Evaluation of Dissimilarity Measures for Color and Texture

CHAPTER 3 IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN

Introduction to Geographic Information Science. Some Updates. Last Lecture 4/6/2017. Geography 4103 / Raster Data and Tesselations.

Time Stamp Detection and Recognition in Video Frames

CoE4TN4 Image Processing

MA 323 Geometric Modelling Course Notes: Day 31 Blended and Ruled Surfaces Coons Patches

Digital Image Processing COSC 6380/4393

EE368 Project Report CD Cover Recognition Using Modified SIFT Algorithm

EECS 556 Image Processing W 09. Image enhancement. Smoothing and noise removal Sharpening filters

Exercise 6 Using the NHDPlus Raster Data Sets Last Updated 3/12/2014

Halftoning and quasi-monte Carlo

Poor Man s Rendering Of Segmented Data

Image Enhancement. Digital Image Processing, Pratt Chapter 10 (pages ) Part 1: pixel-based operations

Transcription:

CS 111: Programing Assignment 4 This programming assignment is focused on geometric transformation and histogram processes. You should submit the output images in a ZIP file (not rar or other file compression conventions) and drop it into EEE dropbox for PA4. You will NOT allowed to use any OpenCV functions unless you are told to do in pa4.cpp. In this assignment you only work with gray images. So, use CV_LOAD_IMAGE_GRAYSCALE when reading your images. Histogram Equalization: I. Histogram Matching a. Histogram equalization is a special case of histogram matching. In histogram matching we have a current histogram (the histogram of our image) and a target histogram. The goal is to change the pixel values of the current image such that the current histogram becomes similar to the target histogram. b. To perform histogram matching, we first calculate the Cumlative Distrbution Function (CDF) of both current and target histograms. If we devide the histogram of an imge by the number of pixels in that image, we get a Probaiblity Density Function (PDF). The sum of PDF values is 1. If an image has H pixels and the histogram is: Then, by dividing each bin by the number of pixels you will get the PDF as: Page 1

Then, by calculating the cumulative sum CDF(h) = h 0 PDF(i) is: c. Once we have the CDF of the current and target histograms, then we can find the mapping to perform the histogram matching. For each gray level in the current image you should find its CDF value, and then find its CDF value equivalent gray level in the target CDF. For example, in the image below a gray level x is chosen. It s CDF value is equal to CDF value of gray level y. Therefore, x should be mapped into y. Assume the current CDF is shown by function F and the target CDF is function G. Then the relation between x and y is y = G 1 (F(x)) II. Histogram Equalization a. It is desirable that the probibility distribution of gray levels be equally distributed. If so, the image utilizes the dynamic range of possible values (e.g. 0-255) and will have optimal contrast. The equally distributed histogram PDF and CDF are as follows: Page 2

b. Here, when you are working with discrete values, the PDF and CDF will be discrete functions (bar histogram in earlier images) and when you want to find the equall CDF value between the current and target CDF they may not match. In this assignment you should search for closest CDF value. Absolutely, you can implement smart search algorithms since the CDF is always non-decreasing, however in this assignment you can just do simple linear search. c. You should write the function Mat HistogramEqualization(Mat I) that gets an image at input and return the histogram equalized output image. This function is composed of multiple functions that you should complete for this section i. FindPDF: Input is the gray image and output is the histogram in the format of pdf ii. FindCDF: Input is the pdf and output is the CDF iii. FindEqualMapping: Input is the cdf and output is the mapping after equalization iv. ApplyEqualization: Input is the image and mapping, it applies the mapping on the image and returns the eualized image. Mat FindPDF(Mat I); Mat FindCDF(Mat pdf); Mat FindEqualMapping(Mat cdf); Mat ApplyEqualization(Mat I, Mat mapping) Mat HistogramEqualization(Mat I) { Mat currpdf = FindPDF(I); Mat currcdf = FindCDF(currPDF); Mat eqmap = FindEqualMapping(currCDF); Mat output = ApplyEqualization(I, eqmap); return output; } Page 3

Complete all four functions that compose the HistogramEqualization function in pa4.cpp, and apply it on the input image aerial.png. You should submit the output image aerial_eq.png along with the codes in pa4.cpp in your submitted zip file. Geometric Transformation III. Bi-linear Interpolation a. In geometric transformation, we assume the image a 2D function that has a value for each point on the 2D grid. b. The transformation maps a 2D point to another 2D point. T(x, y) (x, y ) If (x, y ) is on the grid, we can easily find its value, but it needs a general solution for real numbers. The (x, y ) can be anywhere on the 2D space not limited to the integers (grid numbers). If the query point (x, y ) is inside the range of the image (x: 0 to N-1, y: 0 to M 1, for a MxN image) then the operation of finding the value for query point is interpolation. If the query point is outside the coordinates of the image the operation for finding the value is called extrapolation. c. One simplest method of interpolation is called nearest neighbor. In this method you will assign the value of the closest grid point to the query point. Because of poor result and blockiness nature of this interpolation method, it is used very rarely. d. One important and widely used methods for interpolation is called billinear interpolation. In this method it is assumed that each grid block creates a 2D linear function and we can find the value for the query points in each block of the grid. Page 4

e. In 1D linear interpolation you can estimate the query value between known values. In this example we want to linearly interpolate the value at 1.25, which is between 1 and 2. V(1.25) = (1.25 1)1 + (2 1.25)3 = 0.25 + 2.25 = 2.5 f. In 2D, we calculate the liner interpolation in one direction and then for the top and bottom boundaries and then we calculate it becomes a 1D interpolation problem, as follows: v(q 1 ) = (x q x 1 )v 2 + (x 2 x q )v 1 Then, v(q 2 ) = (x q x 1 )v 4 + (x 2 x q )v 3 v(q) = (y q y 1 )v(q 2 ) + (y 2 y q )v(q 1 ) IV. Image Resizing a. Suppose we want to resize an image to twice of its current size. Since we will have more pixels in the output, we should interpolate the values between the pixels. In this work we will perform a bi-linear interpolation. To resize and image we place the four corners of the output image on the same coordinates of the four corners of the input image and then interpolate all the output pixels. b. Assume you have 4x4 image and now you want to resize it to 6x6. The four corners of the output image(6x6) is placed on the four corners of the input image (4x4) and all output pixels (black dots) are within the range of the input image pixels (circles). In the following image, you can see how the query coordinates are placed. Page 5

c. In this assignment you should write a function that sclaes the input image into s times of its input size. The function Mat Resize(Mat I, float s). You should first fill in the X and Y Mat s that contained the query point coordinates. Then you should calculate the query value by using bi-linear interpolation. Mat Resize(Mat I, float s) Complete the function Resize(Mat I, float s) in the pa4.cpp, and apply on the input image aerial.png and wite it in aerial_640.png. Submit the code and the output image in the zip file. Page 6