Placement or arrangement of visual elements may be performed according to a specified color scheme. For example, three popular color schemes are the complementary color scheme, the triad color scheme and the analogous color scheme.
One property of color which distinguishes one color from another is termed color hue and is dependent on the dominant wavelength of light that is emitted or reflected from an object. For example, the range of visible light is generally between infrared light (approximately 700 nm wavelength) and ultraviolet light (approximately 400 nm wavelength). In addition to color hue, the properties of a color include saturation and luminance. For purposes of brevity, the terms ‘color hue’, ‘color’ and ‘hue’ are used interchangeably within the description to denote color hue.
A triadic color scheme uses colors that are evenly spaced around the color wheel 100. For example, in
Analogous color schemes refer to colors which are close on the color wheel 100. For example, red-violet 102, violet 103, blue-violet 104 and blue 105 constitute an analogous color scheme denoted 113. Analogous color schemes are a palette of compatible color combinations that blend well together and typically provide aesthetically pleasing results in terms of human visual perception. Unlike the complementary and triadic color schemes that often create tension in the image, analogous color schemes suggest tranquillity and calmness.
The triad and complementary color schemes are derived from a family of remote color composition schemes. This is in contrast to the analogous color scheme which is based on close colors. Thus, whilst the triad and complementary color schemes may be selected on the basis of artistic intent, the analogous color scheme may be used merely as an attractive visual property which leads to an inherently appealing image, independent of artistic intent.
Colors can be represented using a mathematical model termed a color space whereby a color is represented as a tuple of numbers, typically termed values, components or coordinates. Typically, a color space represents a color as three or four coordinates, as is the case for the well known RGB, CMYK and CIELAB color spaces. For example, the CIELAB color space represents color using the three coordinates L*, a* and b*, where L* represents color lightness, a* represents color position between red-magenta and green, and b* represents color position between yellow and blue.
Features and advantages of the invention will become apparent from the following description of embodiments of the invention, given by way of example only, which is made with reference to the accompanying drawings, of which:
When placing one or more objects into an image, it is often desirable to locate the objects such as to achieve a harmonic composition on the basis of a chosen color scheme. Analogous color schemes are known to exhibit stability and robustness with respect to remote color schemes such as the triad and complementary schemes. The robustness of analogous color schemes can be demonstrated by changing the hue of a dominant color in an image generated or composed according to a particular color scheme. For example, shifting the hue by 30 degrees or one segment of color wheel 100 of
When considering harmony of an image I, it is helpful to introduce a quantitative measure of harmony. This can be achieved by defining a hue standard deviation 0σc,r(I) at a coordinate c=(x,y)εC and within a radius r>0 in image I. This measure provides the standard deviation of the hue values of all objects that are within Euclidean distance r or less from coordinate c. Since the color wheel is cyclic it is not possible to employ the straightforward definition of standard deviation. Instead, we exploit an alternative definition of standard deviation that is computed in two steps. First, given a collection of hues hiεH, an average hue μ is calculated as the value that has the minimum sum of distances to all hues in H:
where ‘arg min’ is used to denote the value of μ for which the value of the given expression attains its minimum value, and brackets ∥ ∥ indicate absolute value. In the second step the cyclic standard deviation is defined as:
where N=|H| is the number of hues in the collection H over which the average is calculated.
On the basis of the hue standard deviation value σc,r(I) at a radius r around a coordinate c in an image I, a measure of the color harmony H(I) of the image can be specified as follows:
where C is the collection of all coordinates in/over which the harmony measure is to be calculated, R is the maximum distance between two coordinates in C, and α is a parameter that typically takes a value of 1. Examination of the harmony measure H(I) indicates that in order to achieve harmony (corresponding to a low value of H(I)) the hue variability should be small in the close neighbourhood but it may turn to be larger when the radius of the neighbourhood increases.
In general, embodiments of the present invention relate to a computer implemented method for generating an image using analogous color schemes such as to optimise the harmony of the image.
The task is to assign or map the plurality of color objects o1-o5 to the plurality of locations p1-p5 such that the harmony of the resulting image is optimised. In the present embodiment the image does not contain color entities in the image (or at least color entities are ignored for the purposes of locating the color objects o1-o5) so the problem is termed an unconstrained problem. This problem can be expressed mathematically as the following color assignment problem:
Given are an image I and a set of objects oεO that have to be assigned to a group of locations pεP (indices ×
), wherein each object oεo has a hue hoε
mod 2 π, assign the color objects in O into locations in P such that the harmony measure H(I) is minimized.
Whilst it is straightforward to arrange color objects in a harmonic fashion along a single dimension, it is generally more difficult to arrange color objects for general two dimensional images. This is mainly due to the fact that there is a linear ordering for one dimension but not for two dimensions. Hence, the hue values can easily be assigned in harmonic fashion along a straight line. On the other hand this task is more challenging for two dimensional images, even for simple harmony metrics as illustrated in the present embodiment.
In the present embodiment, the color of each object oεO (o1-o5 in
In the present embodiment, objects O are assigned to the locations P using a bipartite matching method.
The values a*o, b*o and xp,yp for each object o and position p respectively are normalised to the interval [0,1], using for example the identity function to provide normalised values ã*o, {tilde over (b)}*o and {tilde over (x)}p, {tilde over (y)}p. For example, normalised values ã*o, {tilde over (b)}*o and {tilde over (x)}p, {tilde over (y)}p may be calculated as follows:
Next, a weighting for each of the edges wopεW is defined. Given an edge that connects between an object node uoεU to a location node vpεV the weight wopεW over the corresponding edge eopεE is calculated as follows:
w
op=(ã*o−{tilde over (x)}p)2+({tilde over (b)}*o−{tilde over (y)}p)2. (8)
In the next step it is necessary to find the optimum assignment of object nodes uoεU to location nodes vpεV such that the sum of weights over the assigned edges is minimised (and thus the harmony measure is minimised). The resulting assignment may be termed the harmonic object location pairs. This assignment problem can be achieved using a minimum weight matching algorithm (for example, the Bellman-Ford algorithm or any other suitable algorithm as is known in the prior art). The time complexity for complete balanced bipartite graphs is O(N3), where N is the number of nodes in the bipartite graph. Therefore, in the present case this translates to O(|O|3), where |O|3 is the cardinality of the group of color objects O. An example set of harmonic object-location pairs forming an example optimum solution are shown as bold lines linking nodes U to nodes V in
Once a solution to the assignment problem has been obtained, each color object oεO (o1-o5 in
The hereinbefore described first embodiment of the invention provides a heuristic method for producing an image with a small harmony measure H(I) (thus producing a harmonic image) based on a bipartite graph method. However, it will be appreciated by those skilled in the art that the method does not produce an image that is mathematically guaranteed to minimise the harmony measure H(I) of the resulting image.
In a second embodiment of the present invention, the color objects are assigned to locations such as to optimise color harmony with one or more color entities at fixed positions in the image. In this second embodiment the method comprises a first stage and second stage. In the first stage a spatial color distribution in the image is calculated based on the color entities, and in the second stage the color distribution is used to generate a corresponding bipartite graph which is used to assign color objects to areas in the image that share similar color hues.
The task associated with
Given a set of objects oεO that have to be assigned to a group of locations pεP (indices in ×
) in an image I comprising a set of color entities εC, wherein each object oεO and each color entity cεC has a hue hcε
mod 2π and hoε
mod 2 π respectively, assign the color objects in O into locations in P (i.e., find an assignment from the object space O into the location space L) such that the harmonious measure H(I) is minimized.
Given a plurality of color entities of fixed position in the image (c1-c3 in
where dc is the hue at a color entity c (in the limit the color entity may correspond to a single pixel), dp,c is the distance from location p to c and C is the collection of all color entities in the image. The mean hue at each position hp is calculated only for locations that are in image I and are located within a radius of at most R from a color entity in the given image. Where |O|=|P|, the computation of this step requires O(|O|·N) operations, where N is the number of color entities in the image.
Next, the color objects are assigned to the locations according to the calculated spatial hue distribution. In other words, color objects are matched to areas in the image with similar colors hues. In this step, the assignment reflects only the distribution of hues across the image (due to the color entities). Given the set of all possible locations pεP, we consider only the locations that are within a radius R from a color entity in the given image. For example, referring to
Each link in the bipartite graph connects a color object oεO and an active location paεPa. However, in contrast to the first embodiment, the weight for each edge is calculated as the distance between the hue of the object and the hue in the hue distribution map that was computed in the previous step for the corresponding active location. More specifically, given an edge that connects between an object node uoεU to a location node vpεV the weight wopεW over the corresponding edge eopεE is calculated as:
w
op=(a*p−a*o)2+(b*p−b*o)2 (10)
where a*p and b*p are the (L*,a*,b*) color coordinates in the computed color map at the active location (xp,yp). After the above construction, we can find an assignment of color objects to location using any minimum weight matching algorithm as discussed above in relation to the first embodiment. For convenience, the resulting assignment of harmonic object-location pairs is denoted as A. Referring to
In the previously described embodiment, it is possible that the active locations are fewer than the number of color objects to be assigned. Thus, it is possible that following determination of the optimum assignment there will be one or more unassigned color objects (e.g. the object o4 and o5 corresponding to node u4 and u5 in
Given a network G(V,E) with a cost ce>0, lower bound le>0 and upper bound ue>0 on the flow over each edge eεE, the goal is to find a flow F that satisfies the following constraints: (i) the flow over each link is between the lower and the upper bounds i.e., le≦fe≦ue for each eεE; (ii) flow cannot appear or disappear at nodes i.e.,
for each node vεV where O(v) and I(v) is the collection of all nodes that stem out and get into the node v respectively.
In the following, we exploit this solution to solve our problem as follows. As before we define two sets of nodes U and V where U corresponds to the set of all color objects and V corresponds to the set of all locations pεP. We assign an edge eopεE between each node in U to each node in V with a capacity (i.e., upper bound on the flow) of one unit and a cost ce equal to the weight we previously calculated (for example, see Equation 10). Consider now the assignment A that was computed in the second embodiment corresponding to the optimum assignment of color objects to active locations paεPa. In the present embodiment we set a lower bound of one flow unit over each edge that represents an assignment in A between an object oεO and a location paεPa. The lower bound le is set to 1 for each assigned pair of objects oεO and location pεPa when A(o)=pa (otherwise, we set the lower bound to be zero). This requirement on the minimum flow implicitly states that the assignment defined by A is part of the final solution. Next, we designate a source node, s, connected to each of the nodes in U, and a sink node, t, connected to each of the nodes in V. An edge is defined between the two designated nodes s and t with a lower bound on the flow that equals to the number of objects that are to be assigned in the image (i.e., |O|). The minimum cost circulation problem has an efficient solution with a complexity of O(N3), where N is the number of network nodes. Therefore, the proposed algorithm solves the problem with a time complexity of O(|O|3). Any suitable maximum-flow algorithm, such as the Edmonds-Karp algorithm, may be used to obtain a solution.
It will be appreciated that the embodiments of the present invention and the graphical user interface described hereinabove may be implemented using conventional computer hardware including but not limited to personal computers, mobile phones, personal digital assistants, or printing devices with display functionality. Embodiments of the invention may be implemented using hardware, firmware, software (for example, Java, Pascal, C#, C++, C, CGI, Perl, SQL, APIs, SDKs), or any appropriate combination of the three.
The methods described above may be implemented on a computing device, and example of which is shown in
The invention further comprises a computer program or set of computer programs which when run on a suitable image processing system cause the system to implement the methods described above. The program or programs may be stored on carrier for example a computer readable storage medium. The storage medium may be a hard drive, tape, disc, or electronic storage device. The tape may be a magnetic tape. The disc may be an optical disc, a magnetic disc or a magneto-optical disc for example. The electronic storage may be a RAM, ROM, flash memory or any other volatile or non-volatile memory. The program may be on a carrier which may be a computer readable storage medium or a communication channel, or a signal.
The above embodiments are to be understood as illustrative examples of the invention. Further embodiments of the invention are envisaged. For example, the methods may be applied to vector images in addition to raster or bitmap images. It is to be understood that any feature described in relation to any one embodiment may be used alone, or in combination with other features described, and may also be used in combination with one or more features of any other of the embodiments, or any combination of any other of the embodiments. Furthermore, equivalents and modifications not described above may also be employed without departing from the scope of the invention, which is defined in the accompanying claims.