1 ENGI 2420 Structured Programming (Lab Tutorial 8) Memorial University of Newfoundland.

Slides:



Advertisements
Similar presentations
Introduction to Web Design Lecture number:. Todays Aim: Introduction to Web-designing and how its done. Modelling websites in HTML.
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Contest format 5 hours, around 8-12 problems One computer running (likely)Linux, plus printer 3 people on one machine No cell phones, calculators, USB.
Elementary Data Structures: Part 2: Strings, 2D Arrays, Graphs
1 ENGI 2420 Structured Programming (Lab Tutorial 0) Memorial University of Newfoundland.
Chapter 7: User-Defined Functions II
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
The Web Warrior Guide to Web Design Technologies
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming
Lab6 – Debug Assembly Language Lab
Chapter 6: User-Defined Functions I
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
1 Lecture 9  Arrays  Declaration  Initialization  Applications  Pointers  Declaration  The & and * operators  NULL pointer  Initialization  Readings:
Introduction to C Programming
CSC – Java Programming II Lecture 9 January 30, 2002.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
L. Akshay Masare Piyush Awasthi IMAGE PROCESSING AND OPENCV.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
CSE 131 Computer Science 1 Module 1: (basics of Java)
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
DATA STRUCTURES LAB 1 TA: Nouf Al-harbi
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
Unit 1: Java and Eclipse The Eclipse Development Environment.
9/2/ CS171 -Math & Computer Science Department at Emory University.
Lecture 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
1 ENGI 2420 Structured Programming (Lab Tutorial 4) Memorial University of Newfoundland.
1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 18 – Student Grades Application Introducing.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
1 ENGI 2420 Structured Programming (Lab Tutorial 5) Memorial University of Newfoundland.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
Chapter 3: User-Defined Functions I
The Hashemite University Computer Engineering Department
1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
1 ENGI 2420 Structured Programming (Lab Tutorial 1) Memorial University of Newfoundland.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
1 ENGI 2420 Structured Programming (Lab Tutorial 3) Memorial University of Newfoundland.
Course 3 Binary Image Binary Images have only two gray levels: “1” and “0”, i.e., black / white. —— save memory —— fast processing —— many features of.
CSC 121 Computers and Scientific Thinking Fall Event-Driven Programming.
1 ENGI 2420 Structured Programming (Lab Tutorial 2) Memorial University of Newfoundland.
Introduction to Programming Python Lab 8: Loops 26 February PythonLab8 lecture slides.ppt Ping Brennan
FUNCTIONS (C) KHAERONI, M.SI. OBJECTIVE After this topic, students will be able to understand basic concept of user defined function in C++ to declare.
1 Using an Integrated Development Environment. Integrated Development Environments An Integrated Development Environment, or IDE, permits you to edit,
Introduction to Programming
Lab 1: Using NIOS II processor for code execution on FPGA
Continuing Studies CS 38 Stanford University
Chapter 6: User-Defined Functions I
Chapter 7: User-Defined Functions II
Introduction to Programming
Web Graphics By Chris Harding.
Chapter 2 – Introduction to the Visual Studio .NET IDE
2.5 Another Java Application: Adding Integers
Introduction to Programming
User-Defined Functions
Chapter 5 Working with Images
Saving Images from Fireworks
Debugging with Eclipse
Java Programming with BlueJ Objectives
CSCE 313: Embedded Systems Performance Analysis and Tuning
Debugging with Eclipse
Presentation transcript:

1 ENGI 2420 Structured Programming (Lab Tutorial 8) Memorial University of Newfoundland

ENGI 2420 – Structured Programming Lab Tutorial 8 2 Assignment-8  Purpose of this assignment implement functions for image processing  Structure of C++ files - assign8.h (downloadable): contains the declarations for the functions - a8main.cpp (downloadable): main function that can be used as test code - assign8.cpp: contains your implemented functions (only submit this one via web-submit) - you may want to create your own test code in a separate.cpp file (do NOT submit your test code)

ENGI 2420 – Structured Programming Lab Tutorial 8 3 Data Format (I)  We provide readImage and writeImage functions in a8main.cpp  These both use the same data format  The data consists of a sequence of integers. The first pair is to be interpreted as the number of rows and columns, respectively, in the image (i.e., the size of the data). The remaining numbers are the data, row by row.

ENGI 2420 – Structured Programming Lab Tutorial 8 4 Data Format (II) a 5x6 image with diagonal stripes:

ENGI 2420 – Structured Programming Lab Tutorial 8 5 threshold() Function (I)  void threshold(int src[], int rows, int cols, int dest[], int thr)  Convert the image in src to a binary (black and white) storing the resulting image in dest, with pixel values of only either 0 or 255. If an image pixel value is greater than thr (the threshold), then set it to 255, otherwise set it to 0  Do not alter the data in src

ENGI 2420 – Structured Programming Lab Tutorial 8 6 threshold() Function (II)  For example, if thr = 100, then src and dest should be 

ENGI 2420 – Structured Programming Lab Tutorial 8 7 blur() Function (I)  void blur(int src[], int rows, int cols, int dest[])  Make a blurred copy of the image in src into dest. The value of each pixel in dest is calculated as the average of the corresponding pixel in src with its adjacent neighbours (normally a total of 9 pixels). Round to the nearest integer. (When the average is exactly half way between two integers, round up.)

ENGI 2420 – Structured Programming Lab Tutorial 8 8 blur() Function (II)  for a pixel not on the edges:  dest[r, c] = (src[r-1,c-1] + src[r-1,c] + src[r-1,c+1] + src[r,c-1] + src[r,c] + src[r,c+1] + src[r+1,c-1] + src[r+1,c] + src[r+1,c+1])/9.  Note that, for pixels on an edge of the image or in the corner, the number of neighbours is fewer so the summation and the divisor will be different

ENGI 2420 – Structured Programming Lab Tutorial 8 9 threshold() Function (III)  For the diagonal stripe image example, the contents of src and dest should be 

ENGI 2420 – Structured Programming Lab Tutorial 8 10 Running the Program  Our main program uses a "program argument" to select the transformation (threshold or blur). 0 is for threshold and 1 is for blur  The default is threshold, but it is easy to change by changing the line int functionSelector = FUNC_THRESHOLD ; to int functionSelector = FUNC_BLUR ;  You can also select the function using the "program argument" feature of Eclipse's Run Dialog

ENGI 2420 – Structured Programming Lab Tutorial 8 11 Running with MMGood2  MMGood2 is a java program that will execute your program on JPEG, PNG, or GIF files so you can see it working  For windows –Download and uncompress mmgood2.zip –Double click on mmgood2.bat from a Window's Explorer window

ENGI 2420 – Structured Programming Lab Tutorial 8 12 Running with MMGood2  Once mmgood's main window has appeared, and you have compiled your project, you can –Load an input JPEG, PNG, or GIF file –Observe the input image

ENGI 2420 – Structured Programming Lab Tutorial 8 13 Running with MMGood2 –Select your assignment 8 executable. (It is in the Debug subdirectory of your project directory and, in Windows, its name will end with ".exe".) –Set the program argument to be 0 (threshold) or 1 (blur) –Run the executable

ENGI 2420 – Structured Programming Lab Tutorial 8 14 Running with MMGood2 –Wait patiently for your program to finish –Observe the output image –You can save it as a jpeg, if you like