kfupm stu swe 363

Page 1

Computer Science Department

ICS 233 Lab Report Experiment #: 6

Arrays, Multiplication and Division Date: Team: Section: # ID Number

Student Name

1 2

Item Lab Work + Programs Report Team work Total

Mark Student 1 70 20 10 100

1. 1

Student 2


2. Introduction In your own words, write one paragraph describing the experiment in general. Briefly describe the objectives of the experiment. Do not copy-paste from the lab manual.

2


3. LAB Tasks: 3.1 Part 1: Address Calculation Review in the lab manual how arrays are dealt with. a. For 1-D array: Address(element i) = Starting address + element_size * i b. For 2-D array: Address(element i,j) = Starting Address + element_size*(i*row_size + j) c. Write a procedure that given i j and row_size will compute the address of the element (i,j) in the array Img. Img:

fin: fout: line: buffer:

.data .word 0 1 2 3 4 .word 10 11 12 13 14 .word 20 21 22 23 24 .asciiz "img1.bmp" .asciiz "img2.bmp" .asciiz "\n" .space 300000 .globl main .text

main: la $a0, Img li $t0, 5 #row size li $t1, 1 #row # li $t2, 4 #col # multu $t0, $t1 mflo $t1 addu $t1, $t1, $t2 sll $t1, $t1, 2 addu $a0, $a0, $t1 lw $a0, 0($a0) li $v0, 1 syscall li $v0, 10 syscall

3


3.2 Part 2: Grey Level Conversion Last week you wrote programs to deal with images as arrays. Write a procedure that converts a colored image to a gray level one. Use the following transformation: for (int i = 0; i < imageWidth; i++) for (int j=0; j <imageHeight; j++) { grayRGB[i][j] = 0.212671 * rgb[i][j] + 0.715160 * rgb[i][j] + 0.072169 * rgb[i][j] +; } Make use of the multiplication and division instructions.

3.3 Part 3: Partial Image Modification Write a procedure that modifies only part of the image by converting it to gray. The main program should ask the user to enter the starting and ending locations (row, column) of the block to be converted to gray.

4


\

4. Conclusion In your own words: • Summarize the work accomplished. • Summarize what have you learned from this experiment. • Discuss problems faced in conducting the experiment.

Tasks Accomplished Experience and Techniques learned Problems Faced •

5


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.