COEN 20 Programming Lab #9 Image Processing (SIMD Processing, Saturating Arithmetic, Composite Data Types and Inline Code)

$30.00

Download Details:

  • Name: Lab-9-dpal09.zip
  • Type: zip
  • Size: 309.18 KB

Category:

Description

Rate this product

Step 1: You are to implement the following two functions in one assembly language source code file. The
two functions are almost identical except that one adds a constant to every byte in an array, and the other
subtracts a constant from every byte. The addition and subtraction operations are used to increase or decrease the 8-bit unsigned red, green and blue intensity components of the pixels in one row of an image,
so unsigned saturating addition and subtraction must be used to limit each result to the range 0-255.
void SIMD_USatAdd(uint8_t bytes [], uint32_t count, uint8_t amount) ;
void SIMD_USatSub(uint8_t bytes[], uint32_t count, uint8_t amount) ;
These two functions are similar to function SIMD_USatAdd found in Chapter 11 of the text. However, the
loop in that version only processes 4 bytes per iteration while each row of our image contains more than
600 bytes. Every iteration of the loop must check how many bytes remain to be processed and branch
from the bottom to the top of the loop. To reduce this overhead and improve performance, design your
functions to process 40 bytes per iteration instead of four, thus reducing the number of iterations by an
order of magnitude. The total number of bytes in each row is only guaranteed to be a multiple of four, so
you will need a “cleanup” loop to process up to 36 bytes of additional RGB data not processed by the
main loop.
Processing more than 40 bytes per iteration decreases the time per pixel in the main loop, but it also increases the (shorter) execution time of the cleanup loop. Although it’s not usually a significant issue, note
that increasing the number of bytes processed in one iteration of the main loop inherently limits the minimum number of bytes per row and thus the minimum width of the image.
Step 2: Rewrite the C functions Saturate, Between, AssemblePixel, UnpackRGB and PackPXL that appear at the
beginning of the main program as inline functions encapsulating inline assembly. Use IT blocks in functions Saturate and
Between.
Test your code using the main program downloaded from
here. Press the reset (black) pushbutton to start the program.
Touch the “+” or “-” characters to increase or decrease the red
(R), green (G), blue (B) components by the amount displayed.
The intensity (I) value is added to all three of the RGB adjustments when the image is displayed. Touch the image itself to
reset all values to zero.