Median Filters C with shared memory and forks

Job ID: 33889928

Budget: $10 – $30 USD

One of the most used filters in this sense is the median filter, where the central element of a region is replaced by the median of its neighbors.

For example, the figure below illustrates an example of calculating the median for the central pixel of the region shown. The adopted mask has a size of 3 x 3. The upper matrix presents the original pixel values. Pixels (3.3), (2.4) and (4.4) represent noise. The vector of the intermediate region presents the pixels sorted in ascending order. The middle value is substituted for the center pixel, as shown in the lower matrix. A problem related to the Median filter is linked to the ordering of the neighborhood of pixels, which constitutes a very expensive processing time step.

Within this context, write a program that reads an image in 24-bit BMP format and applies a median filter of NxN on the image. The result must be written to an output image. Afterwards, the program must be parallelized using process creation and shared memory area. The mask size and the number of processes must be received as parameters by the program. Make tests evaluating the execution time with masks of different sizes 3x3, 5x5 and 7x7, using 1, 2, 3 and 4 processes. Finally, evaluate the performance of the program by calculating the speedup and efficiency.

Redeploy the same program using the Pthreads thread library. Afterwards, redo the runtime tests with masks with the same mask sizes, using 1, 2, 3 and 4 threads. Present the results by calculating the speedup and efficiency.
Related categories: C Programming Image Processing