This project involves developing an algorithm to carry out image interpolation in C, running and optimizing the code in a DSP Processor simulator using Texas Instruments' Code Composer Studio v5.5.
Given a grayscale image of size WxH, interpolate into an image of size 2WxH. i.e., for an input image of size 256x256, the output image size would be 512x256. The code should fill in the extra output pixels by interpolating using the formula - (a+b+1)/2
- Creating/opening the input ("Image1_256x256.raw") and output files ("Image1_512x256.raw").
- Reading from the input file (row by row), and storing the pixel data in a pointer array "rev".
- Calling the function "interpImg", which carries out the interpolation and stores the result in another pointer array "revout".
- Writing to the output file (row by row).
- Closing all files.
For more information regarding the basics of images & image processing -
For more information regarding image interpolation -
Codes for reading raw images -
- https://stackoverflow.com/questions/29760779/reproduce-raw-image-c
- https://stackoverflow.com/questions/26416702/how-can-i-read-a-raw-image-in-c-without-special-libreries
Before running the code in CCS, profiling is added to measure the time taken for running the "interpImg" function. The header file "<c6x.h>" is included and the 64 bit TSC register (timer) is initialized before calling "interpImg", and ended afterwards. "sumcycles" stores the total cycles taken.
For further optimization, we use intrinsics functions to perform SIMD (Single Instruction Multiple Data) operations in the function definition to compute the values of the extra output pixels.
The intrinsics functions used for Image Interpolation include -
_mem4, _amem4, _unpklu4, _unpkhu4, _swap4, _shrmb, _avgu4, _add4
Details on C66x intrinsics are available at Texas Instruments' TMS320C6000 Programmer's Guide -
The values for optimization levels 0, 1, 2, 3 were obtained by changing the levels in the CCS IDE properties window. (Code used - "ImageInterpCCS.c")
The value for optimization level 4 was obtained by selecting level 3 in the CCS IDE properties window and using the code - "ImageInterpOptimized.c", i.e. the code using the intrinsics function.
DSP Simulator details - Device Family: "C6000" , Variant: "Generic C66xx Device", Target Configuration: "C6678 Device Cycle Approximate Simulator", "Little Endian"
For clarifications, contact me at christinapramode@gmail.com

