(last update: Mon Aug 15 07:05:15 CEST 2016)
During this course we will develop a client/server system for multithreaded image processing. The system will implement various algorithms, including:
You are provided with a skeleton of the code for the client and server applications (you will need to add the assembly System.Drawing.dll to your project):
You are also provided with some example images in BMP format.
All image processing is performed on the server. The client only loads from a file the images to process, connects to the server, and writes to disk the output image after the server sends them back to the client.
Client and server use the BitTorrent Bencode format to communicate.
The client locates the server using an online database of servers, where previously the server has registered the IP and port on which it receives requests. The server updates this online database using an HTTP request every time it starts. The server uses the Windows Registry to store some configuration.
Client (see the Client.Run method, already given to you):
Server (see the Server.Run method, already given to you):
The RIPS client will be a commandline application with the following syntax:
Usage: Client REQUEST IMAGE1 [IMAGE2] [OPTIONS] Where REQUEST can be one of the following histogram - Outputs the histogram of IMAGE, by default to 'out.txt' bw - Transforms IMAGE1 into grayscales blur - Blurs the image and stores the result, by default, to 'out.bmp' merge - Fuses IMAGE1 (foreground) and IMAGE2 (background) into one single image, output to 'out.bmp' and where [OPTIONS] are zero or more options from the following list: /out:FILE - Saves the result image or histogram in FILE instead of the default file indicated above /nthreads:N - The server will use 2^N threads (default 2, ie, 4 threads used) /contour:N - (only for 'blur') Compute pixel averages using the N surrounding 'rings' (default 3) /alpha:N - (only for 'merge') Set the transparency of IMAGE1 to N percent, where 0% means IMAGE1 is completely opaque and 100% means it is completely transparent (default 50)
Here are some examples of invocation:
Compute the histogram of the file lena.bmp and store it in hist.txt. By default 4 threads are used to perform the computation:
Client.exe histogram lena.bmp /out:hist.txt
Blur the image lena.bmp using 32 threads and mixing the 2 rings of pixels that surround every pixel:
Client.exe blur lena.bmp /nthreads:5 /contour:2
Mix the images lena.bmp and background.bmp into one single image whose pixels are defined as 15% of lena.bmp and 85% of background.bmp. Uses 16 threads:
Client.exe merge lena.bmp background.bmp /nthreads:4 /alpha:15