ECE 3331, Dr. Hebert, Summer-3, 2016 HW 11 Hardcopy HW due Tues 07/19 Program due Sunday 07/17. Problem 1. Section 10.6, Exercise 3.

Size: px
Start display at page:

Download "ECE 3331, Dr. Hebert, Summer-3, 2016 HW 11 Hardcopy HW due Tues 07/19 Program due Sunday 07/17. Problem 1. Section 10.6, Exercise 3."

Transcription

1 ECE 3331, Dr. Hebert, Summer-3, 2016 HW 11 Hardcopy HW due Tues 07/19 Program due Sunday 07/17 Problem 1. Section 10.6, Exercise 3. Problem 2. Section 10.6, Exercise 5. Problem 3. Section 10.6, Exercise 6 Problem 4. Section 10.8, Exercise 2. Problem 5. Section 10.8, Exercise 5. Problem 6. Section 10.9, Exercise 1. Problem 7. Section 10.9, Exercise 3. Problem 8. Programming project. The BMP (bitmap) Image-file Format Read this whole section before starting. The BMP (bitmap) format is a standard image-file format developed by Microsoft and used by Windows Operating systems and others. This document describes how to construct a 24-bit BMP file. A 24-bit BMP file uses 24 bits to denote the color of each pixel in an image: an 8-bit value (0-255) for the blue component, an 8-bit value (0-255) for the green component, and an 8-bit value (0-255) for the red component of a pixel. Using BGR to denote the blue, green, and red components of a pixel, if the pixel is bright blue, it would have (B,G,R)=(255,0,0). If a pixel is bright green it would have (B,G,R)=(0,255,0). If the pixel is bright red, it would have (B,G,R)=(0,0,255). Black is formed by the absence of color; so if a pixel is black it would have (B,G,R)=(0,0,0). White is formed by the superposition of the brightest blue, green, and red; so a white pixel would have (B,G,R)=(255,255,255). Your 24-bit BMP file will have the following 3 parts. 1) A bitmap file header (14 bytes) is the 1st 14 bytes in a BMP image-file. The bitmap-file header, called a BITMAPFILEHEADER, contains information about the type, size, and layout of the bitmap file. (More info below) 2) A bitmap information header (40 bytes) called a BITMAPINFOHEADER follows the BITMAPFILEHEADER in the *.bmp image file. The bitmap-information header specifies the dimensions, compression type, and color format for the bitmap file. (More info below) 3) Image-data, a sequence of bytes that define the BGR value at each pixel in the image. The image-data stores the BGR values of each pixel in order: beginning at the bottom row of the image, going across the row, then the 1st pixel of the next higher row of the image, etc. Let's consider creating a BMP (bitmap) file that will contain a 256x256 pixel color image as shown below. The image will be black on the left and bright red on the right.

2 For this image, the BGR values in each row of the image will be the same. As your eye travels across the image from left-to-right, the pixels become brighter and brighter red, as follows. Consider that the image is 256 pixels in width and 256 pixels in height. The BMP file will have the width and height of the image in the file header, each will be stored as an unsigned int (4 bytes) least significant byte first. The decimal value 256 is represented with a 4-byte unsigned integer as the 4 bytes (least significant byte 1st) 0, 1, 0, 0 which denotes the decimal non-negative value 0+1*256+0*256*256+0*256*256*256=256. The decimal value 503, for examples, would be stored as 247, 1, 0, 0 which denotes the decimal non-negative value 247+1*256+0*256*256+0*256*256*256=503. Additionally in the header of the BMP file, we will need to store the number of bytes of image-data; i.e. the total number of bytes required to store the BGR values for each pixel in the image. Since we are storing the blue-green-red value of each pixel as 3 consecutive bytes, we will need 3*256*256=196,608 bytes for the image data. The value 196,608 will also have to be stored in the header of the BMP file as a 4-byte unsigned int value, least significant byte first. The decimal value 196,608 is represented as a 4-byte integer value as the 4 bytes (least significant byte 1st) 0, 0, 3, 0 which denotes the decimal value 0+0*256+3*256*256+0*256*256*256=196,608. The total number of bytes in the BMP file will be *256*256=196,662 via (bitmap file header =14 bytes)+(bitmap information header =40 bytes)+(image data BGR =196,608bytes). The decimal value 196,662 is represented as a 4-byte integer value as the 4 bytes (least significant byte 1st) 54, 0, 3, 0. Now let's examine the first 14 bytes in the 256x256 pixel BMP file shown above, i.e. the BITMAPFILEHEADER. BYTE locations Description Decimal Byte Value Comments bytes 1-2 (2) BMP file 66, 77 (Type) designation bytes 3-6 (4) (Size) total # bytes in BMP imagefile 54, 0, 3, 0 LeastSigByte 1st; MostSigByte last bytes 7-8 (2) reserved bytes 0, 0 must be 0's (Reserved1) bytes 9-10 (2) reserved bytes 0, 0 must be 0's (Reserved2) bytes (4) (OffsetBytes) offset (in bytes) from start of file to image-data =54. using 4 bytes: 54, 0, 0, 0 Least Signif Byte 1st; Most Signif Byte last Figure 5.1 The 14-byte BITMAPFILEHEADER that begins your BMP file.

