1. Field of the Invention
The present invention relates to an image processing apparatus and an image processing method for compressing dynamic ranges of color images into a dynamic range of an output device such as a printer, for outputting the color images. The present invention also relates to a program for causing a computer to execute the image processing method.
2. Description of the Related Art
Conventionally, images obtained by taking photographs of subjects with photography devices such as digital cameras and images obtained by photo-electrically reading images recorded on films such as negative films and reversible films, prints or the like are reproduced at reproduction devices such as printers. When the images are reproduced at the reproduction devices, dynamic ranges of the images are compressed into dynamic ranges of the reproduction devices to prevent loss of gradation in highlights and/or shadows of the images.
As the aforementioned dynamic range compression method, a method has been proposed, wherein filtering processing is performed on an image by using a low-pass filter, an unsharp image only showing low spatial frequency structures in the image is produced, and a dynamic range is compressed using the unsharp image. Accordingly, loss of gradation in both highlights and shadows of the image is prevented while contrast in fine texture in the highlights and the shadows of the image is preserved (U.S. Pat. No. 6,101,273).
However, in the method disclosed in U.S. Pat. No. 6,101,273, dynamic range compression rates are set based on information indicating brightness of the images. Therefore, there is a problem that if the dynamic ranges of the images are compressed at the set dynamic range compression rates, high saturation colors included in the images become saturated and lost.
In view of the foregoing circumstances, it is an object of the present invention to make it possible to compress dynamic ranges of images without saturating high saturation colors.
An image processing apparatus according to the present invention is an image processing apparatus comprising:
a dynamic range compression means for obtaining a processed image of which dynamic range has been compressed by compressing a dynamic range of a color image;
The term “setting the dynamic range compression rate based on the dynamic range of the color image” refers to setting the dynamic range compression rate so that the dynamic range of the color image is compressed into a dynamic range of a reproduction device such as a printer, for outputting the color image.
The term “lowering the dynamic range compression rate” refers to reducing a degree of dynamic range compression. Specifically, the set dynamic range compression rate should be lowered by a predetermined value. Alternatively, the dynamic range compression rate should be lowered more as a pixel number of high saturation pixels become larger.
In the image processing apparatus according to the present invention, the compression rate setting means may create a histogram of an image data set representing the color image, calculate a dynamic range of the color image based on the histogram, and set a dynamic range compression rate for each of an area of relatively high data values, an area of relatively low data values and/or a whole area of the image data set based on the dynamic range by using a predetermined standard value of the image data set as a standard.
An image processing method according to the present invention is an image processing method comprising the steps of:
A program for causing a computer to execute the image processing method according to the present invention may also be provided.
According to the present invention, the dynamic range compression rate for the color image is set based on the dynamic range of the color image. Then, saturation of each of a plurality of pixels in the color image is calculated and a pixel number of high saturation pixels of which saturation is higher than a first threshold value is counted. If the pixel number of the high saturation pixels is equal to or larger than a second threshold value, a new dynamic range compression rate which is lower than the set dynamic range compression rate is set. Then, a compression table is created by using the dynamic range compression rate which was before or the new dynamic range compression rate. The dynamic range of the color image is compressed by using the created compression table. Here, if the dynamic range compression rate is lowered, the degree of dynamic range compression is reduced. Accordingly, high saturation pixels included in the color image become less saturated. Therefore, according to the present invention, the dynamic range of the color image including a large number of high saturation pixels may be compressed while saturation of the high saturation pixels is prevented.
Further, a histogram of the color image is obtained. A dynamic range compression rate for each of a whole area of the image data set, an area of relatively high data values and/or an area of relatively low data values is set based on the histogram by using a predetermined standard value as a standard. Contrast only in highlights or shadows in the color image is lowered by performing the dynamic range compression processing at the set dynamic range compression rate. If contrast is low in a large area, dynamic range compression processing is not performed for the area. Accordingly, loss of gradation in highlights and shadows in the image is prevented. Further, if contrast is low in a large area of the image, the contrast in the area is not further lowered. Thus, quality of processed images obtained by compressing the dynamic range may be improved.
Note that the program of the present invention may be provided being recorded on a computer readable medium. Those who are skilled in the art would know that computer readable media are not limited to any specific type of device, and include, but are not limited to: floppy disks, CD's RAM'S, ROM's, hard disks, magnetic tapes, and internet downloads, in which computer instructions can be stored and/or transmitted. Transmission of the computer instructions through a network or through wireless transmission means is also within the scope of this invention. Additionally, computer instructions include, but are not limited to: source, object and executable code, and can be in any language including higher level languages, assembly language, and machine language.
Hereinafter, embodiments of the present invention will be described with reference to drawings.
The image input unit 1 includes a media drive for reading the image data set S0 recorded on a medium from the medium and various kinds of interfaces for receiving an input of the image data set S0 sent via a network. The image data set S0 may be obtained with a photography device such as a digital camera. The image data set S0 may also be obtained by photo-electrically reading an image recorded on a film or an original copy.
The image analysis unit 2 sets a compression rate of the image S0 in the following manner. First, the image analysis unit 2 calculates a density Y of each of a plurality of pixels in the image S0 by the following expression (1). Note that R0, G0 and B0 are components of RGB data of each of the pixels in the image S0.
Y=0.3125R0+0.3750G0+0.3125B0 (1)
Next, the image analysis unit 2 obtains a histogram of the density Y.
Meanwhile, information on a maximum density Dmax which can be reproduced by the image output unit 5 has been input to the image analysis unit 2. The image analysis unit 2 compares the shadow density Ys and the maximum density Dmax. If the shadow density Ys is higher than the maximum density Dmax, that is the shadow density Ys is darker than the maximum density Dmax, a dynamic range compression rate is calculated with respect to a predetermined standard density Y0 so that the shadow density Ys does not exceed the maximum density Dmax. Specifically, a dynamic range compression rate P0 is calculated by the following expression (2):
P0=(Ys−Y0)/(Dmax−Y0) (2).
Here, if a subject included in the image S0 is a person for example, a value of the standard density Y0 is set to a value between 0.50 and 0.70 (as a ratio to a range corresponding to a bit number), which is substantially the same as a density of a flesh color. Preferably, the value should be set to 0.6.
Next, the image analysis unit 2 calculates saturation C of each of the pixels in the image S0 by the following expression (3). Note that W in the expression (3) is (R0+G0+B0)/3, which is an average value of each of a plurality of color components R0, G0 and B0 of RGB data of each of the pixels. A calculation method of the saturation is not limited to the method shown by the expression (3) and various kinds of known methods may be used.
C={square root}((R0−W)2+(G0−W)2+(B0−W)2) (3)
Then, pixels of which calculated saturation C is higher than a predetermined threshold value Th1 are detected as high saturation pixels in the image S0. Further, the image analysis unit 2 counts a pixel number N of the high saturation pixels and judges whether the pixel number N is equal to or larger than a predetermined threshold value Th2. If N≧Th2, a new dynamic range compression rate P1 is set by lowering the dynamic range compression rate P0 as shown in the following expression (4):
P1=2/(1/P0+1.0) (4).
The compression table creation unit 3 creates a compression table based on the dynamic range compression rates P0 and P1 set by the image analysis unit 2.
If a part where the gradient changes (i.e., a point of the standard density Y0) is discontinuous in the compression table T0, an artifact might be produced in the processed image. Therefore, production of the artifact may be prevented by setting a function so that the gradient becomes continuous.
The compression processing unit 4 compresses the dynamic range of the image data set S0 in the following manner. The compression processing unit 4 calculates the density Y of each of the pixels in the image S0 by the aforementioned expression (1). Then, filtering processing is performed on the image S0 by using a low-pass filter in a predetermined size and an unsharp image having an unsharp density Y′ is obtained. Here, there are problems that if the size of the low-pass filter is too small, the sharpness is unnaturally emphasized and overshoot at edges becomes apparent. If a size of a major part of a subject, such as a face is small, an effect of the unsharp mask is not sufficiently realized. Further, the size of the apparatus becomes large because an operation amount increases. Therefore, in the present embodiment, the size of the low-pass filter is set so that the aforementioned problems will be prevented.
Next, the compression processing unit 4 performs dynamic range compression processing on the image data set S0 by using the compression table T0 created by the compression table creation unit 3. Specifically, each of a plurality of processed color components R1, G1 and B1 of RGB data is obtained by adding a value of LutDR(Y′) to each of the color components R0, G0 and B0 of RGB data of each of the pixels in the image S0 as shown in the following expressions (5)-(7). The value of LutDR(Y′) is obtained by processing an unsharp density Y′ of each of the pixels by using the compression table T0.
R1=R0+LutDR(Y′) (5)
G1=G0+LutDR(Y′) (6)
B1=B0+LutDR(Y′) (7)
Then, the compression processing unit 4 outputs a processed image data set S1 including each of the processed color components R1, G1 and B1 of the RGB data to the image output unit 5.
The image output unit 5 prints out the processed image data set S1 and obtains a print P of the processed image.
Next, an operation in the present embodiment will be described.
Next, the compression table creation unit 3 creates a compression table T0 based on the dynamic range compression rates P0 and P1 set by the image analysis unit 2 (step S7). Then, the compression processing unit 4 compresses the dynamic range of the image S0 by using the compression table T0 and obtains a processed image data set S1 (step S8). The image output unit 5 prints out the processed image data set S1 (step S9) and processing ends.
As described above, in the present embodiment, if the pixel number N of high saturation pixels, of which saturation C is higher than the threshold value Th1, is equal to or larger than the threshold value Th2, the new dynamic range compression rate P1 is set by lowering the dynamic range compression rate P0 which has already been set. Here, if the dynamic range compression rate is lowered, the degree of compressing the dynamic range of the image S0 is reduced. Accordingly, the high saturation pixels included in the image S0 become less saturated. Therefore, according to the present embodiment, a dynamic range of an image including particularly many high saturation pixels can be compressed while saturation of the high saturation pixels is prevented.
Further, in the aforementioned embodiment, the new dynamic range compression rate P1 which is lower than the dynamic range compression rate P0 is set by using the aforementioned expression (4). However, the new dynamic range compression rate P1 may also be set in the manner that the compression rate is lowered more as the pixel number N of the high saturation pixels becomes larger. In this case, the new dynamic range compression rate P1 may also be set so that the compression rate is gradually lowered according to the pixel number N of the high saturation pixels.
Further, in the aforementioned embodiment, the compression table T0 for compressing the dynamic range in a shadow side of the image S0 is created. However, a compression table T0 for compressing a dynamic range in a highlight side of the image S0, as illustrated in
Further, in the aforementioned embodiment, the compression processing unit 4 compresses the dynamic range of the image data set S0 by obtaining the unsharp image of the image S0, having the unsharp density Y′. However, the density Y before performing filtering processing by using the low-pass filter may be used instead of the unsharp density Y′. Each of the processed color components R1, G1 and B1 of the RGB data may also be obtained by adding a value of LutDR(Y) to each of the color components R0, G0 and B0 of the RGB data of each of the pixels in the image S0, as shown in the following expressions (8)-(10). The value of LutDR(Y) is obtained by processing the density Y of each of a plurality of pixels by using the compression table T0. Accordingly, dynamic range compression processing may be performed at a high speed.
R1=R0+LutDR(Y) (8)
G1=G0+LutDR(Y) (9)
B1=B0+LutDR(Y) (10)
Number | Date | Country | Kind |
---|---|---|---|
299500/2003 | Aug 2003 | JP | national |