The invention relates to a method and apparatus for downscaling a digital matrix image using a selected ratio, in which the matrix image includes a large number of lines, each line including a large number of pixels, so that the intensity values of the pixels form the matrix, and in which the output matrix pixels formed by scaling correspond to the sub-groups of the original matrix, from the intensity values of the pixels of which an average is calculated in a selected manner for each pixel of the output matrix.
Camera sensors are used when using digital cameras to take individual images or video images. The image of the sensor can use various image formats, for example, RGB8;8:8, RGB5:6:5, YUV4:2:0 and a raw-Bayer image. When the image is shown in the viewfinder (VF), which usually has a lower resolution than the image sensor, the image must be formed in the sensor and scaled to be suitable for the resolution of the display. The image can also be zoomed (a smaller image from the sensor is cropped and then scaled) to the viewfinder. In zooming, there should be many stages, so that the result of the zooming will appear to be continuous. When video images are taken, the resolution of the video image is usually lower than the resolution of the sensor. Similar scaling will therefore also be required when videoing. Camera sensors can also be used equally well in portable devices as in cameras. Image scaling is needed, if the viewfinder image is running in real time on the display of a telephone or camera, or if a video image is being taken in real time.
Methods are known, in which the image is scaled (sub-sampled) using a low quality algorithm in the camera (poor image quality). The poorer quality is especially visible in the digital zoom mode of some DSCs (DSC=Digital Still Camera).
U.S. Pat. No. 6,205,245 discloses one method, in which a colour image is scaled directly from the matrix of the sensor, in such a way that a pixel group, which is always processed at one time, is defined, more or less corresponding to each pixel of the final image.
Generally, the scaling of an image matrix M1×N1 is scaled to a smaller size M2×N2 as follows. The scaling ratios M2/M1 and N2/N1 determine the procedure in the calculation operation. If scaling takes place in real time, i.e. As a continuous flow, memory need not be reserved for the input matrix, only three memory lines being sufficient. Consider the data coming in the X lines. The first memory line sums the amount according to the scaling ration in the X direction at the same time as the value of each pixel is summer in the Y line memory. If the scaling ratio, results in the number of pixels not being an integer, the value of the pixel at the limit is weighted and summed with the two adjacent input pixels. In the same way, pixel values are calculated according to the scaling ration into the Y line memory and, in the case of boundary pixels, they are divided weighted into two parts. When the counter set for the Y scaling ration shows that the Y line memory is full, it is emptied forwards, after which summing starts from the beginning.
If the scaling ratios are small (near to zero), several memory lines will be needed, but their size is small. If, on the other hand, the scaling ratios are large (near to unity), only a few memory lines will be needed, but their size is large. Thus, depending on the scaling ratio, a fairly constant amount of memory is needed, the amount of which is about 3×M1 for a single colour component. In a practical application, the whole memory needed for scaling is less than 4×M1 for a single colour component.
The invention is intended to improve the quality of the viewfinder or display image, by using separate scaling ratios and smooth zooming. In addition, it is desired to reduce the level of interference. By means of the invention, it is wished to process an image with nearly optimum quality, while simultaneously keeping the demands for memory and power consumption at an economical level.
The characterizing features of the method and apparatus according to the invention are stated in the accompanying Claims. The invention is particularly suitable for hardware-based (HW) implementations. The quality of scaling is nearly optimal and the level of interference is reduced significantly.
By means of the invention, the following advantages are achieved:
The quality of scaling is affected by the coarse and fine-scaling ratios. Quality is reduced if the pixels that are ready averaged in coarse scaling do not coincide with the fine-scaling limit, in which case they contain information from outside the output pixel.
In the following, the invention is examined with reference to the accompanying figures, which show some embodiments of the invention.
a shows a block diagram of one device solution,
b shows a block diagram on a second device solution,
c shows the scaling solution of
a shows a diagram of the division of the total ratio between the first and the second stages, when seeking to minimize calculation,
b shows a diagram of the division of the total ratio between the first and second stages, when seeking to minimize the amount of memory required,
c shows a diagram of the division of the total ratio between the first and second stages, when seeking to optimize mainly the quality of the image, but also the amount of calculation and memory required.
The method according to the invention includes two scaling stages,
The invention is particularly suitable for hardware-based applications, an example of which is the application according to
In one embodiment, the input and output units are separate units, due to the large data flow, each scaler having its own CPU and memory area on the same chip (not shown).
In
In one (fully digital embodiment) the construction of the scaler at the circuit level is according to
In this embodiment, scaling is performed using integers, which is much simpler to implement on a chip than floating-point calculation.
The values of an output pixel can be calculated as follows from the pixels of the intermediate image (
A=(P2(a)*a+P1(b)*b)/256
B=(P2(b)*b+P(c)*c+P1(d)*d)/256
C=(P2(d)*d+P1(e)*e)/256
D=(P2(e)*e+P(f)*f+P1(g)*g)/256
E=(P2(g)*g+P1(h)*h)/256
The PIXELSTEP value can be defined for the scaling ratio 5/8:
Set MAXSTEP=256
Tmp2=(MAXSTEP*5)/8=160
PIXELSTEP=floor(Tmp2)=160
The weighting coefficients can be defined as follows:
P1(a)=0
P1(x)=MAXSTEP−P2(x−1)
Conditional statement If (P1(x)>PIXELSTEP then
P1(x+1)=P1(x)−PIXELSTEP and P(x)=PIXELSTEP
P2(x)=PIXELSTEP−P1(x)
And so that weighting coefficients of the example given above can be calculated:
P1(a)=0
P2(a)=PIXELSTEP−P1(a)=160−0=160
P1(b)=MAXSTEP−P2(a)=256−160=96<=160 96
P2(b)=PIXELSTEP−P1(b)=160−96=64
P1(c)=MAXSTEP−P2(b)=256−64=192>160
P(c)=PIXELSTEP=160
P1(d)=P1(c)−PIXEL STEP=192−160=32
P2(d)=PIXELSTEP−P1(d)=160−32=128
P1(e)=MAXSTEP−P2(d)=256−128=128<=160 128
P2(e)=PIXELSTEP−P1(e)=160−128=32
P1(f)=MAXSTEP−P2(e)=256−32=224>160
P(f)=PIXELSTEP=160
P1(g)=P1(f)−PIXELSTEP=224−160=64
P2(g)=PIXELSTEP−P1(g)=160−64=96
P1(h)=MAXSTEP−P2(g)=256−96=160<=160 160
Note! P2(h)=PIXELSTEP−P1(h)=160−160=0
P1(i)=MAXSTEP−P2(h)=256−0>160
P(i)=160, P1(j)=96
In the case of
The calculation is performed using the most advantageous integers. In the examples, the following concepts are used
IR=MAX(Hin/Hout, Vin/Vout), in which horizontal (H) and vertical (V) sizes are used.
MAXSTEP=256 (or 65536 if more precise pixel positioning is desired)
Calculation example, scaling ratio (SCRatio) 0,182 i.e. ITR=5,5:
In the case of
In the following table, the stages of the scaling of
In this case too, the calculation is performed using integers, so that in the example (
Inverted total scaling ratio IR=MAX(Hin/Hout, Vin/Vout), in which horizontal (H) and vertical (V) sizes are used.
AVESKIP=2̂SKIP
MAXSTEP=256 (or 65536 if more precise pixel positioning is desired)
Calculation example, ITR=5,5:
AVESKIP=2̂2=4
In the case of
The integer calculation auxiliary variables AVESKIP and PIXELSTEP are defined in the following:
Inverted total scaling ratio IR=MAX(Hin/Hout, Vin/Vout), in which horizontal (H) and vertical (V) sizes are used.
MAXSTEP=256 (or 65536, if more precise pixel positioning is desired)
Calculation example 3, ITR=5,5:
In cases in which the total scaling ratio is on 1/X, AVESKIP=X, the second stage is bypassed.
In most applications, scaling is made directly to the sensor circuit, using a suitable processor unit. The silicon area of such a circuit (ASIC) can be reduced to a usable level using a scaling method disclosed above, compared to an optimal scaling method. With the aid of the invention, it is possible to minimize the amount of line memory on the chip. This is because the area of the silicon determines the costs of the chip and is a central cost factor in portable camera solutions. The invention permits smaller cameras than previously and an increased dynamic range. The coded image size is smaller for the same quality parameters and is suitable for both separate images and video images.
The examples above are mainly for hardware-implemented camera sensors, but the invention can also be applied outside of the sensors, for example, by means of software in a PC. The camera sensor is suitable for use, not only in actual cameras, but also in mobile telephones (generally in mobile stations).
| Number | Date | Country | Kind |
|---|---|---|---|
| 20035227 | Dec 2003 | FI | national |
| Filing Document | Filing Date | Country | Kind | 371c Date |
|---|---|---|---|---|
| PCT/FI04/50172 | 11/23/2004 | WO | 00 | 4/17/2006 |