# Patent

## Title
System, method, and computer program product for picture resizing

## Abstract

System, method, and computer program product to adaptively blend the interpolation results from an 8-tap Lanczos filter and the interpolation results from a bilinear filter, according to the local transitions of the input content. Artifacts may occur, which may be identified as such and corrected. Pixels that represent artifacts in the blended image may be replaced with the pixel for that location taken from the bilinear interpolation.

## Background
BACKGROUND
Image resizing is a common operation in digital image/video processing. An interpolation process is often involved in resizing. Filters such as box (e.g., nearest-neighbor interpolation), tent (e.g., bilinear interpolation), cubic spline (e.g., bicubic interpolation) and a variety of kernels approximating the sinc function have been popular solutions for image interpolation. Among these approaches, the Lanczos filter, a windowed form of the sinc filter, may provide a sharper output than common bilinear or bicubic interpolation. Moreover, the Lanczos filter may be considered to be an effective compromise in terms of aliasing, ringing, and sharpness compared to other approaches.
For an N-lobed Lanczos-windowed sinc function, its oscillation nature can induce a ringing effect and the negative values in the resulting kernel can produce undershoot (i.e., the output is lower than the input). The ringing effect often appears as artificial rings near edges.



BRIEF DESCRIPTION OF THE DRAWINGS/FIGURES
FIG. 1 is a block diagram illustrating processing of the system described herein, according to an embodiment.
FIG. 2 is a block diagram illustrating the system described herein, according to an embodiment.
FIG. 3 illustrates the resizing process and the use of a sampling window, according to an embodiment.
FIG. 4 is a flowchart illustrating a process for determination of an artifact, according to an embodiment.
FIG. 5 is a block diagram illustrating a software or firmware embodiment of the system described herein.



DETAILED DESCRIPTION
A preferred embodiment is now described with reference to the figures, where like reference numbers indicate identical or functionally similar elements. Also in the figures, the leftmost digit of each reference number corresponds to the figure in which the reference number is first used. While specific configurations and arrangements are discussed, it should be understood that this is done for illustrative purposes only. A person skilled in the relevant art will recognize that other configurations and arrangements can be used without departing from the spirit and scope of the description. It will be apparent to a person skilled in the relevant art that this can also be employed in a variety of other systems and applications other than what is described herein.
Disclosed herein are methods and systems to blend the interpolation results from a Lanczos filter and the interpolation results from a bilinear filter. The blending may be done adaptively, according to the local transitions of the input content. Undershoot may occur, which accentuates transitions in images and can be beneficial for generating sharper scaled images. However, it may produce artifacts in certain patterns as well. Detection and correction of this kind of artifact may be performed.
FIG. 1 illustrates the overall processing of the system described herein, according to an embodiment. At 110, an input image may be resized, using bilinear filtering. At 120, the input image may be resized using 8-tap Lanczos filtering. The outputs, i.e., resized images, produced by 110 and 120 may be blended at 130. This may create a single blended image. At 140, artifacts may be detected in the blended image. At 150, any detected artifacts may be corrected. The process may conclude at 160.
A system that may perform this process is shown in FIG. 2, according to an embodiment. The pixels of an original input image are shown as pixels 205. These pixels may be provided to a sampling window module 210 that locates a sampling window in the input image. A sampling window may be based on a specific point or location in the input image. Such a location may be represented by a center pixel coordinate that may be provided to sampling window module 210 by a sample point locator module 215. The sampling window module 210 may then provide two pixels to bilinear filtering module 220. The sampling window module 210 may also provide eight pixels to an 8-tap Lanczos filtering module 220. In order for the Lanczos filtering module 225 to operate, this module may require filter coefficients. Such coefficients may be provided by coefficients module 230. In the illustrated embodiment, the generation of coefficients by module 230 may use phase information that is provided by sample point locator module 215. Sample point locator module 215 may also provide phase information to bilinear filtering module 220.
Bilinear filtering module 220 and Lanczos filtering module 225 may each provide respective resized images to blending module 240. In order to perform blending of these inputs, blending module 240 may also require local content information provided by local content analysis module 245. Local content analysis module 245 may generate the local content information on the basis of pixels identified by a sampling window module 210. These pixels may be viewed as the window of pixels surrounding the pixel coordinate identified by sample point locator module 215.
The blending module 240 may provide filtering results to output module 255. The output module 255 may generate a scaled image composed of pixels 260. In order to generate this scaled image, output module 255 may rely on information provided by detection and correction module 250. This latter module may identify and correct artifacts that are found in the blended output of module 240. In the illustrated embodiment, detection and correction module 250 may also take advantage of local content information produced by local content analysis module 245. The scaled image composed of pixels 260 may then be sent to a display device for viewing, or may be sent to a memory device for storage and/or additional subsequent processing.
FIG. 3 illustrates a scaling process, according to an embodiment. This figure shows a set of pixels in a scaled image 310. The darkened pixels may collectively represent a sampling window. The indicated pixel yi may represent a center pixel for the window. The other pixels in the window are labeled as xi−3, xi−2, xi−1, xi0, xi1, xi2, xi3, and xio, where yi may fall between xi0 and xi1.
Note that, in general, an interpolator includes two components, a horizontal interpolator and a vertical interpolator. In FIG. 3, and in the remainder of this description, processing is described in terms of horizontal interpolation. It should be understood that processing with respect to vertical interpolation may be analogous. The concepts, processes, and systems described herein with respect to horizontal interpolation may be directly applicable to vertical interpolation.
In the case of horizontal interpolation, as in the case of vertical interpolation, the sample point locator module first determines the two pixels between which the center pixel is located. In the example of FIG. 3, those two pixels are shown as xi0 and xi1. The phase differences between xi0 and yi, and between yi and xi1 are shown as iphase and 1−iphase respectively. Assuming that i0ε int and iphase ε[0,1), then the bilinear interpolated pixel yiB may be calculated as

