Question: MIPS Assembly language Your task is to write the body of the threshold function that takes in an array of pixels of a grayscale image
MIPS Assembly language
Your task is to write the body of the threshold function that takes in an array of pixels of a grayscale image (one byte per pixel) along with its dimensions and applies binary thresholding. The input image for this part is a square sized grayscale image. For grayscale images, one byte is used to represent each pixels intensity where the possible values range from 0x00 to 0xFF. In other words, the image is stored in a 2D array where each element is a byte.
###############################################################
# Text Section
.text
# Utility function to print byte arrays
#a0: array
#a1: length
print_array:
li $t1, 0
move $t2, $a0
print:
lb $a0, ($t2)
andi $a0, $a0, 0xff
li $v0, 1
syscall
li $v0, 4
la $a0, space
syscall
addi $t2, $t2, 1
addi $t1, $t1, 1
blt $t1, $a1, print
jr $ra
###############################################################
###############################################################
# PART 1 (Image thresholding)
#a0: input buffer address
#a1: output buffer address
#a2: image dimension
#a3: threshold value
###############################################################
threshold:
############################## Part 1: your code begins here ###
(Answer here)
############################## Part 1: your code ends here ###
jr $ra
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