3 The first 14 bytes of the BMP file will be 66, 77, 54, 0, 3, 0, 0, 0, 0, 0, 54, 0, 0, 0 Now, let's examine the next 40 bytes in the BMP file, i.e. the BITMAPINFOHEADER. BYTE locations Description Decimal Byte Comments Values bytes 1-4 (4) # bytes in 40, 0, 0, 0 (Size) BITMAPINFOHEADER bytes 5-8 (4) Image-width in 0, 1, 0, 0 (Width) pixels=256 bytes 9-12 (4) Image-height in 0, 1, 0, 0 (Height) pixels=256 bytes (2) (Planes) # planes in image=1 1, 0 typically = 1 bytes (2) # of bits per pixel=24 24, 0 (BitCount) bytes (4) (Compression Type) Type of Compression 0, 0, 0, 0 0 means no compression bytes (4) (ImageDatasize) bytes (4) (PixelsPerMeter_X) bytes (4) (PixelsPerMeter_Y) bytes (4) (Colors_Used) bytes (4) (Colors_Important) Total # bytes in imagedata 192,608 using 4 bytes is 0, 0, 3, 0 # horiz pixels per meter=0 0, 0, 0, 0 (Not used). # vert pixels per meter=0 0, 0, 0, 0 (Not used). # of entries in color 0, 0, 0, 0 not used for this table=0 image. Set equal to 0 # of significant colors=0 0, 0, 0, 0 not used for this image. Set equal to 0 Figure 5.2 The 40-byte BITMAPINFOHEADER that follows the BITMAPFILEHEADER in a BMP file. The next 40 bytes in the BMP file will therefore be 40, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0. To generate the BGR pixels in each row of the image above, you could use a double "for" loop (a nested for-loop) to increment across each image row and across each pixel in that row. for(i=0; i<256; i++){\\ iterate across the rows in the image for(j=0; j<256; j++){ \\ iterate across the pixels in the ith row.... } }. As you visit each pixel, you would generate the 3-byte BGR value for that pixel. The blue B and green G components would be 0 for every pixel in the image. The red R value for each pixel would be its j value from the inner for-loop.

4 For example, if i=14 (you are visiting the 14th row) and j=23 (you are visiting the 23rd pixel in the 14th row) the BGR value for that pixel is BGR=(0, 0, 23)= (0,0,j). There was two additional pieces of information about the BMP format. A) The BMP format requires that each image row consist of an integer multiple of 4-bytes. If each image row needs for example 15 bytes to store the BGR pixel values, then an additional 1-byte ( a "padding byte") needs to be stored after the BGR pixel values for each row, so that the row occupies 16-bytes, an integer multiple (4) of 4-bytes. B) The BMP format writes out the pixels in the bottom row of the image to the file first, and it writes the pixels of the top row of the image last. For the reddish image above, each image row contains 256 BGR values or (256)*(3)=768 bytes. Of course, 768 is a whole multiple of 4, since 768=4*192. Therefore, no "padding bytes" need to be written to the file after each image row. To calloc( ) memory for the BGR values of the N pixels in an image row, we could do unsigned char *irow,n; N=99; \\ 99 pixels per image row. irow=(unsigned char)calloc(1,3*n); But 3*99=297 is not a multiple of 4 bytes, so "padding bytes" would need to be written to the file so that the bytes for the row would occupy a whole multiple of 4 bytes. Since 300=4*75, we need to add =3 "padding bytes" to the data in the BMP file for each image row. Note that modulus 297%4=1. Also 4-1=3 bytes, and 3 bytes is the number of padding bytes that we would need. So the way to calloc( ) memory for each image row is unsigned char *irow,n; N=99; \\ 99 pixels per image row. M=3*N+(4-(3*N)%4); irow=(unsigned char)calloc(1,3*n); To read-in or write-out a BMP image, you should open the file as unformatted "rb" or "wb". In this project, you will write a program to read-in a 24-bit BMP color image and write out a color "negative" of the image to a BMP file. A color "negative" simply changes each color component B,G,R to 255-B, 255-G,255- R. Your program will prompt the user for the path/filename of the input BMP file, and write out a file called neagative.bmp to the same folder in which the input file is stored. 1. Write a structures for the BITMAPFILEHEADER and for the BITMAPINFOHEADER. Since the byte-order (least significant byte first) of many of the fields of the BITMAPFILEHEADER and BITMAPINFOHEADER are important, the fields, for example, for filesize should not be simply an unsigned int. If we were to fwrite( ) the structure to a file, the byte order written to the file depends on the operating system of the computer. Most, but not all, of the operating systems would write the least-significant byte of the unsigned int; but some operating systems write out the most-significant byte first. Your program should be able to e compiled and run on any operating system and still produce a valid BMP file. Therefore, filesize is most easily stored as a 4-byte vector unsigned char filesize[4], struct bmpfileheader{ unsigned char bmp[2]; unsigned char filesize[4]; unsigned int reserved;

5 unsigned char dataoffset[4]; }; Write a similar structure for the BITMAPINFOHEADER. 2. Now declare a structure for the BMP header made up of the BITMAPFILEHEADER structure and the BITMAPINFOHEADER structure struct bmpheader{ struct bmpfileheader fileheader; struct bmpinfoheader infoheader; } 3. Declare a bmpheader variable struct bmpheader header; 4. Write a function whereby you pass a 4-byte unsigned int value and the function fills a vector unsigned char v[4] with the 4 bytes ordered with least-significant byte first in v[0]. We worked this out in lecture as void ui24bytes(unsigned int itmp, unsigned char * v){ v[0]= (unsigned char)(itmp%256); v[3]= (unsigned char)(itmp/pow(256,3)); v[2]= (unsigned char)( (itmp-v[3]*pow(256,3))/pow(256,2)); v[1]= (unsigned char)( (itmp-v[3]*pow(256,3)-v[2]*pow(256,2))/256); } For example, ui24bytes(23917, header.fileheader.filesize); would will in the four bytes denoting a filesize of Fill in all the fields of the bmp header using fread( ) from the input BMP file. 6. If the 1st two bytes of the input file are not 66 and 77, print a message to the user and exit. 7. If the file is indeed BMP, write out the header to the output BMP file. 8. Now read-in the imagedata byte -by - byte, invert each byte (255-byte) and write it to the output file. Each byte value v of the input image data, however, will be changed to 255-v in the output image data. In the final version of your program, do not change the "padding bytes" p in each image row to 255-p.