yiB=xi0*(1−iphase)+xi1*iphase.

Here, both iphase and 1−iphase are between 0 and 1. yiB may therefore be viewed as a weighted sum of xi0 and xi1.

The realization of yi using an 8-tap Lanczos filter may be calculated as

yiL=Σxikhkiphase where k=−3,−2, . . . , 4.

Here, hkiphase is the sample from the 4-lobed Lanczos-windowed function

hkiphase=(sin π[(k−iphase)*sf]/π[(k−iphase)*sf])(sin π[((k−iphase)/4)*sf]/π[((k−iphase)/4)*sf]) when |k−iphase)*sf|<4, and

hkiphase=0 when |(k−iphase)*sf|>=4.

In the above expressions, sf represents the scaling factor.

Blending yiB and yiL may maintain the sharpness that comes from Lanczos filtering while reducing the ringing effect. Such blending may result in the realization of yi as

yiBL=αi*yiL+(1−αi)*yiB,

where αi=f(xi−3, xi−2, xi−1, xi0, xi1, xi2, xi3, xi4) and α may be a function of local content. In an embodiment, αi may be defined as follows:

αi=max(D′,D′′),

where

D′′=max(|ik−ik+1|), where kε−2, −1, 0, . . . 4,
D′=min(D1, D2),
D1=min[max(|Xi1−Xi2|,|Xi0−Xi1|), max(|Xi1−Xi2|,|Xi2−Xi3|)], and
D2=[Xi1+Xi1−2Xi0]+[2Xi2−Xi1−Xi3].
Once blending is complete, the determination may be made as to whether a pixel yiBL represents an artifact. If the pixel is determined to be an artifact, then the pixel may be replaced by the pixel, for the same location, that had resulted from application of the bilinear filtering, yiB. In an implementation, detection of an artifact at yiBL may result in the setting of a flag. For any pixel where such a flag is set, the pixel may be replaced by the pixel yiB that resulted from application of the bilinear filtering. Stated more formally, for the output pixel yiout,

yiout=yiB if flag(yi)=1, and

yiout=yiBL if flag(yi)=0

In an embodiment, a pixel may be determined to be an artifact by applying the test illustrated in FIG. 4. This figure shows a set of logical expressions 410-450, where if any of these are false, then the pixel yi is not an artifact, and the final output pixel yiout may keep the value yiBL. If all the conditions 410-450 are true, then the pixel yi may be considered to be an artifact, and yiout may be assigned the value yiB.
At 410, a determination may be made as to whether the following is true:

|yiL−yiB|>f1(Xi−3,Xi−2, . . . , Xi3,Xi4).

If not, then flag(yi) may be given a value 0 at 470, and the process concludes at 480. If this expression is true, the process may continue at 420.

At 420, a determination may be made as to whether the following is true:

|Xi0−Xi1|<f2(Xi−3,Xi−2, . . . , Xi3,Xi4).

If not, then flag(yi) may be given a value 0 at 470, and the process may conclude at 480. If this expression is true, the process may continues at 430.

At 430, a determination may be made as to whether the following is true:

