Method of changing a color in an image

Abstract: A method for varying the color of an image including lines and background. Where the image includes the colors black and white and a plurality of gray pixels, where gray refers to the presence of pixel values between the maximum and minimum pixel values, inclusive, the image is first converted to a color space, such as for example, r, g, b (red-green-blue). Pixel values are thresholded for differentiation between lines and background. When pixels have a value indicating that the pixel is background, that pixel is set to a background color that has been previously selected. Otherwise, that pixel is set to a foreground color. The result is that background is set to a single color, and lines are set to a second color. Alternatively, where intermediate values are present, the foreground color value may be added to the intermediate level color value to produce a gradually varying colored line.

Description: The present invention relates generally to color imaging, and more particularly, to varying the colors of lines and background in images. Black and white photos and line art images are available from many sources for integration into documents. In electronic document creation this is easily done on several possible levels, including the derivation of the black and white image by scanning. Alternatively, a large number of computer systems still produce images that are black and white. In either case, in the production of colored documents, it is often desirable to convert black and white images to colors to produce a visually pleasing result. In broader terms however, it is desirable to convert lines or background of any color to other colors on a differentiated basis. U.S. Patent US-A-4,608,596 to Williams et al. discloses a system for the colorization of monochrome video frames under operator control including a video color encoder. The encoder has a luminance input and a plurality of color component inputs. The luminance signal is derived from a monochrome video signal, and an operator assigns color component signals to selected regions of pixels of the video frame. The color video output of the color video encoder can be displayed and recorded. U.S. Patents US-A-3,706,841 and 3,784,736, both to Novak, disclose methods for converting black and white monochrome images to multi-color pictures. The method uses a video camera to scan a black and white monochrome image. Luminance values of the scanned black and white image are combined with selected color signals to create a colorized image. Additionally, in the '736 patent, the image can be separated into foreground and background memories, which may be operated on independently. U.S. Patent US-A-4,862,256 to Markle et al. discloses a method of coloring a black and white video signal in which different parts of a frame are assigned a particular color on the basis of gray levels or luminance values. Japanese Patent JP-A-57-99088 to Watanabe discloses a system for providing a simulated color picture from a black and white picture. In the system, a color subcarrier signal is arbitrarily selected and synthesized to provide a simulated color picture. Japanese Patent JP-A-60-141093 to Mizuguchi discloses a method of coloring a picture. The picture is converted to a video signal and a luminance signal is separated from it. As a result of a coloring process executed on the basis of a profile picture formed from the video, a chrominance signal is output, and mixed with the luminance signal. EP-A-0 305 126 discloses an image processing apparatus in which a multiple-value circuit converts image signals into multiple-valued data by comparing the image signals with predetermined threshold value data. A detachable external storage stores the threshold value data. An object of the present invention is to provide a method for varying the color of lines and background in an image on a differentiated basis. In accordance with one aspect of the invention, there is provided a method of changing a color in an image, the image being defined by pixels, each pixel having a value indicative of an optical density value of the image at a discrete point therein, and where the image includes lines and background, lines including a set of pixels having optical density values distinct from optical density values of pixels in the background, the method including changing a color of the lines and the background, characterised by: a) converting the value of each pixel to a combination of a red value, a green value and a blue value, where combinations of red, green and blue values define all possible colors in a color set, and any black value is converted to a combination of a red, a green and a blue value where the red value=green value=blue value; b) selecting a foreground color, identified in terms of red, green and blue values; c) selecting a background color, identified in terms of red, green and blue values; d) comparing the red, green and blue values of each pixel to a reference value; e) determining from said comparison whether the pixel is a background pixel or a foreground pixel; f) for any pixel not determined to be a background pixel, adding to said pixel value the red, green and blue values identifying said foreground color; and g) for any pixel determined to be a background pixel setting the value of said pixel equal to the background color, identified in terms of red, green and blue values. When pixels have a value indicating that the pixel is background, that pixel is set to a background color that has been previously selected. To maintain gray gradations of lines in the image, the foreground pixel values are set to the pixel value plus the selected foreground color value. The result is that background is set to a single color, and gray lines are set to a foreground color that maintains a range of density values. Solid black lines are converted to the foreground color without density gradation. In accordance with yet another embodiment of the invention, using a second comparison step, foreground pixels are detected separately from background pixels. Accordingly, pixels that are neither foreground or background pixels may be treated in a separate manner, which includes no treatment at all. The present invention will be described further, by way of example, with reference to the accompanying drawings, in which:- Figure 1 shows a step-by-step flow chart of a reduced color set selection process in which the invention might find use; Figure 2 shows the memory mapping of the color set in an 8 bit system which allows a standard color set and modified color set to exist on a single display; Figure 3 shows a user interface, usable in association with the described invention; Figures 4A and 4B show flow charts of the present method that varies the color of lines and background in an image on a differentiated basis; and Figure 5 shows an alternative embodiment of the invention. With reference now to the drawings, where the showings are for the purpose of illustrating an embodiment of the invention and not for the purpose of limiting same, Figure 1 shows a flow chart of a color editing process that will be referred to in describing the invention. High quality, high density CRT displays reproduce color images in red, green and blue components. Each pixel in the color image, produced in accordance with several known processes, may be defined with a 24 bit value, which provides three color separations, each represented by an 8 bit value. Accordingly, the color set or palette available for use in such displays has about 16 million colors. In the embodiment described, a Sun Microsystems workstation having 8 bit deep graphics, with a Unix operating system was used for color modification of images. Sun Microsystems workstations are the product of Sun Microsystems, Inc. of Sunnyvale, CA. The workstations used in the development of the described invention may be characterized as personal minicomputers, with multitasking operations. User data entry at the workstation is typically provided through a keyboard and a mouse. Of course, such features are not required, and other processors and data entry devices are possible. The graphics display used was a standard Sun Microsystems 1152 X 900, 8 bit deep display. Programs implementing the described invention were produced in the "C" language. The user interface that will be further described hereinbelow was produced using the X-Windowing System software, from the Massachusetts Institute of Technology, Cambridge, MA. A similar user interface development tool is the Sun X-News software, a proprietary software of Sun Microsystems, Inc. Of course, other graphics display systems, and other software may be used to the same effect as those used to produce the present invention. Another suitable device for implementing the present invention might be one of the Macintosh II family of products, produced by Apple Corporation of Cupertino, CA. In an example system for editing color images, color images are provided at 256 3 different density levels. This number of levels is generally considered too complex to easily deal with. It is preferable therefore to provide a simple method of handling data, utilizing a reduced color set, representative of the color used in the original image. With reference to Figure 1, at a first step 10 to producing an approximation or representative reduced number color set, each separation is handled separately from its complements. Using the red separation, labeled RED, as an example, the intensity value, typically an 8 bit value providing up to 256 levels of intensity (or optical density), is encoded at a step 20 to a much smaller value between about 3 levels and 8 levels of intensity. The number of levels chosen for each separation now represent the full range of each color, albeit with more widely spaced intervals. The number of levels retained is selected based upon experimentation to determine a number of levels that produce an aesthetically pleasing reduced color set for display purposes. It is, of course, important that the reduced color set to be produced have an appearance close to the original image, or color modification will have no value. Since a simple threshold application, which could be used, will produce undesirable image artifacts, a conversion which smooths the image across levels of conversion is desirable. Several well known dithering and/or error conversion methods are known for this purpose. The well-known Floyd-Steinberg Error Diffusion Algorithm (1976), or one of many derivative error diffusion methods, distribute the difference error derived in the encoding arrangement over adjacent pixels for image smoothing. It has been determined that the number of levels N x , of each color for a set which suitably approximates the original color image is approximately 4 red levels (N R ), 8 green levels (N G ), 3 blue levels (N B ). There are a number of other combinations, including 5 red levels, 5 green levels, 4 blue levels; or 5 red levels, 6 green levels, 3 blue levels. Other schemes are possible and depend for their desirability on the user's perception of the color accuracy of such approximations. In this process, black images must be converted to r, g, b values, where r = g = b (see step 10). In step 30, the new color values of the color separations are combined to produce a single index number for each pixel, that indicates one of the r, g, b triplets possible in the index of the reduced color set. Using the set of 4 red levels, 8 green levels, 3 blue levels, derives a total of 96 color levels or triplets (N R X N G X N B ). Thus, each pixel in the original image having 16 million possible colors is represented by one of these triplets, by mapping through the LUT, through the index of numbers indicating the reduced color set. The color index is created by taking combinations of the amounts of red represented by N R levels of red, the amounts of green represented by N G levels of green, and the amounts of blue represented by N B levels of blue. Together, the 96 levels or triplets will be referred to as the "standard color look up table". Aesthetically, it has been determined that a limited number of color levels, in the range of 27-120 levels, serves as an adequate representation of the original color image. Particularly satisfactory results are found in the range of about 90 to 100 levels. The lowest number of levels usable depends somewhat on user perception, but also on the resolution of the display. On a relatively high resolution display, the problem of noise created through the use of the error diffusion or thresholding algorithms is minimized. Obviously, control of color rendition that will ultimately be applied to the original image is not as fine as with a larger number of levels, but for many purposes, the lower number of levels may suffice. The highest number of levels is preferably selected as 120, although a higher number of levels, up to 256 levels, may be used in accordance with the invention. Similarly, if a ten bit graphics system is used, the limit would be 1024 levels. Beyond about a 16 bit graphics system, however, the advantage of the invention is lost in the increased computational time. At step 35, the reduced color set r, g, b image is displayed. As shown in Figure 2, color tables are stored in a 256 level look up table 33 (LUT 33) in the described 8 bit graphics system, with the mapping of Figure 2, where the standard color table is stored in a portion 32 of LUT 33. Portions 34 and 36 are free space for colors that are unique to other display applications. Portion 38 is a modified color table, that will be explained hereinafter. If more than 128 levels are desired for color modification, there may be room for only a single LUT. Two look up tables are desirable so that other images or portions of the image being modified on the display, may be mapped to a standard color LUT, and are not modified simultaneously with the subject image. At step 50, modification of the color image may occur in a manner similar to that of a color television set, which most users are familiar with. User interface I may be used for the selection of foreground and background colors. User interface I allows selection of foreground and background colors through color manipulation in hue, saturation and brightness. The control operation is converted to variations in r, g, b values. Additional controls, 46, 47, 48, and 49 respectively labeled "Original", "Cancel", "Apply" and "Foreground/Background", represent functions for the application of color modifications to the image, where "Original" toggles the displayed image between the original color LUT and the modified color LUT, "Cancel" cancels or nullifies any changes made to the displayed image to return to the appearance of the original, as defined by the standard color LUT, "Apply" actually applies the changes specified by the sliders to the image, as will be explained hereinafter, and "Foreground/Background" indicates whether foreground or background color is being selected. In a possible arrangement, the sliders or "gauges" 44 are selectable and dragged to appropriate positions with a mouse-driven cursor (not shown), while the additional controls are areas for selection by the mouse-driven cursor for activation of those functions. Of course, the displayed controls might be on a touch screen, activatable by user touch. An additional feature that may or may not be provided at the user interface is selection of a threshold level or levels which define a level at which lines or background are distinguished from the remainder of the image. Modifications made to the color set in the standard color table 32 create a new color set in the modified color table 38. In turn, the new r, g, b triplets defined as a result of the conversion are displayed (step 60) to reflect the changes. Since only a small number of values (27-120) are being changed, the modification made at the user interface I of Figure 3 are applied to the displayed image in essentially real time. At step 70, once a desired color modification is derived, changes made to the image that are stored may be applied to the original image. This operation is not expected to occur in real time, and may be referred to a high speed computer on a network for processing. Alternatively, and because the user expects the delay and can select the time of its occurrence, the user's processor on the user's own workstation may apply the luminance/chrominance equations to the 24 bit/pixel data. At step 80, the newly modified 24 bit/pixel data is again displayed on the workstation, in the reduced color set mode. The image displayed may vary slightly from the image as modified, since many imaging artifacts that appear on the screen during modification are removed when the underlying original image is changed. It will of course be appreciated that when speaking about an "image", the reference is to that portion of an entire image for which modification is desired. Accordingly, the color of an entire image may be varied, or the color of only a user defined portion of the image might be varied, through standard area definition methods. In accordance with the invention, and with reference to Figure 4, a flow chart is shown demonstrating the inventive process, modifications to the LUT values at step 50 of the Figure 1 method occur as follows: an area of interest (step 210) is selected in accordance with any of several well known area selection routines that define one or more pixels as in an area of interest. Pixels in the areas of interest are mapped to LUT portion 38, which initially, may have the same values as LUT 32. It will, of course, no doubt be appreciated that the area of interest could be the entire image, and accordingly, no actual selection of an area would be required. At step 215, any "black" in the system is converted to an r, g, b triplet where r = g = b. By black, the reference herein is to a color black, as opposed to some combination of r, g, b. In the case of "full black", i.e., the darkest black possible, the values of r, g and b are taken as the densest value of each that is possible in the system. For grays, the values will be more than the densest value of each that is possible in the system. Entries into the r, g, b lookup table are made in accordance with the described encoding method, so that for each different black or gray level value present in the image, the pixels having that black or gray level are mapped to an r, g, b triplet in the r, g, b lookup table. It will be understood that pixels to be modified are mapped to LUT portion 38, while non-modified pixels remain mapped to LUT portion 32. Image values are selected and set for establishing a background color r b , g b , b b (step 220) and foreground color r f , g f , b f (step 230) to differentiate background from lines (which for the purpose of this disclosure are considered "foreground"). In the context of the limited set of encoded values used in the color selection method, this entails selecting an r, g, b triplet that represents the desired output colors. This may be done via the UI I of Figure 3, which applies changes to an r, g, b triplet for storage in a standard look up table. The next part of the process is dependent upon whether the process is used in the interactive color editing scheme described as an embodiment herein, or in a scheme where each pixel is identified by an individual value r, g, b, such as in the conversion of the original image in background processing. In the interactive color editing scheme defined, pixels to be modified are defined only by a reference to one of a limited number of entries in LUT 38. Thus, at step 250, a determination is made as to whether each color the look up table color in the selected area is a background or foreground color, by thresholding the values of the r, g, b triplets in LUT 38, to which the pixel is mapped, in comparison to a selected threshold level. A reasonable value for this threshold level is taken to be 75% of the maximum white value of the system, or, in a system where white = 255, a threshold level or value is established at 196. Where the color or r, g, b triplet to which the pixel is mapped is equal to or exceeds the value of 196, the pixel is deemed to be background. The color or r, g, b triplet to which the pixel is mapped is tested to determine if R ≥ threshold AND G ≥ threshold AND B ≥ threshold. This is an AND function, and therefore, to find that a pixel is a background pixel, all three tests must be met. Accordingly, highly saturated colored lines are treated as foreground pixels, as the test for background pixels is not met by such pixels. Each background color is then converted to the selected background r b ,g b ,b b triplet (step 260). Pixels mapped to those colors change in appearance at the display. By using the look up table for the comparison process, with its limited number of entries, rather than proceeding on a pixel-by-pixel basis, significant speed of processing is obtained. With reference to Figure 4B, in a scheme where each pixel is identified by an individual value r, g, b is used, then the comparison step 250a asks whether, for each pixel value P(r,g,b), is the r, g, b value of the pixel is greater than a threshold. If it is, at step 260a, the pixel value is set to r b ,g b ,b b . In the simplest embodiment of the invention, all colors (Fig. 4A) or pixel values (Fig. 4B) that are not background colors or pixel values, are determined to be foreground colors or pixel values (step 300, 300a), and the color of the look up table entries or the pixel values are changed accordingly. In one embodiment of the invention, shown in Fig. 4A and 4B, a mode of color replacement choice is provided at step 290. If mode = replace, then each look up table color (Fig. 4A) or pixel value (Fig. 4B) that is determined to have a foreground value, is set to the foreground r, g, b triplet (step 300, 300a). In a slightly more complex case of the invention, if mode is not equal to replace, then at step 320 and 320a, color r, g, b or pixel value P(r,g,b) is set to either r, g, b + r f , g f , b f (for color in LUT 38) or P(r,g,b) + r f , g f , b f (for pixel values). The effect of this choice is that for black lines, which are commonly represented as 0 in a system where white = 255, the color or pixel will have a set of r, g, b values = r f , g f , b f . However, in the case where the line is gray, where r = g = b ≠ 0, the new color or pixel will have a value that is offset from the gray value by the values r f , g f , b f , or alternatively, the color selected will have the gray density gradation imposed on it, and reflect the gray gradation of the line that is converted to color. A similar effect is noted for the conversion of lines having fully saturated color, and lines have less than fully saturated color. To accomplish this change, at step 330, selected color value r f , g f , b f is added to the then current color value mapped to the particular pixel in the LUT 38. Step 330 is not necessary in the Fig. 4B embodiment. In yet another variation of the invention, and as shown in Figure 5, after determining whether the color or pixel is a background pixel, a subsequent determination may be made as to whether the pixel is a foreground pixel. (This embodiment is shown only for the Fig. 4B embodiment, although equally applicable to the Fig. 4A embodiment.) This is accomplished at step 410, by comparing the color or pixel value determined not to be a background pixel to a second threshold level, where a threshold is selected to identify black lines. By setting a threshold, for example at 25% (or 75% of white value), mostly gray images that do not approach the density of black will be excluded from the foreground color replacement. This may be of interest, so that lines may be varied in color and background may be varied in color, while gray images stay the same, or are converted to a third color. Threshold levels that have effective aesthetic values might be in the range of 15-30%. It will no doubt be appreciated that other mechanisms for mapping a color to a particular pixel exist, aside from the described reduced color set method herein described. It will also be appreciated that while the particular gray level imposition method is the addition of a desired color in a system where black is given as the minimum in the system and white is the maximum, an equivalent operation is available in systems where black is given as the maximum in the system, and white is the minimum. Alternatively, a conversion step for converting from one system to the other could be provided. The principle of the invention as described and claimed simply requires that an operation be accomplished where the gradation of the original pixel can be imposed on the color to be substituted. The invention has been described with reference to a particular embodiment. Modifications and alterations will occur to others upon reading and understanding the specification taken together with the drawings. This embodiment is but one example, and various alternatives, modifications, variations or improvements may be made by those skilled in the art from this teaching which are intended to be encompassed by the following claims.

