Pointers to solving this image processing problem?

The second issue in 2013 IOI is:

You have an art history exam, but you pay more attention to computer science at school than to your art classes! You will need to write a program for the exam.

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 contemporary art. Style 2 contains impressionistic landscapes. Style 3 contains expressionist action pictures. Style 4 contains color field paintings.

Your task, taking into account the digital image of the picture, is to determine what style the painting belongs to.

The image will be presented as a grid of H Γ— W 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. Pixels are described using two-dimensional arrays R, G and B, which give the number of red, green and blue colors, respectively, in each pixel of the image. These amounts range from 0 (no red, green, or blue) to 255 (maximum amount of red, green, or blue).

Implementation You must send a file that implements the style of the function (), 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 :

  • H: the number of lines of pixels in the image.
  • W: 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 number of blue in each pixel of the image.

Sample images are in PDF problem

I do not need a ready-made program. One hint or two to start me would be nice, because I do not know that this can be solved.

+6
source share
2 answers

Since you are provided with RGB image data, first prepare a copy of the same image data in YUV. This is necessary since some of the image functions are easily identified on the Luma (Y) and Chroma (U, V) cards.

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


Style1 - Neoplastic Contemporary Art

Neoplastic modern art

  • Zero grain - check for large areas with a uniform lamp (Y)
  • Black pixels at the edges of areas (transition between different colors).

Style2 - impressionist landscapes

Impressionistist landscapes

  • High Grit - Check for high entropy ( salt-n-pepper-noise, for example ) in Luma (Y).
  • The dominance of green . High values ​​in the green channel.
    Green avg > Red avg
    Green avg > Blue avg

Style3 - Expressionist action paintings

Expressionist action paintings


Style4 - Colored Canvases

Color field paintings

  • Zero grain - check for large areas with a uniform lamp (Y)
  • NO black (or near black) pixels when switching between different colors.

As long as the input image belongs to one of these classes, you should not have any problems with the classification by running the image data through functions that are implemented to identify the above functions.

This basically boils down to the following codestream:

  • Does the image have uniform brightness ?
    • (If yes) Does the image have black pixels in color transitions ?
      • (If yes) Style1
      • (If not) Style4
    • (If not) Is the image green-ish ?
      • (If yes) Style2
      • (If not) Style3
+14
source

Maybe you can make the first approach using colors and shapes ... In a neoplastic modern style, it is likely that there will be only a few colors occupying geometric areas, as in color field paintings.

This can give you the ability to distinguish styles 1 and 4 from styles 2 and 3.

In styles 1 and 4, you have large areas with the same color, but in style 4 the color is rarely a solid color, but the strokes are strokes of shades of color.

In any case, you should study the features of each style, which are the usual colors and methods, and then try to make your function "see" it.

0
source

Source: https://habr.com/ru/post/950887/


All Articles