|Xi0−Xi−1|>f3(Xi−3,Xi−2, . . . , Xi3,Xi4).

If not, then flag(yi) may be given a value 0 at 470, and the process may conclude at 480. If this expression is true, the process may continue at 440.

At 440, a determination may be made as to whether the following is true:

sign[(Xi0−Xi−1)*h−1iphase]<0.

If not, then flag(yi) may be given a value 0 at 470, and the process may conclude at 480. If this expression is true, the process may continue at 450.

At 450, a determination may be made as to whether the following expression is true:

!{[|Xik−1−Xk|>f4(Xi−3,Xi−2, . . . , Xi3,Xi4)] & [∥Xik−1−Xik|−|Xi0−Xi−1∥>f5(Xi−3,Xi−2, . . . , Xi3,Xi4)]}

    
    
        for all k=−2, −1, 0, 1, 2, 3, 4
        
            or

|yiL−yiB|/(yiL+yiB)>f6(Xi−3,Xi−2, . . . , Xi3,Xi4)

If not, then flag(yi) may be given a value 0 at 470, and the process may conclude at 480. If this expression is true, the process may continue at 460. At 460, flag(yi) may be given a value of 1.

        
        
    
    


The functions f1 through f6 may be defined as functions of (Xi−3, Xi−2, . . . , Xi3, Xi4) as indicated above. Alternatively, f1 through f6 may be given predefined constant values. In an embodiment,
f1=64,
f2=16,
f3=20,
f4=20,
f5=10, and
f6=1.
Note that the application of 410-440 may capture interpolated pixels with large undershoot values in certain image patterns, such as smooth regions with some regular thin strips. The application of 450 may, for other image patterns, perform protection of undershoot values to maintain sharpness.
One or more features disclosed herein may be implemented in hardware, software, firmware, and combinations thereof, including discrete and integrated circuit logic, application specific integrated circuit (ASIC) logic, and microcontrollers, and may be implemented as part of a domain-specific integrated circuit package, or a combination of integrated circuit packages. The term software, as used herein, refers to a computer program product including a computer readable medium having computer program logic stored therein to cause a computer system to perform one or more features and/or combinations of features disclosed herein.
A software embodiment is illustrated in the context of a computing system 500 in FIG. 5. System 500 may include a processor 520 and a body of memory 510 that may include one or more computer readable media that may store computer program logic 540. Memory 510 may be implemented as a hard disk and drive, a removable media such as a compact disk and drive, or a read-only memory (ROM) device, for example. Processor 520 and memory 510 may be in communication using any of several technologies known to one of ordinary skill in the art, such as a bus. Computer program logic contained in memory 510 may be read and executed by processor 520. One or more I/O ports and/or I/O devices, shown collectively as I/O 530, may also be connected to processor 520 and memory 510.
Computer program logic may include modules 550 and 560, according to an embodiment. Blending logic 550 may be responsible for blending the outputs of an interpolation process that uses bilinear filtering, and an interpolation process that uses 8-tap Lanczos filtering. The blending process is described above, according to an embodiment. Artifact detection and correction logic 560 may be responsible for evaluating pixels that are output from blending logic 550. In this evaluation, a determination may be made for each pixel as to whether the pixel represents an artifact. Details of this determination are described above with respect to FIG. 4. Logic 560 may then correct any such artifacts.
In an embodiment, the resulting image, with artifacts corrected, may be sent to I/O 530, which may include a display on which the image may be displayed. Alternatively, the image may be sent to a memory device for storage.
Methods and systems are disclosed herein with the aid of functional building blocks that illustrate the functions, features, and relationships thereof. At least some of the boundaries of these functional building blocks have been arbitrarily defined herein for the convenience of the description. Alternate boundaries may be defined so long as the specified functions and relationships thereof are appropriately performed.
While various embodiments are disclosed herein, it should be understood that they have been presented by way of example only, and not limitation. It will be apparent to persons skilled in the relevant art that various changes in form and detail may be made therein without departing from the spirit and scope of the methods and systems disclosed herein. Thus, the breadth and scope of the claims should not be limited by any of the exemplary embodiments disclosed herein.

## Claims

1. A method, comprising:
scaling an input image using bilinear filtering, generating a first output;
scaling the input image using 8-tap Lanczos filtering, generating a second output;
blending the first and second outputs to create a blended image;
detecting artifacts in the blended image;
correcting the detected artifacts; and
displaying, on a display device, an output image that results from said detection and correction of the artifacts,
wherein said method is performed using a programmable processor.