Claims: A method of changing a color in an image, the image being defined by pixels, each pixel having a value indicative of an optical density value of the image at a discrete point therein, and where the image includes lines and background, lines including a set of pixels having optical density values distinct from optical density values of pixels in the background, the method including changing a color of the lines and the background, characterised by: a) converting the value of each pixel to a combination of a red value, a green value and a blue value, where combinations of red, green and blue values define all possible colors in a color set, and any black value is converted to a combination of a red, a green and a blue value where the red value=green value=blue value; b) selecting a foreground color, identified in terms of red, green and blue values; c) selecting a background color, identified in terms of red, green and blue values; d) comparing the red, green and blue values of each pixel to a reference value; e) determining from said comparison whether the pixel is a background pixel or a foreground pixel; f) for any pixel not determined to be a background pixel, adding to said pixel value the red, green and blue values identifying said foreground color; and g) for any pixel determined to be a background pixel setting the value of said pixel equal to the background color, identified in terms of red, green and blue values. A method as claimed in claim 1, characterised in that as black values vary, the combination of red, green and blue values to which black values are converted varies. A method as claimed in any one of claim 1 or claim 2, characterised in that the selected reference value is almost a white value. A method as claimed in claim 3, characterised in that the almost white value is greater than 70-85% of a maximum possible white value. A method as claimed in claim 3, characterised in that the almost white value is selectable over of a range of values representing a value distinguishing between background pixel values and foreground pixel values. A method as claimed in claim 1 characterised in that: a) the pixel values which indicate the optical density values within the image are defined in terms of gray values varying over a range of white to black; b) the lines in the image include a set of pixels which have gray values other than white; c) the gray value of each pixel is converted to a combination of red, green and blue values, and black values other than full black are converted to a combination of red, green and blue values where the red value = green value = blue value; d) the red, green, and blue pixels are compared to a reference value which is a threshold value selected to identify background pixels; e) said comparison is used to determine whether the pixel is a background pixel; f) for each background pixel so determined, changing said pixel value to the background color; g) each pixel not determined to be a background pixel is next compared to a reference value which is a threshold value selected to identify foreground pixels; h) determining from said comparison whether the pixel is a foreground pixel; i) the red, green, and blue values identifying said foreground color are added to the pixel value of each line pixel determined to be a foreground pixel; and j) for any pixel determined not to be either a foreground pixel or a background pixel, applying neither the foreground or background colors to said pixel. A method as claimed in claim 1 characterised in that: a) the set of pixels which define the image are in a memory; b) the pixel values which indicate the optical density values within the image are indicated by gray values having m-bits, where m is the number of bits defining the value; c) the lines of the image include pixels which have gray values other than white; d) for each m-bit pixel value, a representative n-bit pixel value is generated, where n is the number of bits defining the n-bit value, n<m, and all possible colors in an image are defined by a gray m-bit pixel value, and the set of n-bit pixel values; e) the value of each is pixel converted to a combination of red, green and blue values is an n-bit pixel value, where combinations of red, green, and blue values define all possible colors in a color set, and values converted to an n-bit- combination of red, green and blue values where the red value = green value = blue value are gray values; f) the image is displayed in terms of n-bit red, green and blue pixel values; g) a foreground color is selected from n-bit red, green, and blue values; h) a background color is selected from n-bit red, green, and blue values; i) the pixel value of each n-bit combination of red, green and blue values is compared to a threshold value selected to identify background combination of red, green and blue values; j) said comparison is used to determine whether the n-bit combination of red, green and blue values is a background color; k) for each background color so determined, said n-bit red, green and blue pixel value is changed to the background color; I) the red, green and blue values identifying said foreground color are added to all n-bit red, green and blue pixel values not identified as background pixels; and m) the image is re-displayed in terms of red, green and blue pixel values in accordance with any red, green and blue pixel value changes. A method as claimed in claim 7, characterised by: j) converting each of said threshold value, n-bit background color and n-bit foreground color respectively to m-bit values; k) converting the m-bit gray value of each pixel to an m-bit combination of red, green and blue values, where combinations of red, green and blue values define all possible colors in the m-bit color set, and gray values are converted to an m-bit combination of red, green and blue values where the red value = green value = blue value; I) comparing each m-bit pixel value in the original image to the threshold value selected to identify background pixels; m) determining from said comparison whether the pixel is a background pixel; n) for each background pixel so determined, changing said m-bit pixel value to the m-bit background color; o) changing all pixels not identified as background pixels to the m-bit foreground color.

Inventors: BOLLMANN JAMES E, VENABLE DENNIS L, BOLLMANN, JAMES E., VENABLE, DENNIS L.
Applicants: XEROX CORP, XEROX CORPORATION
Application year: 1992
Main classification: H04N1
IPC codes: G06T11, G06T1, H04N1