Lomographic filters

Project goal

Develop a lomographic filter. Secondary objectives are: learn how to use a trackbar to specify filter parameters, and improve filter performance through a lookup table (LUT) to improve the performance of the lomographic filter.

Project description

Historically, lomography filters are used to modify a photograph to improve its aesthetics. Lomography is also used in modern applications such as Instagram to make images visually more pleasing.

What is lomography?

Lomography is named after the Soviet-era cameras produced by Leningradskoye Optiko-Mekhanicheskoye Obyedinenie (LOMO). Lomography is claimed by Lomographische AG as a commercial trademark but has become a genericized trademark. A number of photo editor applications include a lomo filter.

High-level solution steps

Develop two lomographic filters. The first filter will manipulate the red channel of an RGB image using a LUT, which is computed using the following expression:

\[\text{LUT}_i = \frac{1}{1 + e^{-\frac{(i/256)-0.5}{s}}}\]

where \(s\) is a parameter, and \(0.08 \leq s \leq 0.20\). Since we use 8-bit images, the value of \(i\) varies from 0 to 255. This expression makes dark pixels darker and bright pixels brighter.

The second filter will provide a vignette effect by applying a dark halo to the image. The radius \(r\) of the halo circle is a parameter for the second filter, and \(1 \leq r \leq 100\).

Develop a simple Graphical User Interface (GUI) and use two trackbars to specify values for the parameters \(s\) and \(r\).

Running/testing the solution

Invoke your solution with the following commands:

  1. lomo -h displays information about how to use the solution.
  2. lomo <image-file-name> to start the application to apply lomographic filters on image named <image-file-name>
  3. Terminate the application when the user presses q on the keyboard.
  4. Save a copy of the image when the user presses s. Prompt the user for a file name.

Details of solution steps

  1. Parse the command line. You can create your own parser or use the class CommandLineParser provided by OpenCV.

  2. Set up two trackbars and display the image. Keep the default for color trackbar at 0.1 and that for the halo effect at 100. Since the trackbars can take only integer values as parameters, set 0 to 20 as the range for color trackbar. Divide this value by 100 to provide a suitable parameter value for the callback function. Also, ensure that you ignore any value below 0.08 as such values will cause undesirable effects.

Trackbar callback function

  1. Create a 1D LUT of 256 elements. It is a \(1 \times 256\) of type #CV_8UC1#. Populate it by evaluating the expression specified above. The callback will recompute this LUT as the value of parameter \(s\) is modified.

  2. Decompose the input image into its three channels by using the function split() function. Apply LUT to the red channel (channel 2).

  3. Merge the three channels back into a single output image and display it.

Halo callback function

  1. The input to halo filter is the output image from the color filter. If the color filter has not been activated, copy the input image into the output image of color filter. Make sure that you perform a deep copy (use Mat::copyTo() function).

  2. Create a 3-channel floating point matrix of the same size as the original image (Open CV type #CV_32FC3#). Assign to each element of this matrix the value 0.75.

  3. Compute the maximum radius of the halo as the minimum of number of rows and columns in the image. Use the percentage from the trackbar to draw a circle of radius \(r\) – percentage of maximum radius. Each pixel in this circle is assigned the value 1 (white).

  4. Use the blur() function with a kernel of $r \times r$ on the halo matrix.

  5. Convert the resulting color image into a 32-bit floating point image (#CV_32FC3#). Multiply the output of color filter with the halo filter. Convert the result in 8-bit image (#CV_8UC3#) and display the resulting image.

  6. Catch any exceptions thrown by OpenCV functions.

Reflecting on the learning experience and teamwork

Reflect on your solution to the problem and the learning experience through this project. Trust building, connectedness, and psychological safety are the foundational elements of teamwork. Reflect on the team dynamic experienced in this project.

Team member contribution/effort assessment

Use the following rubric to rate yourself and your teams members on a scale of 1 to 5 about their individual contribution to the project (a rating of 1 being poor and 5 being outstanding). Also, please provide rationale for each rating.

Self-assessment Assess team member 1 Assess team member 2
Responsibilities/ Performance Rating Rationale Rating Rationale Rating Rationale
Attended classes and group meetings
Initiated communication and interaction with group members
Contributed and committed to the group project
Provided comments and feedback in group work
Demonstrated a positive attitude towards to the project
Any other comments

Rubric for self-assessment and grading

Use the following rubric for self-assessment and peer grading. Also, the instructor will use the same rubric for grading the project. The final grade for the project will be based on scores from the self-assessment, peer-grading and instructor grading.

Good Fair Poor
Conformance to Specifications (40 points) The program works correctly and meets all of the specifications. (40 points). The program works correctly but implements less than 50% of the specifications. (30 points) The program produces incorrect results or does not compile. (10 points)
Data Structures and Algorithms (20 points) Appropriate and efficient data structures and algorithms are used. (20 points) The data structures and algorithms used get the job done but they are neither a natural fit nor efficient. (10 points) Solution is based on brute force approach. No consideration is given to selection of suitable data structures and algorithms. (5 points)
Testing (20 points) Coverage of test cases is comprehensive. Following information is provided for test cases: inputs, expected results, pass/fail, and remarks.(20 points) Coverage of test cases is low. Test case documentation is incomplete. (10 points) Cursory treatment of testing. No documentation of test cases. (5 points)
Coding (10 points) The code is compact without sacrificing readability and understandability. (10 points) The code is fairly compact without sacrificing readability and understandability. (5 points) The code is brute force and unnecessarily long. (2 points)
Readability (5 points) The code is well organized and very easy to follow. (5 points) The code is readable only by someone who knows what it is supposed to be doing. (3 points) The code is poorly organized and very difficult to read. (1 points)
Documentation (5 points) The code is self-documenting and obviates the need for elaborate documentation. It is well written and clearly explains what the code is accomplishing and how. (5 points) The documentation is simply comments embedded in the code with some simple header comments separating functions/methods. (3 points) The documentation is simply comments embedded in the code and does not help the reader understand the code. (2 points)


Back to course home