Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pointers on solving this Image Processing challenge?

Tags:

c++

c

image

The 2nd problem in IOI 2013 states:

You have an Art History exam approaching, but you have been paying more attention to informatics at school than to your art classes! You will need to write a program to take the exam for you.

The exam will consist of several paintings. Each painting is an example of one of four distinctive styles, numbered 1, 2, 3 and 4. Style 1 contains neoplastic modern art. Style 2 contains impressionist landscapes. Style 3 contains expressionist action paintings. Style 4 contains colour field paintings.

Your task is, given a digital image of a painting, to determine which style the painting belongs to.

The image will be given as an H×W grid of pixels. The rows of the image are numbered 0, …, (H ­ 1) from top to bottom, and the columns are numbered 0, …, W ­ 1 from left to right. The pixels are described using two­dimensional arrays R , G and B , which give the amount of red, green and blue respectively in each pixel of the image. These amounts range from 0 (no red, green or blue) to 255 (the maximum amount of red, green or blue).

Implementation You should submit a file that implements the function style(), as follows:

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]);

This function should determine the style of the image. Parameters are:

  • H: The number of rows of pixels in the image.
  • W: The number of columns of pixels in the image.
  • R: A two­dimensional array of size H×W , giving the amount of red in each pixel of the image.
  • G: A two­dimensional array of size H×W , giving the amount of green in each pixel of the image.
  • B: A two­dimensional array of size H×W , giving the amount of blue in each pixel of the image.

Example pictures are in the problem PDF

I do not want a readymade program. A hint or two to get me started would be nice, as I am clueless about this might be solved.

like image 504
Soham Chowdhury Avatar asked Aug 02 '13 08:08

Soham Chowdhury


People also ask

What are the problems in digital images?

Among the most common problems in digital photography are pictures that are incorrectly exposed and are too light or too dark. This problem is usually caused by the camera exposure system reading the background and compensating for it.

Is Digital Image Processing tough?

Not an easy task. Of course, you can attempt to simulate the way we see with two eyes by taking two pictures simultaneously and extracting 3D information from these. This is called stereoscopic vision. However, stitching images together is also not a trivial task and is, hence, likewise an open area of research.


1 Answers

Since you are provided the image data in RGB format, first prepare a copy of the same image data in YUV. This is essential as some of the image features are easily identified patterns in the Luma(Y) and Chroma(U,V) maps.

Based on the samples provided, here are some of the salient features of each "style" of art :


Style1 - Neoplastic modern art

Neoplastic modern art

  • Zero graininess - Check for large areas with uniform Luma(Y)
  • Black pixels at edges of the areas(transition between different chroma).

Style2 - Impressionist landscapes

Impressionist landscapes

  • High graininess - Check for high entropy (salt-n-pepper-noise like) patterns in Luma(Y).
  • Pre-dominantly green - High values in green channel.
    Greenavg >> Redavg
    Greenavg >> Blueavg

Style3 - Expressionist action paintings

Expressionist action paintings

  • High graininess - Check for high entropy (salt-n-pepper-noise like) patterns in Luma(Y).
  • NOT green.

Style4 - Color field paintings

Color field paintings

  • Zero graininess - Check for large areas with uniform Luma(Y)
  • NO black(or near black) pixels at the transition between different chroma.

As long as the input image belongs to one of these classes you should have no trouble in classification by running the image data through functions that are implemented to identify the above features.

Basically it boils down to the following code-flow :

  • Image has uniform luma?
    • (If Yes) Image has black pixels at chroma transitions?
      • (If Yes) Style1
      • (If No) Style4
    • (If No) Image is green-ish?
      • (If Yes) Style2
      • (If No) Style3
like image 52
TheCodeArtist Avatar answered Oct 05 '22 20:10

TheCodeArtist