0% found this document useful (0 votes)
62 views2 pages

CS1032 - Programming Fundamentals (2010 Intake: Semester 1) Programming Assignment 1 - Group C3 Time Allowed: 1 Hour Only Instructions

This document contains instructions for Programming Assignment 1. Students must write a C program to calculate the difference between two black and white images represented as 2D arrays. The program takes the image sizes and two strings of pixel values as input and outputs the difference image with pixels that differ in the two images marked in black. A second part of the assignment involves writing a program that applies a grayscale pixel value operator to a given grayscale image and outputs the new image values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views2 pages

CS1032 - Programming Fundamentals (2010 Intake: Semester 1) Programming Assignment 1 - Group C3 Time Allowed: 1 Hour Only Instructions

This document contains instructions for Programming Assignment 1. Students must write a C program to calculate the difference between two black and white images represented as 2D arrays. The program takes the image sizes and two strings of pixel values as input and outputs the difference image with pixels that differ in the two images marked in black. A second part of the assignment involves writing a program that applies a grayscale pixel value operator to a given grayscale image and outputs the new image values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CS1032 Programming Fundamentals (2010 Intake: Semester 1)

Programming Assignment 1 Group C3


Time Allowed: 1 hour only
Instructions:
1. You must name your source file as "PA1-<StudentNum>.c" and save it in a folder/directory named
"PA1" in your home directory.
2. You have to upload the same source file, "PA1-<StudentNum>.c" onto the Programming Assignment 1
for Group C3 assignment using the given upload facility in Moodle.
3. Make sure you name your source file correctly. Example: If your student number is "101010P", then the
name of your source file will be "PA1-101010P.c"

A black and white image can be represented using a two dimensional array where we have 1 for places
where we have a black dot (or pixel) and a zero for places where we have white dots. Develop a C
program that can calculate the difference between two black and white images. Given two black and
white images, your program should be able to mark (in black) the cells which have two different colours in
the two images. The program should take the size of the images (should be equal) and two strings, where
each string contains the row-major order of the pixel values of the corresponding image, as the input. You
can assume that the maximum possible size of the image is 250 by 250. Sample execution of the
program should be similar to the following:
Enter the number of rows in the images: 2
Enter the number of columns in the images: 3
Enter the details of the first image: 1 0 0 1 0 1
Enter the details of the second image: 1 1 0 0 0 0
Difference between the two images:
0 1 0
1 0 1
The above scenario simulates the following difference.

-

=

You can assume that the input is entered correctly by the user at all times.

CS1032 Programming Fundamentals (2010 Intake: Semester 1)
Programming Assignment 1 Group A3
Time Allowed: 1 hour only
Instructions:
1. You must name your source file as "PA1-<StudentNum>.c" and save it in a folder/directory named
"PA1" in your home directory.
2. You have to upload the same source file, "PA1-<StudentNum>.c" onto the Programming Assignment 1
for Group A3 assignment using the given upload facility in Moodle.
3. Make sure you name your source file correctly. Example: If your student number is "101010P", then the
name of your source file will be "PA1-101010P.c"

A grayscale image can be represented using a two dimensional array where we have an integer between
0 and 255 representing the grayscale value for each pixel. Let P(i, j) represent the grayscale value of the
pixel at the i
th
row and j
th
column. We define a operator which will modify the pixel value to P(i, j), which is
given by;

*Note: P(i, j) is always positive.
Develop a C program that will apply this operator to a given image. The program should take the size of
the image and a string which contains the row-major order of the pixel values of the image. You can
assume that the maximum possible size of the image is 250 by 250. Your program should apply the
operator to each pixel of the image (except for the pixels in the left and right boundary.). Sample
execution of the program should be similar to the following:
Enter the number of rows in the images: 2
Enter the number of columns in the images: 4
Enter the details of the image: 125 228 226 120 254 119 110 252
New matrix after applying the operator:
125 52 52 120
254 63 75 252
*Notice here that the values at the left and right boundaries have not changed.
You can assume that the input is entered correctly by the user at all times.

You might also like