Image Processing: Sepia Filter

Unpublished

This sample demonstrates how to improve the performance of Sepia filter using Intel® Cilk™ Plus. To demonstrate the performance increase, you will use a program that converts a bitmap file from color image to a Sepia tone image. A Sepia tone image is monochromatic image with a distinctive Brown Gray color that provides a distinctive tone to a photograph when Black & White film was available. The program works by converting each pixel in the bitmap file to a Sepia tone.

Click here for a more in-depth discussion about the sample as well as more information about the design choices of this sample.

 

Code Change Highlights:

  • cilk_for
  • linear version:
    for(int i = 0; i < size_of_image; i++) { process_image_AOS(indata[i], outdata[i]); }
    cilk_for version:
    cilk_for(int i = 0; i < size_of_image; i++) { process_image_AOS(indata[i], outdata[i]); }
    This simple change creates code that ran almost 4x faster on our machine.

Performance Data:

Note: Modified Speedup shows performance speedup with respect to serial implementation.

Modified Speedup Compiler (Intel® 64) Compiler options System specifications
cilk_for: 3.08x Intel C++ Compiler 15.0 for Windows /Qrestrict /W3 /QxAVX /Zi /O2 /Qvec-report2 /Qipo /Oi /MD /EHsc Microsoft Windows Server 2012* (x64)
2rd generation Intel® Xeon® E3 1280 CPU @ 3.50GHz
8GB memory
cilk_for: 4.27x Intel C++ Compiler 15.0 for Linux -restrict -W3 -xAVX -O2 -vec-report2 -ipo -Oi -MD -EHsc Ubuntu* 10.04 (x64)
3rd Generation Intel Core™ i7-2600K CPU @ 3.40GHz
8GB memory

Build Instructions:

  • For Microsoft Visual Studio* 2010 and 2012 users:
  • Open the solution .sln file
    [Optional] To collect performance numbers (will run example 5 times and take average time):
    • Project Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions: add PERF_NUM
    Choose a configuration (for best performance, choose a release configuration):
    • Intel-debug and Intel-release: uses Intel® C++ compiler
    • VSC-debug and VSC-release: uses Visual C++ compiler (only linear/scalar will run)
  • For Windows* Command Line users:
  • Enable your particular compiler environment
    For Intel® C++ Compiler:
    • Open the appropriate Intel C++ compiler command prompt
    • Navigate to project folder
    • Compile with Build.bat [perf_num]
      • perf_num: collect performance numbers (will run example 5 times and take average time)
    • To run: Build.bat run [help|0|1|2|3|4]
    For Visual C++ Compiler (only linear/scalar will run):
    • Open the appropriate MicrosoftVisual Studio* 2010 or 2012 command prompt
    • Navigate to project folder
    • To compile: Build.bat [perf_num]
      • perf_num: collect performance numbers (will run example 5 times and take average time)
    • To run: Build.bat run
  • For Linux* or OS X* users:
  • Set the icc environment: source <icc-install-dir>/bin/compilervars.sh {ia32|intel64}
    Navigate to project folder
    For Intel® C++ compiler:
    • To compile: make [icpc] [perf_num=1]
      • perf_num=1: collect performance numbers (will run example 5 times and take average time)
    • To run: make run [option=help|0|1|2|3|4]
    For gcc (only linear/scalar will run):
    • Compile with make gcc [perf_num=1]
      • perf_num=1: collect performance numbers (will run example 5 times and take average time)
    • To run: make run
For more complete information about compiler optimizations, see our Optimization Notice.