Effective Programming in C and UNIX Lab 6 Image Manipulation with BMP Images Due Date: Sunday April 3rd, 2011 by 11:59pm

Effective Programming in C and UNIX Lab 6 Image Manipulation with BMP Images Due Date: Sunday April 3rd, 2011 by 11:59pm 15-123 Effective Programming in C and UNIX Lab 6 Image Manipulation with BMP Images Due Date: Sunday April 3rd, 2011 by 11:59pm The Assignment Summary: In this assignment we are planning to manipulate

More information

BMP Graphics File Formats

BMP Graphics File Formats BMP Graphics File Formats This topic describes the graphics-file formats used by the Microsoft Windows operating system. Graphics files include bitmap files, icon-resource files, and cursor-resource files.

More information

TODO. open file update outfile s header info read infile s scanline, pixel by pixel resize horizontally remember padding!

TODO. open file update outfile s header info read infile s scanline, pixel by pixel resize horizontally remember padding! resize TODO open file update outfile s header info read infile s scanline, pixel by pixel resize horizontally remember padding! resize vertically copy.c opens a file updates header info for outfile reads

More information

TODO. parse float input update outfile s header info resize horizontally remember padding! resize vertically

TODO. parse float input update outfile s header info resize horizontally remember padding! resize vertically resize TODO parse float input update outfile s header info resize horizontally remember padding! resize vertically copy.c parses int input opens a file updates header info for outfile reads each scanline,

More information

CpSc 101, Fall 2015 Lab7: Image File Creation

CpSc 101, Fall 2015 Lab7: Image File Creation CpSc 101, Fall 2015 Lab7: Image File Creation Goals Construct a C language program that will produce images of the flags of Poland, Netherland, and Italy. Image files Images (e.g. digital photos) consist

More information

pset 4: Forensics Zamyla Chan

pset 4: Forensics Zamyla Chan pset 4: Forensics Zamyla Chan zamyla@cs50.net Toolbox update50 File I/O copy.c bitmaps padding! JPEGs pset 4 0. A Section of Questions 1. Whodunit 2. Resize 3. Recover File I/O Toolbox fopen fread fwrite

More information

Graphics File Formats

Graphics File Formats Graphics File Formats This topic describes the graphics-file formats used by the Microsoft Windows operating system. Graphics files include bitmap files, icon-resource files, and cursor-resource files.

More information

BMP file format - Wikipedia

BMP file format - Wikipedia Page 1 of 3 Bitmap file header This block of bytes is at the start of the file and is used to identify the file. A typical application reads this block first to ensure that the file is actually a BMP file

More information

OptimiData. JPEG2000 Software Development Kit for C/C++ Reference Manual. Version 1.6. from

OptimiData. JPEG2000 Software Development Kit for C/C++  Reference Manual. Version 1.6. from OptimiData for optimized data handling JPEG2000 Software Development Kit for C/C++ Reference Manual Version 1.6 from 2004-07-29 (Windows and Linux Versions) www.optimidata.com OptimiData JPEG2000 C-SDK

More information

C Language, Token, Keywords, Constant, variable

