1. Technical Field
Embodiments of the present disclosure relate to the field of image processing, and more particularly to a computing device, a storage medium and a method for processing foreground color of an image.
2. Description of Related Art
When a user processes an image, the user may insert text, graphs, or lines having an eye-catching foreground color in the image. Usually, the user selects the foreground color by experience, for example, if a background color of the image is cyan, the user may select red as the foreground color of the image. However, if the image includes a variety of background colors, it is inconvenient for the user to select an appropriate foreground color for the image.
The disclosure, including the accompanying drawings, is illustrated by way of example and not by way of limitation. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean at least one.
The foreground color processing system 100 may be in form of one or more programs that are stored in the storage system 10 and executed by the at least one processor 11. The foreground color processing system 100 can provide a foreground color for the image when the image is processed by inserting text, graphs, or lines into the image.
In one embodiment, the storage system 10 may be a random access memory (RAM) for temporary storage of information, and/or a read only memory (ROM) for permanent storage of information. In other embodiments, the storage system 10 may also be an external storage device, such as a hard disk, a storage card, or a data storage medium. The at least one processor 11 executes computerized operations of the computing device 1 to provide functions of the computing device 1.
In one embodiment, the foreground color processing system 100 may include a predetermination module 101, a sampling module 102, a count module 103, a selecting module 104, and a calculation module 105. The module 101-105 may comprise a plurality of functional modules each comprising one or more programs or computerized codes that are stored in the storage system 10 and executed by the at least one processor 11. In general, the word “module”, as used herein, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language, such as, Java, C, or assembly. One or more software instructions in the modules may be embedded in firmware, such as in an EPROM. The modules described herein may be implemented as either software and/or hardware modules and may be stored in any type of non-transitory computer-readable medium or other storage device. Some non-limiting examples of non-transitory computer-readable media include CDs, DVDs, BLU-RAY, flash memory, and hard disk drives.
The predetermination module 101 predetermines a color palette that includes a plurality of colors in the RGB color model. Each of the colors in the color palette is also represented in form of an RGB value. The predetermination module 101 predetermines each of the colors in the color palette by predetermining the RGB values of the colors. For example,
The sampling module 102 acquires the image from the storage system 10, and samples pixels from the image according to the predetermined sampling ratio. For example, if the total number of pixels in the image is one hundred and the sampling ratio is 30%, the sampling module 102 samples thirty pixels from the image according to the sampling ratio.
The count module 103 counts the RGB value of each sampled pixel of the image, and determines an ideal pixel value of each of the R value, the G value and the B value according to the counted RGB value of each sampled pixel of the image. The ideal pixel value is defined as a value that appears most frequently in the RGB value of each sampled pixel of the image. For example, the sampling module 102 samples ten pixels, and the RGB value of each sampled pixel is:
The count module 103 determines the value “125” as the ideal pixel value of the R value, determines the value “120” as the ideal pixel value of the G value, and determines the value “23” as the ideal pixel value of the B value.
The selecting module 104 selects a color from the color palette as a background color of the image according to the ideal pixel value of each of the R value, the G value and the B value. In the embodiment, the R value, the G value and the B value of the background color respectively equals or most approximates to the ideal pixel value of each of the R value, the G value and the B value.
The calculation module 105 calculates a complementary color of the background color. In one embodiment, the calculation module 105 calculates a difference between the decimal number “255” and the R value, a difference between the decimal number “255” and the G value, and a difference between the decimal number “255” and the B value of the background color. The calculation module 105 further determines the differences as the R value, the G value and the B value of the complementary color. For example, if the RGB value of the background is (255, 50, 125), the RGB value of the complementary color is (0, 205, 130).
The selecting module 104 further selects a color from the color palette as the foreground color of the image according to the complementary color, and stores the foreground color of the image to the storage system 10. In the embodiment, the R value, the G value and the B value of the foreground color respectively equals or most approximates to the R value, the G value and the B value of the complementary color.
Before step S1, the predetermination module 101 predetermines a color palette that includes a plurality of colors in an RGB color model. Each of the colors is represented in form of an RGB value. The predetermination module 101 predetermines each of the colors in the color palette by predetermining the RGB values of the colors. The predetermination module 101 further predetermines a sampling radio between a number of sampled pixels to a total number of pixels in an image, such as 30%.
In step S1, the sampling module 102 acquires an image from the storage system 10, and samples pixels from the image according to the predetermined sampling ratio.
In step S2, the count module 103 counts the RGB value of each sampled pixel of the image, and determines an ideal pixel value of each of the R value, the G value and the B value according to the counted the RGB value of each sampled pixel of the image. The ideal pixel value is defined as a value that appears most frequently in the RGB value of each sampled pixel of the image.
In step S3, the selecting module 104 selects a color from the color palette as a background color of the image according to the ideal pixel value of each of the R value, the G value and the B value. In one embodiment, the R value, the G value and the B value of the background color respectively equals or most approximates to the ideal pixel value of each of the R value, the G value and the B value.
In step S4, the calculation module 105 calculates a complementary color of the background color. In one embodiment, the calculation module 105 calculates a difference between the decimal number “255” and the R value, a difference between the decimal number “255” and the G value, and a difference between the decimal number “255” and the B value of the background color. The calculation module 105 further determines the differences as the R value, the G value and the B value of the complementary color.
In step S5, the selecting module 104 selects a color from the color palette as the foreground color of the image according to the complementary color, and stores the foreground color of the image to the storage system 10. In one embodiment, the R value, the G value and the B value of the foreground color respectively equals or most approximates to the R value, the G value and the B value of the complementary color.
Although certain embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
201110380594.X | Nov 2011 | CN | national |