2. The method of claim 1, wherein said the scaling of the input image using bilinear filtering comprises:
calculating a pixel of the first output as


yiB=xi0*(1−iphase)+xi1*iphase,


where
i0 and i1 are x-coordinates of respective pixels on either side of the pixel yi of the input image,
xi0 and xi1 are pixels at respective locations i0 and i1,
i0ε int, and
iphase ε [0,1).

3. The method of claim 2, wherein said scaling of the input image using 8-tap Lanczos filtering comprises:
calculating a pixel of the second output as


yiL=Σxikhkiphase 


where k=−3, −2, . . . , 4,
hkiphase is a sample from a 4-lobed Lanczos-windowed function


hkiphase=(sin π[(k−iphase)*sf]/π[(k−iphase)*sf])(sin π[((k−iphase)/4)*sf]/π[((k−iphase)/4)*sf]) when |k−iphase)*sf|<4, and



hkiphase=0 when |k−iphase)*sf|>=4.

4. The method of claim 3, wherein a pixel yiBL of the blended image is calculated as yiBL=αi*yiL+(1−αi)*yiB, where αi=f(xi−3, xi−2, xi−1, xi0, xi1, xi2, xi3, xi4) and α is a function of local content.

5. The method of claim 3, wherein detecting artifacts comprises determining whether the following conditions are met,


|yiL−yiB|>f1(Xi−3,Xi−2, . . . , Xi3,Xi4);



|Xi0−Xi1|<f2(Xi−3,Xi−2, . . . , Xi3,Xi4);



|Xi0−Xi−1|>f3(Xi−3,Xi−2, . . . , Xi3,Xi4);



sign[(Xi0−Xi−1)*h−1iphase]<0;



!{[|Xik−1−Xik|>f4(Xi−3,Xi−2, . . . , Xi3,Xi4)] & [∥Xik−1−Xik|−|Xi0−Xi−1∥>f5(Xi−3,Xi−2, . . . , Xi3,Xi4)]}

for all k=−2, −1, 0, 1, 2, 3, 4
or


|yiL−yiB|/(yiL+yiB)>f6(Xi−3,Xi−2, . . . , Xi3,Xi4),




where, when the conditions are met, then pixel yiBL is determined to be an artifact.

6. The method of claim 5, wherein when pixel yiBL is determined to be an artifact, then correction of the artifact comprises replacing yiBL with yiB.

7. A system, comprising:
a processor; and
a memory in communication with said processor, wherein said memory stores
a plurality of processing instructions configured to direct said processor to scale an input image using bilinear filtering, generating a first output,
a plurality of processing instructions configured to direct said processor to scale the input image using 8-tap Lanczos filtering, generating a second output,
a plurality of processing instructions configured to direct said processor to blend the first and second outputs to create a blended image,
a plurality of processing instructions configured to direct said processor to detect artifacts in the blended image,
a plurality of processing instructions configured to direct said processor to correct the detected artifacts, and
a plurality of processing instructions configured to direct said processor to display, on a display device, an output image that results from the detection and correction of the artifacts.

8. The system of claim 7, wherein said plurality of processing instructions configured to direct said processor to scale the input image using bilinear filtering comprises:
processing instructions configured to direct said processor to calculate a pixel of the first output as


yiB=xi0*(1−iphase)+xi1*iphase,


where
i0 and i1 are x-coordinates of respective pixels on either side of the pixel yi of the input image,
xi0 and xi1 are pixels at respective locations i0 and i1,
i0ε int, and
iphase ε [0,1).

9. The system of claim 8, wherein said plurality of processing instructions configured to direct said processor to scale the input image using 8-tap Lanczos filtering comprises:
processing instructions configured to direct said processor to calculate a pixel of the second output as


yiL=Σxikhkiphase where k=−3,−2, . . . , 4,



where hkiphase is a sample from a 4-lobed Lanczos-windowed function


hkiphase=(sin π[(k−iphase)*sf]/π[(k−iphase)*sf])(sin π[((k−iphase)/4)*sf]/π[((k−iphase)/4)*sf]) when |k−iphase)*sf|<4, and



hkiphase=0 when |k−iphase)*sf|>=4.

10. The system of claim 9, wherein said plurality of processing instructions configured to direct said processor to blend said first and second outputs comprises:
processing instructions configured to direct said processor to calculate a pixel yiBL of the blended image as


yiBL=αi*yiL+(1−αi)*yiB,



where αi=f(xi−3, xi−2, xi−1, xi0, xi1, xi2, xi3, xi4) and α is a function of local content.