C Language, Token, Keywords, Constant, variable C Language, Token, Keywords, Constant, variable A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C

More information

Common File Formats. Need a standard to store images Raster data Photos Synthetic renderings. Vector Graphic Illustrations Fonts

Common File Formats. Need a standard to store images Raster data Photos Synthetic renderings. Vector Graphic Illustrations Fonts 1 Image Files Common File Formats Need a standard to store images Raster data Photos Synthetic renderings Vector Graphic Illustrations Fonts Bitmap Format - Center for Graphics and Geometric Computing,

More information

This is not yellow. Image Files - Center for Graphics and Geometric Computing, Technion 2

This is not yellow. Image Files - Center for Graphics and Geometric Computing, Technion 2 1 Image Files This is not yellow Image Files - Center for Graphics and Geometric Computing, Technion 2 Common File Formats Need a standard to store images Raster data Photos Synthetic renderings Vector

More information

Graphics: Legacy Library

Graphics: Legacy Library Graphics: Legacy Library Version 5.1 February 14, 2011 (require graphics/graphics) The viewport graphics library is a relatively simple toolbox of graphics commands. The library is not very powerful; it

More information

Data Structures Unit 02

Data Structures Unit 02 Data Structures Unit 02 Bucharest University of Economic Studies Memory classes, Bit structures and operators, User data types Memory classes Define specific types of variables in order to differentiate

More information

- It computes the Standard Deviation by calculating the difference of each channel (R,G,B and A) of a pixel.

- It computes the Standard Deviation by calculating the difference of each channel (R,G,B and A) of a pixel. Standard Deviation: It is common to find comparison of two bitmaps in Image Processing Development. Comparison of two bitmaps means how each pixel of image1 is different from corresponding pixel of image2

More information

