This application claims the benefit of Taiwan application Serial No. 106144069, filed Dec. 15, 2017, the subject matter of which is incorporated herein by reference.
The invention relates in general to image processing, and more particularly to an image processing circuit capable of color removal and an associated image processing method.
Palette coding technologies are extensively applied for coding images. One main concept of palette coding technologies is that, the color of each pixel is represented by an index. When a display device is to display images, a palette table is involved to convert these indices to image data coded in another color space (e.g., an RGB color space) and corresponding images are then displayed. In the prior art, a color removal (also referred to as “a key index”) function is supported by images coded by palette coding technologies; that is, a user can remove the color corresponding to an index through inputting the index.
For example, assume that the color corresponding to an index “10” is orange (e.g., red, green and blue components in a color space are respectively (R1, G1, B1)). If a user-inputted color removal instruction Iy is asks to remove the color having the index “10”, the color removing circuit 130 identifies the color Cy corresponding to the index “10” from the memory 150, and directly replaces the color of pixels having the red, green and blue components (R1, G1, B1) to black. However, when the image processing circuit 100 needs to magnify the image, because an image magnification operation involves interpolation, it is possible that colors of new pixels generated by interpolation coincide with the above color having the red, green and blue components (R1, G1, B1). At this point, if a user happens to input a color removal instruction asking to remove the color of the index “10”, these pixels generated by interpolation may be replaced by black, thus affecting the display quality.
Therefore, it is an object of the present invention to provide an image processing method capable of preventing an error caused by the above color removal operation so as to maintain display quality.
In one embodiment of the present invention, an image processing circuit includes a determining circuit, a converting circuit and a color removing circuit. The determining circuit determines a specific color different from all colors in a palette table. The converting circuit converts a first image in a palette mode to a second image having a color space according to the palette table, wherein a pixel having a specific index in the first image is converted to a pixel having the specific color. The color removing circuit removes the specific color from the second image.
In another embodiment of the present invention, an image processing method applied to an image processing circuit, includes: determining a specific color different from all colors in a palette table; converting a first image in a palette mode to a second image having a color space according to the palette table, wherein a pixel having a specific index in the first image is converted to a pixel having the specific color; and removing the specific color from the second image.
The above and other aspects of the invention will become better understood with regard to the following detailed description of the preferred but non-limiting embodiments. The following description is made with reference to the accompanying drawings.
In the image processing circuit 200, the converting circuit 210 converts indices to colors. More specifically, the converting circuit 210 first receives a first image D1, in which a color of each pixel in the first image D1 is represented by an index and the color corresponding to each index is stored in a palette table in the memory 250. The converting circuit 210 reads the palette table from the memory 250, converts the index of each pixel in the first image to a corresponding color according to the palette table, and accordingly generates a second image D2. For example, the palette table may record indices and the corresponding colors. The term “color” refers to a composition of a red component, a green component and a blue component in an RGB color space, and the red/green/blue component can be represented by a value between 0 and 25. The converting circuit 210 converts the index corresponding to each color in the first image D1 to the corresponding color in the palette table according to the palette table.
The scaling circuit 220 scales the second image D2 to generate a scaled second image D2′. In this embodiment, the scaling circuit 220 performs a magnification operation on the second image D2, e.g., magnifying the second image D2 from an original a resolution of 19201080 to a resolution of 3840*2160. It should be noted that, because new pixels are generated during the magnification process performed on the second image D2, interpolation is needed to acquire colors of these new pixels; however, pixel values (i.e., colors) generated by the interpolation may coincidently correspond to the color corresponding to one of the indices recorded in the palette table.
The color removing circuit 230 removes a specific color from the scaled second image D2′ according to a color removal instruction to generate an output image D2″. If the color removal instruction is not received, the color removing circuit 230 is not required to process the scaled second image D2′; that is, the scaled second image D2′ may directly serve as the output image D2″. More specifically, the color removal instruction indicates a specific index Ix, and the color removing circuit 230 removes the color corresponding to the specific index Ix from the scaled second image D2′, i.e., adjusting the pixel(s) having the color to black. For example, assuming that a user-inputted color removal instruction asks to remove the color corresponding to the index “15”, the color removing circuit 230 then adjusts the color corresponding to the index “15” in the scaled second image D2′ to black. However, as previously described, pixel values (i.e., colors) generated by the interpolation during the magnification process performed on the second image D2 may coincide with the color corresponding to the index “15”. Thus, the color removing circuit 230 would incorrectly adjust the pixel values generated by the interpolation to black, causing a flaw in the display image.
To solve the above issue, the image processing circuit 200 further includes a determining circuit 240 for determining a specific color Cx corresponding to the specific index Ix. The specific color Cx includes a specific red component, a specific green component and a specific blue component (Rx, Gx, Bx). When the image processing circuit 200 receives a color removal instruction asking to remove the color having the specific index Ix, the determining circuit 240 first calculates a specific color Cx different from all of the colors in the palette table, provides the specific index Ix and the specific color Cx to the converting circuit 210, and provides the specific color Cx to the color removing circuit 230. At this point, the converting circuit 210 directly converts the pixel having the specific index Ix in the first image D1 to the specific color Cx; that is, for this specific index, the converting circuit 210 does not determine the color corresponding to the specific index according to the palette table, and the color removing circuit 230 adjusts the pixel having the specific color Cx in the scaled second image D2′ to black, and does not remove the color having the specific index recorded in the palette table. For example, assume that the color removal instruction asks to remove the color corresponding to the index “15” (e.g., scarlet). At this point, the determining circuit 240 determines a specific color (e.g., pale yellow) different from all the colors in the palette table, the converting circuit 210 converts all pixels having the index “15” in the first image D1 to the specific color (pale yellow), and the color removing circuit 230 removes only pale yellow from the scaled second image D2′. Thus, the above issue of removing the color of pixels generated by interpolation can be effectively prevented.
In the embodiment in
In step 300, the process begins.
In step 302, when a color removal instruction is received, a specific color different from all colors in a palette table is determined, wherein the color removal instruction asks to remove a color having a specific index.
In step 304, a first image in a palette mode is converted to a second image having a color space according to the palette table, wherein a pixel having the specific index in the first image is directly converted to having the specific color.
In step 306, the second image is scaled to generate a scaled second image.
In step 308, the specific color is removed from the scaled second image according to the color removal instruction.
In the flowchart of the image processing method according to an embodiment of the present invention in
In the above embodiment, the specific color determined is different from all the colors in the palette table. However, it is still possible that the specific color (pale yellow) in the above embodiment is the color of pixels generated by interpolation. Thus, to minimize such possibility and considering that interpolation is generally used for situations where neighboring colors are similar, a method is further provided according to another embodiment of the present invention to cause the specific color determined by the determining circuit 240 to have a predetermined color scale distance from the colors recorded in the palette table.
The determining circuit 240 first sets a tag for each cubic region. The tag has a default value, e.g., logic “0”. The determining circuit 240 then reads the palette table from the memory 250, and modifies the tag of the cubic region corresponding to the colors recorded in the palette table to logic “1”. For example, black dots in
The determining circuit 240 may select any desired cubic region of which the tag is logic “0” as a specific region, select the specific color from the specific region, and provide the selected specific color to the converting circuit 210 and the color removing circuit 230. In one embodiment, to ensure that the specific color is spaced from the colors recorded in the palette table by a predetermined color scale distance, the determining circuit 240 uses the color at a center of the specific region as the specific color, so as to ensure that the red component (R), the green component (G) and the blue component (B) of the specific color are spaced from the colors recorded in the palette table by a color scale distance “16”. Further, when the determining circuit 240 cannot find any cubic region of which the tag is logic “0”, the color space needs to be again divided into more cubic regions (e.g., 4096 (16*16*16=4096), and the logic values of the tags need to be again set.
Since the color space is divided in advance instead of sequentially comparing all possible repeating colors one after another, the operation of the above determining circuit 240 can quickly determine the specific color by using minimal hardware/software resources. Further, the specific color is spaced from the colors recorded in the palette table by a certain color scale distance, such that the possibility that the specific color is identical to the color of any new pixels generated by interpolation performed by the scaling circuit 220 is minimized (minimal possibility). Particularly, as the number of regions divided for the entire color space gets smaller, the less hardware/software resources are needed, and the specific color determined is necessarily spaced from the colors recorded in the palette table by a larger color scale distance.
In conclusion, in the image processing circuit and the associated method, the determining circuit determines a specific color spaced from all the colors in a palette table by a certain color scale distance, and provides this specific color for further use to the converting circuit and the color removing circuit, wherein the specific color is used to replace a color asked to be removed according to a user-inputted color removal instruction. With the present invention, the issue of incorrectly removing a color of pixels generated by interpolation is solved, and the associated operation can be completed by using few steps and minimal hardware resources.
While the invention has been described by way of example and in terms of the preferred embodiments, it is to be understood that the invention is not limited thereto. On the contrary, it is intended to cover various modifications and similar arrangements and procedures, and the scope of the appended claims therefore should be accorded the broadest interpretation so as to encompass all such modifications and similar arrangements and procedures.
Number | Date | Country | Kind |
---|---|---|---|
106144069 | Dec 2017 | TW | national |