11. The system of claim 9, wherein said plurality of processing instructions configured to direct said processor to detect artifacts comprises:
processing instructions configured to direct said processor to determine whether the following conditions are met,


|yiL−yiB|>f1(Xi−3,Xi−2, . . . , Xi3,Xi4);



|Xi0−Xi1|<f2(Xi−3,Xi−2, . . . , Xi3,Xi4);



|Xi0−Xi−1|>f3(Xi−3,Xi−2, . . . , Xi3,Xi4);



sign[(Xi0−Xi−1)*h−1iphase]<0;



!{[|Xik−1−Xik|>f4(Xi−3,Xi−2, . . . , Xi3,Xi4)] & [∥Xik−1−Xik|−|Xi0−Xi−1∥>f5(Xi−3,Xi−2, . . . , Xi3,Xi4)]}

for all k=−2, −1, 0, 1, 2, 3, 4
or


|yiL−yiB|/(yiL+yiB)>f6(Xi−3,Xi−2, . . . , Xi3,Xi4),





where, when the conditions are met, then pixel yiBL is determined to be an artifact.

12. The system of claim 11, wherein said processing instructions configured to direct said processor to correct the detected artifacts comprises:
processing instructions configured to direct said processor to replace yiBL with yiB when yiBL has been determined to be an artifact.

13. A computer program product including a non-transitory computer readable medium having computer program logic stored therein, the computer program logic including:
logic to cause a processor to scale an input image using bilinear filtering, generating a first output;
logic to cause the processor to scale the input image using 8-tap Lanczos filtering, generating a second output;
logic to cause the processor to blend the first and second outputs to create a blended image;
logic to cause the processor to detect artifacts in the blended image;
logic to cause the processor to correct the detected artifacts; and
logic to cause the processor to display, on a display device, an output image that results from the detection and correction of the artifacts.

14. The computer program product of claim 13, wherein the logic to cause the processor to scale the input image using bilinear filtering comprises:
logic to cause the processor to calculate a pixel of the first output as


yiB=xi0*(1−iphase)+xi1*iphase,


where i0 and i1 are x-coordinates of respective pixels on either side of the pixel yi of the input image,
xi0 and xi1 are pixels at respective locations i0 and i1,
i0ε int, and
iphase ε [0,1).

15. The computer program product of claim 14, wherein said logic to cause the processor to scale the input image using 8-tap Lanczos filtering comprises:
logic to cause the processor to calculate a pixel of the second output as


yiL=Σxikhkiphase where k=−3,−2, . . . , 4


where hkiphase is a sample from a 4-lobed Lanczos-windowed function


hkiphase=(sin π[(k−iphase)*sf]/π[(k−iphase)*sf])(sin π[((k−iphase)/4)*sf]/π[((k−iphase)/4)*sf]) when |k−iphase)*sf|<4, and



hkiphase=0 when |k−iphase)*sf|>=4.

16. The computer program product of claim 15, wherein said logic to cause the processor to blend the first and second outputs comprises:
logic to cause the processor to calculate a pixel yiBL as


yiBL=αi*yiL+(1−αi)*yiB,



where αi=f(xi−3, xi−2, xi−1, xi0, xi1, xi2, xi3, xi4) and α is a function of local content.

17. The computer program product of claim 15, wherein said logic to cause the processor to detect artifacts comprises:
logic to cause the processor to determine whether the following conditions are met:


|yiL−yiB|>f1(Xi−3,Xi−2, . . . , Xi3,Xi4);



|Xi0−Xi1|<f2(Xi−3,Xi−2, . . . , Xi3,Xi4);



|Xi0−Xi−1|>f3(Xi−3,Xi−2, . . . , Xi3,Xi4);



sign[(Xi0−Xi−1)*h−1iphase]<0;



!{[|Xik−1−Xik|>f4(Xi−3,Xi−2, . . . , Xi3,Xi4)] & [∥Xik−1−Xik|−|Xi0−Xi−1∥>f5(Xi−3,Xi−2, . . . , Xi3,Xi4)]}


for all k=−2, −1, 0, 1, 2, 3, 4
or


|yiL−yiB|/(yiL+yiB)>f6(Xi−3,Xi−2, . . . , Xi3,Xi4),




where, when the conditions are met, pixel yiBL is determined to be an artifact.

18. The computer program product of claim 17, wherein said logic to cause the processor to correct artifacts comprises:
logic to cause the processor to replace yiBL with yiB.