BMP file format. Contents. Pixel storage. The BMP file format, sometimes called bitmap. or DIB file format (for device-independent

BMP file format. Contents. Pixel storage. The BMP file format, sometimes called bitmap. or DIB file format (for device-independent 1 of 7 BMP file format From Wikipedia, the free encyclopedia Windows Bitmap The BMP file format, sometimes called bitmap File extension:.bmp or.dib or DIB file format (for device-independent MIME type:

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

CS 315 Data Structures Fall Figure 1

CS 315 Data Structures Fall Figure 1 CS 315 Data Structures Fall 2012 Lab # 3 Image synthesis with EasyBMP Due: Sept 18, 2012 (by 23:55 PM) EasyBMP is a simple c++ package created with the following goals: easy inclusion in C++ projects,

More information

Programming in C++ 5. Integral data types

Programming in C++ 5. Integral data types Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long

More information

Love is not rude, is not selfish, and does not get upset with others. Reading BMP Files

Love is not rude, is not selfish, and does not get upset with others. Reading BMP Files 33 Love is not rude, is not selfish, and does not get upset with others. Reading BMP Files When you look at the BMP file format closely, you can find that BMP stores palette information in it. So in order

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

What is the Box Model?

What is the Box Model? CSS Box Model What is the Box Model? The box model is a tool we use to understand how our content will be displayed on a web page. Each HTML element appearing on our page takes up a "box" or "container"

More information

EE 355 Unit 5. Multidimensional Arrays. Mark Redekopp

EE 355 Unit 5. Multidimensional Arrays. Mark Redekopp 1 EE 355 Unit 5 Multidimensional Arrays Mark Redekopp MULTIDIMENSIONAL ARRAYS 2 3 Multidimensional Arrays Thus far arrays can be thought of 1-dimensional (linear) sets only indexed with 1 value (coordinate)

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

An Introduction to Video Compression in C/C++ Fore June

An Introduction to Video Compression in C/C++ Fore June 1 An Introduction to Video Compression in C/C++ Fore June 1 Chapter 1 Image and Video Storage Formats There are a lot of proprietary image and video file formats, each with clear strengths and weaknesses.

More information

Parallel Image Processing

Parallel Image Processing Parallel Image Processing Course Level: CS1 PDC Concepts Covered: PDC Concept Concurrency Data parallel Bloom Level C A Programming Skill Covered: Loading images into arrays Manipulating images Programming

More information

Computer Programming

Computer Programming Computer Programming Dr. Deepak B Phatak Dr. Supratik Chakraborty Department of Computer Science and Engineering Lectures 20, 21, 22 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty, 1 A Generic Iteration

More information

ECE 598 Advanced Operating Systems Lecture 18

ECE 598 Advanced Operating Systems Lecture 18 ECE 598 Advanced Operating Systems Lecture 18 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 5 April 2018 Announcements Homework #9 will be posted (graphics) 1 Graphics Interface

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

OpenCV. Rishabh Maheshwari Electronics Club IIT Kanpur

OpenCV. Rishabh Maheshwari Electronics Club IIT Kanpur OpenCV Rishabh Maheshwari Electronics Club IIT Kanpur Installing OpenCV Download and Install OpenCV 2.1:- http://sourceforge.net/projects/opencvlibrary/fi les/opencv-win/2.1/ Download and install Dev C++

More information

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types

More information

Multimedia Retrieval Exercise Course 2 Basic of Image Processing by OpenCV

Multimedia Retrieval Exercise Course 2 Basic of Image Processing by OpenCV Multimedia Retrieval Exercise Course 2 Basic of Image Processing by OpenCV Kimiaki Shirahama, D.E. Research Group for Pattern Recognition Institute for Vision and Graphics University of Siegen, Germany

More information

Lecture 22 Sections 8.8, 8.9, Wed, Oct 28, 2009

Lecture 22 Sections 8.8, 8.9, Wed, Oct 28, 2009 s The s Lecture 22 Sections 8.8, 8.9, 8.10 Hampden-Sydney College Wed, Oct 28, 2009 Outline s The 1 2 3 4 5 The 6 7 8 Outline s The 1 2 3 4 5 The 6 7 8 Creating Images s The To create a texture image internally,

More information

COMP322 - Introduction to C++

COMP322 - Introduction to C++ COMP322 - Introduction to C++ Lecture 05 - I/O using the standard library, stl containers, stl algorithms Dan Pomerantz School of Computer Science 5 February 2013 Basic I/O in C++ Recall that in C, we

More information

Programming in C++ 4. The lexical basis of C++

Programming in C++ 4. The lexical basis of C++ Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++

More information

Problem Solving: Storyboards for User Interaction

Problem Solving: Storyboards for User Interaction Topic 6 1. The while loop 2. Problem solving: hand-tracing 3. The for loop 4. The do loop 5. Processing input 6. Problem solving: storyboards 7. Common loop algorithms 8. Nested loops 9. Problem solving:

More information

typedef unsigned char unch; char far *screen = (char far *) 0xA ; unch pal_buf[max_col][3]; int xmax, ymax;

typedef unsigned char unch; char far *screen = (char far *) 0xA ; unch pal_buf[max_col][3]; int xmax, ymax; #include #include #include #include #include #include #define MAX_COL 256 typedef unsigned char unch; char far *screen = (char far *) 0xA0000000;

More information

Problem 1. Multiple Choice (choose only one answer)

Problem 1. Multiple Choice (choose only one answer) Practice problems for the Final (Tuesday, May 14 4:30-6:30pm MHP 101). The Final Exam will cover all course material. You will be expected to know the material from the assigned readings in the book, the

More information

CSE2003: System Programming (Spring 2009) Programming Assignment #3: Drawing grid lines in an image. Due: Fri May 15, 11:59PM

CSE2003: System Programming (Spring 2009) Programming Assignment #3: Drawing grid lines in an image. Due: Fri May 15, 11:59PM CSE2003: System Programming (Spring 2009) Programming Assignment #3: Drawing grid lines in an image Due: Fri May 15, 11:59PM 1. Introduction In this assignment, you will implement a basic image processing

More information

IMAGE PROCESSING AND OPENCV. Sakshi Sinha Harshad Sawhney

IMAGE PROCESSING AND OPENCV. Sakshi Sinha Harshad Sawhney l IMAGE PROCESSING AND OPENCV Sakshi Sinha Harshad Sawhney WHAT IS IMAGE PROCESSING? IMAGE PROCESSING = IMAGE + PROCESSING WHAT IS IMAGE? IMAGE = Made up of PIXELS. Each Pixels is like an array of Numbers.

More information

Exam 2. CSC 121 MW Class. Lecturer: Howard Rosenthal. April 26, 2017

Exam 2. CSC 121 MW Class. Lecturer: Howard Rosenthal. April 26, 2017 Your Name: Exam 2. CSC 121 MW Class Lecturer: Howard Rosenthal April 26, 2017 The following questions (or parts of questions) in numbers 1-7 are all worth 3 points each. 1. Answer the following as true

More information

COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization. Data Representation COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

More information

Huawei Test 3. 1 A card is drawn from a pack of 52 cards. The probability of getting a queen of club or a king of heart is:

Huawei Test 3. 1 A card is drawn from a pack of 52 cards. The probability of getting a queen of club or a king of heart is: Huawei Test 3 1 A card is drawn from a pack of 52 cards. The probability of getting a queen of club or a king of heart is: ( )1 /13 ( )2 /13 ( )1 /26 ( )1 /52 Here, n(s) = 52. Let E = event of getting

More information

Decision Making and Loops

Decision Making and Loops Decision Making and Loops Goals of this section Continue looking at decision structures - switch control structures -if-else-if control structures Introduce looping -while loop -do-while loop -simple for

More information

CSI 402 Lecture 2 (More on Files) 2 1 / 20

CSI 402 Lecture 2 (More on Files) 2 1 / 20 CSI 402 Lecture 2 (More on Files) 2 1 / 20 Files A Quick Review Type for file variables: FILE * File operations use functions from stdio.h. Functions fopen and fclose for opening and closing files. Functions

More information

CP SC 4040/6040 Computer Graphics Images. Joshua Levine

CP SC 4040/6040 Computer Graphics Images. Joshua Levine CP SC 4040/6040 Computer Graphics Images Joshua Levine levinej@clemson.edu Lecture 03 File Formats Aug. 27, 2015 Agenda pa01 - Due Tues. 9/8 at 11:59pm More info: http://people.cs.clemson.edu/ ~levinej/courses/6040

More information

Chapter 3. Texture mapping. Learning Goals: Assignment Lab 3: Implement a single program, which fulfills the requirements:

Chapter 3. Texture mapping. Learning Goals: Assignment Lab 3: Implement a single program, which fulfills the requirements: Chapter 3 Texture mapping Learning Goals: 1. To understand texture mapping mechanisms in VRT 2. To import external textures and to create new textures 3. To manipulate and interact with textures 4. To

More information

Nested Loops. A loop can be nested inside another loop.

Nested Loops. A loop can be nested inside another loop. Nested Loops A loop can be nested inside another loop. Nested loops consist of an outer loop and one or more inner loops. Each time the outer loop is repeated, the inner loops are reentered, and started

More information

MCS 2514 Fall 2012 Programming Assignment 3 Image Processing Pointers, Class & Dynamic Data Due: Nov 25, 11:59 pm.

MCS 2514 Fall 2012 Programming Assignment 3 Image Processing Pointers, Class & Dynamic Data Due: Nov 25, 11:59 pm. MCS 2514 Fall 2012 Programming Assignment 3 Image Processing Pointers, Class & Dynamic Data Due: Nov 25, 11:59 pm. This project is called Image Processing which will shrink an input image, convert a color

More information

CSI 402 Lecture 2 Working with Files (Text and Binary)

CSI 402 Lecture 2 Working with Files (Text and Binary) CSI 402 Lecture 2 Working with Files (Text and Binary) 1 / 30 AQuickReviewofStandardI/O Recall that #include allows use of printf and scanf functions Example: int i; scanf("%d", &i); printf("value

More information

Week 5: Files and Streams

Week 5: Files and Streams CS319: Scientific Computing (with C++) Week 5: and Streams 9am, Tuesday, 12 February 2019 1 Labs and stuff 2 ifstream and ofstream close a file open a file Reading from the file 3 Portable Bitmap Format

More information

Computer Labs: Lab 5 & Sprites

Computer Labs: Lab 5 & Sprites Computer Labs: Lab 5 & Sprites 2 o MIEIC Pedro F. Souto (pfs@fe.up.pt) November 17, 2017 Lab5: Video Card in Graphics Mode - 2nd Lab Class Write a set of functions (tentative): int video_test_xpm(char

More information

Unit 3 Decision making, Looping and Arrays

Unit 3 Decision making, Looping and Arrays Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.

More information

ME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double

ME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double ME 172 Lecture 2 variables scanf() printf() 07/03/2011 ME 172 1 Data Types and Modifier Basic data types are char int float double Modifiers signed unsigned short Long 07/03/2011 ME 172 2 1 Data Types

More information

CS103L PA4. March 25, 2018

CS103L PA4. March 25, 2018 CS103L PA4 March 25, 2018 1 Introduction In this assignment you will implement a program to read an image and identify different objects in the image and label them using a method called Connected-component

More information

CSE2003: System Programming Final Exam. (Spring 2009)

CSE2003: System Programming Final Exam. (Spring 2009) CSE2003: System Programming Final Exam. (Spring 2009) 3:00PM 5:00PM, June 17, 2009. Instructor: Jin Soo Kim Student ID: Name: 1. Write the full name of the following acronym. (25 points) (1) GNU ( ) (2)

More information

Week 9 Lecture 3. Binary Files. Week 9

Week 9 Lecture 3. Binary Files. Week 9 Lecture 3 Binary Files 1 Reading and Writing Binary Files 2 Binary Files It is possible to write the contents of memory directly to a file. The bits need to be interpreted on input Possible to write out

More information

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,... Chapter 9 Computer Arithmetic Reading: Section 9.1 on pp. 290-296 Computer Representation of Data Groups of two-state devices are used to represent data in a computer. In general, we say the states are

More information

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space

More information

Programming refresher and intro to C programming

Programming refresher and intro to C programming Applied mechatronics Programming refresher and intro to C programming Sven Gestegård Robertz sven.robertz@cs.lth.se Department of Computer Science, Lund University 2018 Outline 1 C programming intro 2

More information

C Tutorial: Part 1. Dr. Charalampos C. Tsimenidis. Newcastle University School of Electrical and Electronic Engineering.

C Tutorial: Part 1. Dr. Charalampos C. Tsimenidis. Newcastle University School of Electrical and Electronic Engineering. C Tutorial: Part 1 Dr. Charalampos C. Tsimenidis Newcastle University School of Electrical and Electronic Engineering September 2013 Why C? Small (32 keywords) Stable Existing code base Fast Low-level

More information

ECE15: Lab #4. Problem 1. University of California San Diego

ECE15: Lab #4. Problem 1. University of California San Diego University of California San Diego ECE15: Lab #4 This lab is a cumulative wrap-up assignment for the entire course. As such, it relates to the material covered in Lecture Units 1 5 and 7 9 in class. Here

More information

Programming. C++ Basics

Programming. C++ Basics Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++

More information

Decipher Encrypted Image

Decipher Encrypted Image SuperCon 04 Problem Explanation Decipher Encrypted Image SuperCon 04, 2004.8.2 As announced in the problem outline, the subject of this year s problem is to compute the original from a given encrypted

More information

MPATE-GE 2618: C Programming for Music Technology. Problem Set 4 Out of 80 points

MPATE-GE 2618: C Programming for Music Technology. Problem Set 4 Out of 80 points Problem Set 4 Out of 80 points Part 1 due Monday, October 22, 2012 at 8pm Part 2 due Thursday, October 25, 2012 at 8pm Goals Getting familiar with binary file I/O Getting acquainted with pointers Getting

More information

Memory Usage in Programs

Memory Usage in Programs Memory Usage in Programs ECE2036 Lecture 4 ECE2036 Memory Usage in Programs Spring 2016 1 / 11 Memory Usage in Programs The way that memory is assigned to your program is fundamental to understanding how

More information

Courses IPCx, C2: Histogram, Code Comments

Courses IPCx, C2: Histogram, Code Comments Courses IPCx, C2: Histogram, Code Comments 1 Copyright by V. Miszalok, last update: 24-03-2002 In histo1doc.h in front of class CHisto1Doc : public CDocument #include < vector > //declares the dynamic

More information

At this time we have all the pieces necessary to allocate memory for an array dynamically. Following our example, we allocate N integers as follows:

At this time we have all the pieces necessary to allocate memory for an array dynamically. Following our example, we allocate N integers as follows: Pointers and Arrays Part II We will continue with our discussion on the relationship between pointers and arrays, and in particular, discuss how arrays with dynamical length can be created at run-time

More information

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program Syntax What the Compiler needs to understand your program 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line Possibly replacing it with other

More information

CS201 Some Important Definitions

CS201 Some Important Definitions CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

Code: analysis, bugs, and security

Code: analysis, bugs, and security Code: analysis, bugs, and security supported by Bitdefender Marius Minea marius@cs.upt.ro 4 October 2017 Course goals improve skills: write robust, secure code understand program internals learn about

More information

CP SC 4040/6040 Computer Graphics Images. Joshua Levine

CP SC 4040/6040 Computer Graphics Images. Joshua Levine CP SC 4040/6040 Computer Graphics Images Joshua Levine levinej@clemson.edu Lecture 02 OpenImageIO and OpenGL Aug. 25, 2015 Agenda Reminder, course webpage: http://people.cs.clemson.edu/~levinej/courses/6040

More information

Programming Fundamentals (CS-302 )

Programming Fundamentals (CS-302 ) Programming Fundamentals (CS-302 ) (Structures) Dr. Ihsan Ullah Lecturer Department of Computer Science & IT University of Balochistan 1 Introduction A variable can store one element at a time An array

More information

If you note any errors, typos, etc. with this manual or our software libraries, let us know at

If you note any errors, typos, etc. with this manual or our software libraries, let us know at Oregon State University Robotics Club ORK 2011 Programming Guide Version 1.0 Updated: 10/28/2011 Note: Check back for more revisions and updates soon! If you note any errors, typos, etc. with this manual

More information

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;

More information

Midterm Exam #2 Spring (1:00-3:00pm, Friday, March 15)

Midterm Exam #2 Spring (1:00-3:00pm, Friday, March 15) Print Your Name: Signature: USC email address: CSCI 101L Fundamentals of Computer Programming Midterm Exam #2 Spring 2013 (1:00-3:00pm, Friday, March 15) Instructor: Prof Tejada Problem #1 (20 points):

More information

1. Introduction to the OpenCV library

1. Introduction to the OpenCV library Image Processing - Laboratory 1: Introduction to the OpenCV library 1 1. Introduction to the OpenCV library 1.1. Introduction The purpose of this laboratory is to acquaint the students with the framework

More information

CGS 3460 Summer 07 Midterm Exam

CGS 3460 Summer 07 Midterm Exam Short Answer 3 Points Each 1. What would the unix command gcc somefile.c -o someotherfile.exe do? 2. Name two basic data types in C. 3. A pointer data type holds what piece of information? 4. This key

More information

BLM2031 Structured Programming. Zeyneb KURT

BLM2031 Structured Programming. Zeyneb KURT BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help

More information

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types Data Types Declarations and Initializations Larry Caretto Computer Science 16 Computing in Engineering and Science February 7, 25 Outline Review last week Meaning of data types Integer data types have

More information

MiniView Block Set Library

MiniView Block Set Library Set GUI Mode: This block sets the GUI mode. Value zero is normal, 1=xor, and 2=trans. Clear Screen: This block is used to clear the display screen, and corresponds to message ID 0x426. The trigger is a

More information

Computer Systems and Networks

Computer Systems and Networks University of the Pacific LECTURE 5: C PROGRAMMING Computer Systems and Networks Dr. Pallipuram (vpallipuramkrishnamani@pacific.edu) Today s Class o Pointer basics o Pointers and mul;- dimensional arrays

More information

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators CSE 351: The Hardware/Software Interface Section 2 Integer representations, two s complement, and bitwise operators Integer representations In addition to decimal notation, it s important to be able to

More information

Title and Modify Page Properties

Title and Modify Page Properties Dreamweaver After cropping out all of the pieces from Photoshop we are ready to begin putting the pieces back together in Dreamweaver. If we were to layout all of the pieces on a table we would have graphics

More information

Introduction to Computer Science (I1100) Data Storage

Introduction to Computer Science (I1100) Data Storage Data Storage 145 Data types Data comes in different forms Data Numbers Text Audio Images Video 146 Data inside the computer All data types are transformed into a uniform representation when they are stored

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and

More information

Lab 09 - Virtual Memory

Lab 09 - Virtual Memory Lab 09 - Virtual Memory Due: November 19, 2017 at 4:00pm 1 mmapcopy 1 1.1 Introduction 1 1.1.1 A door predicament 1 1.1.2 Concepts and Functions 2 1.2 Assignment 3 1.2.1 mmap copy 3 1.2.2 Tips 3 1.2.3

More information

Adafruit DotStar FeatherWing

Adafruit DotStar FeatherWing Adafruit DotStar FeatherWing Created by lady ada Last updated on 2018-08-22 04:03:05 PM UTC Guide Contents Guide Contents Overview Pinouts Power Pins Data Pins Usage DotMatrix Usage Downloads Files Schematic

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

CSCE 110 Dr. Amr Goneid Exercise Sheet (6): Exercises on Structs and Dynamic Lists

CSCE 110 Dr. Amr Goneid Exercise Sheet (6): Exercises on Structs and Dynamic Lists CSCE 110 Dr. Amr Goneid Exercise Sheet (6): Exercises on Structs and Dynamic Lists Exercises on Structs (Solutions) (a) Define a struct data type location with integer members row, column Define another

More information

IV Unit Second Part STRUCTURES

IV Unit Second Part STRUCTURES STRUCTURES IV Unit Second Part Structure is a very useful derived data type supported in c that allows grouping one or more variables of different data types with a single name. The general syntax of structure

More information

CS , Fall 2001 Exam 2

CS , Fall 2001 Exam 2 Andrew login ID: Full Name: CS 15-213, Fall 2001 Exam 2 November 13, 2001 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write

More information

Control Flow: Loop Statements

Control Flow: Loop Statements Control Flow: Loop Statements A loop repeatedly executes a of sub-statements, called the loop body. Python provides two kinds of loop statements: a for-loop and a while-loop. This exercise gives you practice

More information

RLE - Run Length Encoding

RLE - Run Length Encoding RLE - Run Length Encoding Student IONUŢ SILVIU NICULESCU Student CĂTĂLIN BOJA Student ALEXANDRU STANCIU Student IONUŢ BULUMACU Faculty of Economic Cybernetics, Statistics and Informatics, Academy of Economic

More information

CpSc 1111 Lab 4 Formatting and Flow Control

CpSc 1111 Lab 4 Formatting and Flow Control CpSc 1111 Lab 4 Formatting and Flow Control Overview By the end of the lab, you will be able to: use fscanf() to accept a character input from the user and print out the ASCII decimal, octal, and hexadecimal

More information

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177 Programming Time allowed: THREE hours: Answer: ALL questions Items permitted: Items supplied: There is

More information

ECE2049 HW #1-- C programming and Binary Number Representations (DUE 9/1/2017 At the BEGINNING of class)

ECE2049 HW #1-- C programming and Binary Number Representations (DUE 9/1/2017 At the BEGINNING of class) ECE2049 HW #1-- C programming and Binary Number Representations (DUE 9/1/2017 At the BEGINNING of class) Your homework should be neat and professional looking. You will loose points if your HW is not properly

More information

STORING DATA: DISK AND FILES

STORING DATA: DISK AND FILES STORING DATA: DISK AND FILES CS 564- Fall 2016 ACKs: Dan Suciu, Jignesh Patel, AnHai Doan MANAGING DISK SPACE The disk space is organized into files Files are made up of pages s contain records 2 FILE

More information

CS103L PA3 It's So Belurry

CS103L PA3 It's So Belurry CS103L PA3 It's So Belurry 1 Introduction In this assignment you will design and implement a program to perform simple kernel based image processing filters on an image. We will be implementing three filters:

More information