5. Image composition

A visually pleasing photo usually has a good composition [5]. If a photo has certain composition characteristics, it is usually more popular than a photo without those. Figure 15 shows some common types of image compositions, which are employed to perceive the beauty of a photo.

Salient regions and prominent lines are two important factors for analyzing the composition of a photo. The salient regions are the perceptually appealing areas, and the prominent lines are

Figure 15. Six types of image compositions: (a) central; (b) rule of thirds; (c) vertical; (d) horizontal; (e) diagonal; (f) perspective.

visually existing edges. In this chapter, we take these two factors as the features fed to an artificial neural network for classifying the possible composition type of an input photo.

#### 5.1. Salient map

Our attention is attracted to salient colors easily, which is a born ability of humans. This ability is important for complex biological systems to rapidly detect potential preys, predators, or mates in a visual world with cluttered objects. Therefore, by finding salient regions, it is possible to find a target object in a cluttered field of view. Locating the salient regions in a photo helps determine the composition of a photo. A salient map can be generated from calculating the salient degree of each color [7] as

$$S(I\_k) = S(\mathbf{c}\_l) = \sum\_{j=1}^n f\_j D(\mathbf{c}\_l, \mathbf{c}\_j) \tag{13}$$

where Ik i s the salient degree of pixel k, cl is the color l in the CIELab color space, cj is the color j in the CIELab color space, D(x, y) is the color distance between two colors x and y in the CIELab color space, and fj is the probability that color j appears in photo I. Figure 16 illustrates an example of finding the salient map of a photo.

Figure 16. Illustration of finding the saliency map: (a) the original photo; (b) the grayscale photo of (a); (c) the saliency map of (a).

On the Design of a Photo Beauty Measurement Mechanism Based on Image Composition and Machine Learning http://dx.doi.org/10.5772/intechopen.69502 109

Figure 17. Illustration of a mosaic of 5x5 blocks resulting from the saliency map for each of six image compositions: (a) central; (b) rule of thirds; (c) vertical; (d) horizontal; (e) diagonal; (f) perspective.

The saliency map is further simplified into a mosaic of 5 x 5 blocks. The value of each block is calculated by averaging the salient degrees within the block. An illustration after simplification for each image composition is shown in Figure 17.

#### 5.2. Prominent line

visually existing edges. In this chapter, we take these two factors as the features fed to an artificial neural network for classifying the possible composition type of an input photo.

Figure 15. Six types of image compositions: (a) central; (b) rule of thirds; (c) vertical; (d) horizontal; (e) diagonal; (f)

Our attention is attracted to salient colors easily, which is a born ability of humans. This ability is important for complex biological systems to rapidly detect potential preys, predators, or mates in a visual world with cluttered objects. Therefore, by finding salient regions, it is possible to find a target object in a cluttered field of view. Locating the salient regions in a photo helps determine the composition of a photo. A salient map can be generated from

> j¼1 f j

where Ik i s the salient degree of pixel k, cl is the color l in the CIELab color space, cj is the color j in the CIELab color space, D(x, y) is the color distance between two colors x and y in the CIELab color space, and fj is the probability that color j appears in photo I. Figure 16 illustrates

Figure 16. Illustration of finding the saliency map: (a) the original photo; (b) the grayscale photo of (a); (c) the saliency

Dðcl, cjÞ ð13Þ

<sup>S</sup>ðIkÞ ¼ <sup>S</sup>ðclÞ ¼ <sup>X</sup><sup>n</sup>

5.1. Salient map

perspective.

108 Perception of Beauty

map of (a).

calculating the salient degree of each color [7] as

an example of finding the salient map of a photo.

The Hough transform is used for finding prominent lines in a photo [8]. The prominent lines are the perceptual straight lines which appear in a photo. To detect the prominent lines, the edge detection must be performed first. The Canny edge detector is chosen in our proposed method. After the edge detection, prominent line detection is executed to detect straight lines in the photo, and the Hough transform is chosen as the detector. The concept of Hough transform is to transform the positions of all edge pixels in rectangular coordinates into polar coordinates, and select the transformed coordinates with more occurrences as the detected lines. What follows is the detailed procedure of prominent line detection.

Given a point (p, q)=(rcosθ, rsinθ) on a line, let (x, y) be the other points on the line. Then

$$\frac{\Delta y}{\Delta x} = \frac{y - q}{x - p} = \frac{y - r\sin\theta}{x - r\cos\theta} \tag{14}$$

Because the slope of the line perpendicular to a straight line can be represented with tanθ, the slope of the straight line is:

$$-\frac{1}{\tan\Theta} = -\frac{\cos\Theta}{\sin\Theta}\tag{15}$$

Combining the above two equations yields

$$\frac{y - r\sin\theta}{x - r\cos\theta} = -\frac{\cos\theta}{\sin\theta} \tag{16}$$

And the resulting equation can be rewritten as

$$y\sin\theta - r\sin^2\theta = -\mathbf{x}\cos\theta + r\cos^2\theta\tag{17}$$

Through some mathematical manipulations, the equation of the straight line becomes

$$x\cos\theta + y\sin\theta = r\tag{18}$$

By substituting the coordinates x and y of every pixel located in the edges to the above equation, many possible combinations of r and θ are acquired, where the range of r is 0 < r ≤ ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi width<sup>2</sup> <sup>þ</sup> height<sup>2</sup> q and the range of θ is �90� < θ ≤ 90�. Therefore, we choose the combinations whose occurrences exceed a given threshold. The chosen combinations correspond to the prominent lines.

The results obtained from the prominent line detection performed on the photos of different compositions are demonstrated in Figure 18 associated with the histograms of detected line orientations, respectively. In each histogram, the scope of 180 angle degrees is uniformly partitioned into 10 bins; that is, each bin contains 18 angle degrees. In the horizontal axis of a

Figure 18. The detection results of the prominent lines appearing in six photos of different image compositions associated with their respective histograms of detected lines: (a) central; (b) rule of thirds; (c) vertical; (d) horizontal; (e) diagonal; (f) perspective.

histogram, bin 1 represents 89 to 72, bin 2 represents 71 to 54, …, and bin 10 represents 73 to 90. The vertical axis of the histogram means the percentages of the 10 orientations of the prominent lines appearing in a photo.
