You are on page 1of 3

CENG505L Project1

Image processing using MIPS Assembly: Edge Detection using Sobel Mask
In this project, you are required to apply the MIPS assembly coding and performance measuring
skills you acquired throughout the previous lectures.
In this project you will be coding a well-known image processing algorithm using MIPS assembly.
Sobel for edge detection is an algorithm that helps detecting contours of objects in an image.
Detecting edges requires, in a first step, converting the RGB image into grayscale image. In a
second step, a specific filter named Sobel is applied on the grayscale image in order to obtain the
edges. The resulting image is a black and white image (white on black) (See Figure 1)

Figure 1 Sobel Edge Detection

Steps to follow:

Step1: As a start, I will provide you with two files:

o The first file follow-me-little-fish.txt contains in a sequential row-based order, the
RGB values of each pixel in the image (R1,G1,B1,R2,G2,B2,). Open the file in
Notepad or Notepad++ to verify its content. The image dimensions are 512x256.
o The second file readingimagefromfile.asm is dedicated to read the previous file
(the image) and copies its content into the memory starting location 0x10010000
so the image can be displayed on the bitmap display. If you are curious about how
it is doing that, you can read the code carefully but note that it is not your
responsibility to know how this code is really working.
o Run the code and make sure that it is working correctly. If it is not, verify the
location of the follow-me-little-fish.txt file.
Step2: You need to write the code of RGB to Gray conversion by appending your code to
the readingimagefromfile.asm
The conversion works like follows for each pixel:
- Compute the value I= R x 0,299 + V x 0,587 + B x 0,114
- Copy the same obtained value I to the R, G and B elements of each pixel
The obtained image should be the grayscale image of Figure 1.

Step3: Applying Sobel.

o Sobel algorithm is based on convoluting an image with two masks presented in
Figure 2. The target pixel can be considered to be in middle of the mask. Check
Figure 3 for better illustration.

Figure 2 Sobel Masks

o The convolution using Sx will result with a value that we name Gx and the
convolution using Sy will result with a value that we name Gy . G stands for
gradient. The resultant gradient of a pixel G = abs(Gx) + abs(Gy)
o Note that you do not need to apply Sobel for the pixels located on the borders
of the image
o Note as well, that the value of a pixel is actually I that you computed earlier in
the RGB to grayscale conversion
o An illustration of the convolution procedure is presented in Figure 3
o How to do a convolution with a mask?
By taking the first example in Figure 3, the pixel b22 is computed like
follows for one of the masks:

o Note that, if G > 255 then put G=255.

o The obtained value for a pixel should be replicated on the R,G and B elements
of the pixel
o Note that the final image should be white on black and not black on white; just
like in Figure 1 Sobel Edge Detection

Step4: once the code is functioning correctly, you need to do a full analysis of the
performance of the application using different cache configurations and different BHT
configurations and log all obtained results

What do you need to provide me?


At the end of the project, you need to send me by email your fully commented assembly
code with the name of the groups members
A presentation will be conducted in class in which you will presenting your code, a
simulation and the analysis results. Your analysis should be similar and more advanced
than the one done in class. Your explanation should be clear and well detailed
Any additional well detailed code analysis is most welcomed
An interactive user-machine menu for selecting which image to display is also worthy

Note that a bonus grade will be given to the first group of students that provides me with
a correctly executing code
Note that a cheating tentative will result in a zero on the project grade
Both members of a group should be fully involved in developing and building the project.
A zero grade will be given to un-involved students

Figure 3 Convolution Procedure