The content of the invention
The embodiment of the present invention provides image-scaling method, image scaling device and electronic equipment, to solve conventional images
Scaling algorithm is easily caused the problem of obvious sawtooth effect occur when the angle of image border is smaller.
In order to solve the above technical problems, the embodiments of the invention provide a kind of image-scaling method.Methods described includes:Meter
The attribute of image procossing window is calculated, the attribute includes the gradient and angle that described image handles window, and described image processing window is
Image-region with intended pixel quantity;At least one scaling filter curve is determined, the scaling filter curve has and institute
State the corresponding curvature of attribute;In described image processing window, the scaling filter curve is used.
Alternatively, the attribute for calculating image procossing window, is specifically included:By edge detection operator, the figure is calculated
As the horizontal gradient and vertical gradient of processing window;The gradient and angle are calculated according to the horizontal gradient and vertical gradient.
Alternatively, the gradient is calculated by following formula:G=| GH |+| GV |;The angle passes through following formula meter
Calculate:Wherein, G is gradient, and Arg is angle, and GH is horizontal gradient, and GV is vertical gradient.
Alternatively, methods described also includes:When the gradient for handling window in described image is more than predetermined threshold value;Determine the figure
As processing window is image border.
Alternatively, it is described to determine at least one scaling filter curve, specifically include:It is image side in described image processing window
During edge, according to predetermined Rule of judgment, scaling filter curve corresponding with described image edge is selected;The scaling filter curve
With the curvature being adapted with the angle of image border;When described image processing window is not image border, selection has initial
The pre-set zoom filter curve of curvature.
In order to solve the above technical problems, the embodiment of the present invention additionally provides a kind of image scaling device.Described device includes:
Attribute computing module, the attribute for calculating image procossing window, the attribute includes gradient and the angle that described image handles window
Degree, described image processing window is the image-region with intended pixel quantity;Filter curve selecting module is scaled, for determining extremely
Few scaling filter curve, the scaling filter curve has curvature corresponding with the attribute;Zoom module, in institute
State in image procossing window, use the scaling filter curve.
Alternatively, the attribute computing module specifically for:By edge detection operator, described image processing window is calculated
Horizontal gradient and vertical gradient;The gradient and angle are calculated according to the horizontal gradient and vertical gradient.
Alternatively, the gradient is calculated by the gradient by following formula:G=| GH |+| GV |;The angle passes through
Following formula is calculated:Wherein, G is gradient, and Arg is angle, and GH is horizontal gradient, and GV is vertical gradient.
Alternatively, described device also includes:Edge detection module;The edge detection module is used for, at described image
When the gradient for managing window is more than predetermined threshold value;Determine that described image processing window is image border.
Alternatively, it is described scaling filter curve module specifically for:When described image processing window is image border, according to
Predetermined Rule of judgment, selects scaling filter curve corresponding with described image edge;The scaling filter curve has and figure
As the adaptable curvature of the angle at edge;When described image processing window is not image border, selection is pre- with initial curvature
If scaling filter curve.
In order to solve the above technical problems, the embodiment of the present invention additionally provides at least one processor, and with it is described at least
The memory of one processor communication connection;Wherein, have can be by least one computing device for the memory storage
Instruction repertorie, the instruction repertorie is by least one described computing device, so that at least one described processor is able to carry out
Image-scaling method as described above.
The image-scaling method and its device provided in the embodiment of the present invention, can be adaptive according to the gradient angle of image
Adjustment filter curve, using suitable curvature filter curve carry out image interpolation, so as to avoid causing image because curvature is excessive
There is the acutance that image border is also ensure that while obvious sawtooth effect in edge, obtains balance between the two.
Embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, it is right below in conjunction with drawings and Examples
The present invention is further elaborated.It should be appreciated that specific embodiment described herein is only to explain the present invention, not
For limiting the present invention.
Sawtooth effect is common artifact effect during image scaling.It is often as needing in image amplification
There is larger difference between the interpolation in different phases, interpolation result, caused by transition is not smooth enough.
" image border " (edge) refers to that image local intensity changes most significant part, and it represents that image intensity is not connecting
The both sides at continuous place have significant difference.Its different target for being primarily present in image, target and background, different zones or not
With between color.It is common, Spline smoothing function or lines can be used to change function to represent image border.Image border
It can be described with two attributes of angle and gradient.
When general, when carrying out image scaling using filter curve as depicted in figs. 1 and 2, with sharpening figure
As the effect at edge, the image scaling effect for meeting use requirement can be obtained.But the curvature of above-mentioned scaling filter curve is higher.
If the angle between horizontal gradient and vertical gradient in image is smaller, interpolation result can be caused to differ using such curve
It is larger so that obvious sawtooth effect occurs in image border.
Certainly, the sawtooth effect of image border can be alleviated to a certain extent using the relatively low curve of some curvature, but
Such interpolation method declines the definition for causing image after scaling, and more image borders occur fuzzy and are unfavorable for scaling
The use of image afterwards.
Fig. 3 is the operation chart of typical image scaling.As shown in figure 3, treat zoomed image 10 for dot matrix image (due to
The image display effect problems such as distortion, deformation are not present in the vector image described by function during scaling.Therefore, herein
It is not covered), its size is p × q pixel.
In the present embodiment, treat that zoomed image 10 zooms in and out processing to described using n × n templates, scheme after being scaled
As 20.Consider or be related in one minimal processing unit of n × n template representations image processing algorithm, scaling algorithm
Pixel quantity (neighborhood).In the implementation procedure of image processing algorithm, each pixel of zoomed image 10 is treated successively to be made
Image Zooming Algorithm is repeated with n × n templates, so as to obtain image 20 after final scaling.
It is easy for statement, it is described in detail below by taking a BiCubic interpolation as an example:If pending image 10 is one
The size of image 20 is 2p × 2q after 256 grades of gray-scale maps (value of i.e. each pixel is 0-255), scaling.
Typical image scaling process is actually the filling process to the picture element matrix of image after scaling 20.Filling
Cheng Zhong, according to the value for the pixel for treating zoomed image 10, to determine the value (i.e. interpolation) of new picture element matrix.
For some point (x, y) in the picture element matrix of image after scaling 20,4 × 4 neighborhood point near it can be taken
(xi, yi), i takes 1,2,3,4, and interpolation calculation is carried out according to equation below:
Wherein, W is BiCubic functions.
Repeat the interpolation operation, it is determined that scaling after image 20 picture element matrix in each pixel value, until contracting
Put rear image 20 picture element matrix be filled and finish after, you can image 20 after being scaled.
As described above, when carrying out image scaling using above-mentioned algorithm, occurring in the less image border of some angles bright
Aobvious sawtooth effect.In actual use, it can protected by using image-scaling method provided in an embodiment of the present invention
Preferable anti-aliasing effect is obtained to image border while holding image definition after scaling.
Fig. 4 is image-scaling method provided in an embodiment of the present invention.As shown in figure 4, this method may include steps of:
100th, the attribute of image procossing window is calculated, the attribute includes the gradient and angle that described image handles window.
Here, representing that the images such as the above-mentioned template with particular size or processing unit contract using " image procossing window "
Put the neighborhood that algorithm carries out consideration during computing, e.g. 4 × 4 or 3 × 3 image procossing window.Such image procossing window is
Image-region with intended pixel quantity, for an image procossing window or pixel region with particular size, it has
There is the angle of gradient in the gradient and different directions of the pixel value changing condition of reflection image procossing window.
Here, using " gradient " to represent that reflection whole image handles the population gradient of window.Represent different using " angle "
The angle between gradient on direction.Attribute of the gradient and angle of the image procossing window to describe image border, weighs certain
Whether individual image procossing window belongs to the property of image border or image border.It can specifically pass through any suitable image side
Edge detective operators are calculated.
200th, at least one scaling filter curve is determined, the scaling filter curve has song corresponding with the attribute
Rate.The attribute calculated by step 100 can be as the quantization parameter for weighing image procossing window, and step 200 is one according to this
The process that sample quantization parameter is adaptively adjusted to the curvature for scaling filter curve.
It is described scaling filter curve can be specifically any suitable type filter curve, the value to calculate pixel,
Filler pixels matrix is so as to realize the zoom operations of image, such as BiCubic functions, lanczos functions.In other implementations
In example, the scaling filter curve can also be to be adjusted based on the existing function curve usually used by regulation parameter to curvature
Obtained after whole, such as it is as shown in Figure 8, after being adjusted, the scaling filter curve with more gradual curvature.
In step 200, it is determined that the foundation of scaling filter curve is bent curvature of a curve, to obtain for image procossing window category
The smoother interpolation result of property.Certainly, those skilled in the art can also be according to actual application needs, according to more screenings
Rule selects or determined the scaling filter curve needed to use.
300th, in described image processing window, the scaling filter curve is used.It is determined that corresponding with image procossing window
After filter curve, the scaling filter curve for the curvature being adapted with attribute is used image procossing window to carry out the calculating of pixel value.
In image-scaling method provided in an embodiment of the present invention, due to combine image procossing window attribute (gradient and
Angle) as criterion, the curvature for the scaling filter curve that adaptive adjustment is used, so avoiding in image procossing window
Angle it is less in the case of, the problem of causing serious sawtooth effect occur because bent curvature of a curve is too high.It is certainly to be additionally, since it
The process of adaptation, is remained able to bent using the scaling filtering of high curvature in other image sections or suitable image border
Line, with sharpening effect so as to ensure the definition in these regions.
Above-mentioned selection or adjustment according to image procossing window attribute self-adaptive scales the mode of filter curve, can take into account
The global zooming effect of image, it is to avoid cause the obvious sawtooth effect of appearance of image border because overemphasizing and sharpening so that
The quality of image 20 is obviously improved after scaling.
Below by taking conventional edge detection algorithm-Sobel (sobel) operator as an example, the embodiment of the present invention is described in detail and carries
The image procossing window attribute calculating process of the image-scaling method of confession.
As shown in figure 5, described image processing window attribute calculating process can include:
510:The horizontal gradient GH of image procossing window horizontal direction and hanging down for vertical direction are calculated using sobel algorithm templates
Vertical ladder degree GV.
Wherein, for some pixel (x, y), its horizontal gradient GH (x, y) and vertical gradient gradient G V (x, y) are respectively
For:
GV (x, y)=(I (x-1, y+1)+2 × I (x, y+1)+I (x+1, y+1))-(I (x-1, y-1)+2 × I (x, y-1)+
I(x+1,y-1));
GH (x, y)=(I (x+1, y-1)+2 × I (x+1, y)+I (x+1, y+1))-(I (x-1, y-1)+2 × I (x-1, y)+
I(x-1,y+1))。
520:According to horizontal gradient GH and vertical gradient GV, total gradient intensity G and angle A rg is calculated respectively.It is optional
Ground, can specifically be calculated by following formula:G=| GH |+| GV |;
It will be appreciated by persons skilled in the art that in further embodiments, other suitable computings can also be passed through
Method determines the gradient or angle of image procossing window, for example, can pass through formula:Determined always to calculate
Gradient intensity G.In calculating process, aim at and determine that gradient and angle to describe image procossing window etc. are quantifiable
Attribute.
, can be specific by the following method it is determined that after the gradient and angle of described image processing window please continue to refer to Fig. 5
The filtering scaling curve that uses of determination.
530:Judge whether gradient intensity G is more than predetermined threshold value.If performing step 540, if otherwise performing step 531.
531:Selection uses the scaling filter curve curve default with initial curvature.
540:Judge whether angle A rg is less than default first angle, if performing step 541, step is performed if not
550。
541:Selection uses the scaling filter curve curve1 with first curvature.
550:Judge whether angle A rg is less than default second angle, if performing step 551, step is performed if not
560。
551:Selection uses the scaling filter curve curve2 with torsion.
560:Judge whether angle A rg is less than default third angle, if performing step 561.
In the present embodiment, both it had been probably acute angle due to calculating the angle A rg obtained, it is also possible to obtuse angle angle
(direction relationses for depending on both horizontal gradient and vertical gradient).Therefore, it is necessary to add adaptation during being judged
In the Rule of judgment of obtuse angle angle.That is, for each angle A rg judgment steps (such as step 440,450 and 460), its
Two following Rule of judgment should be included:
1):Whether angle A rg absolute value is less than predetermined angle argth
2):Whether the absolute value of angle A rg and pi/2 (i.e. corresponding 90 ° of radians) difference is less than predetermined angle argth.
It is the relation of "or" between two Rule of judgment, in the case where meeting any one it is considered that angle A rg is small
In predetermined angle (such as default first angle, second angle or third angle).
561:Selection uses the scaling filter curve curve3 with the 3rd curvature.
……
In the present embodiment, according to default threshold value in step 510, whether the gradient intensity for weighing image procossing window belongs to
Image border (similar with the thought of sobel algorithms).If being not belonging to image border, generally it can be thought that need not be filtered to scaling
Curve is adjusted and can directly use the scaling filter curve of initial setting up.
After it is determined that image procossing window belongs to image border, just further adaptively adjusted into follow-up curvature
Journey.Thereafter selection step belongs to the process of selection optimal curvature, by being multiple intervals by angular divisions, order it is each interval with
One scales the corresponding mode of filter curve to complete.It can also set more or set according to actual needs after step 560
Less interval is put, corresponding judgment step is set.In certain embodiments, if the angle A rg is more than certain angle,
It can also select to use the scaling filter curve with initial curvature.That is, it is equal in whole angle judgment steps to work as angle A rg
During to be judged as NO, then step 531 is performed.
Alternatively, other different Rule of judgment or determination strategy etc. can also be used, the target of above-mentioned optimizing is completed
(determining optimal curvature).
In embodiments of the present invention, the need for specifically can be according to actual conditions, determine specifically to need after debugging or experiment
The region quantity to be divided, the curvature of the corresponding scaling filter curve of regional.
Alternatively, the scaling filter curve can be based on same function curve, adjusted and obtained by regulation parameter,
For example for bicubic function curve W (x), x '=mx can be simply made, the function song of required curvature is obtained by adjusting m
Line W (x ').
The image scaling processing procedure that above-mentioned embodiment of the method is provided specifically can be any suitable, with logic fortune
Realized in the electronics calculating platform of calculation ability.Fig. 6 is provided in an embodiment of the present invention, can perform described image scaling treated
The electronic equipment of journey.
As shown in fig. 6, the electronic equipment includes:With at one in one or more processors 610, memory 620, Fig. 6
Exemplified by reason device 610.In certain embodiments, it can also include:Input unit and output device.
Processor, memory, input unit and output device can be connected by bus or other modes, in Fig. 6 with
Exemplified by being connected by bus.
Memory 620 is as a kind of non-volatile computer readable storage medium storing program for executing, available for storage non-volatile software journey
Sequence, non-volatile computer executable program and module.Processor 610 is stored in non-easy in memory 620 by operation
The property lost software program, instruction and module, so as to perform described image Zoom method.
Memory 620 can include storing program area and storage data field, wherein, storing program area can store operation system
Application program required for system, at least one function;Storage data field can be stored to be created according to using for image-scaling method
Data etc..In addition, memory 620 can include high-speed random access memory, nonvolatile memory, example can also be included
Such as at least one disk memory, flush memory device or other non-volatile solid state memory parts.In certain embodiments, deposit
Reservoir 620 is optional including the memory remotely located relative to processor 610, and the example of above-mentioned network includes but is not limited to interconnection
Net, intranet, LAN, mobile radio communication and combinations thereof.
Input unit can receive the numeral or character information of input, and produce with the user of image-scaling method set with
And the relevant key signals input of function control.Output device may include the display devices such as display screen.One or more of moulds
Block is stored in the memory 620, when being performed by one or more of processors 610, performs above-mentioned any means
Image-scaling method in embodiment.
The embodiment of the present invention also further provides a kind of image scaling device.Fig. 7 is provided in an embodiment of the present invention
The functional block diagram of image scaling device.Described image device for zooming has some program function modules, can be stored in such as Fig. 6 institutes
In the memory of the electronic equipment shown, for processor call and from perform as above embodiment of the method disclose image-scaling method.
As shown in fig. 7, described image device for zooming can include:Attribute computing module 100, scaling filter curve selection mould
Block 200 and Zoom module 300.
Wherein, the attribute computing module 100 is used for the attribute for calculating image procossing window.The attribute includes described image
Handle the gradient and angle of window.The scaling filter curve selecting module 200 is used to determine at least one scaling filter curve,
The scaling filter curve has curvature corresponding with the attribute.The Zoom module 300 is used to handle window in described image
In, use the scaling filter curve.
Alternatively, please continue to refer to Fig. 7, described image device for zooming can also further include a rim detection mould
Block 400.The edge detection module 400 is used to, when the gradient that described image handles window is more than predetermined threshold value, determine the figure
As processing window is image border.
In another embodiment, the attribute computing module 100, scaling filter curve selecting module 200 and scaling mould
Block 300 can also further be used to realize one or more in the image-scaling method disclosed in above method embodiment
Step.
For example, the attribute computing module 100 specifically can be used for:By edge detection operator, calculate at described image
Manage the horizontal gradient and vertical gradient of window;According to the horizontal gradient and vertical gradient calculate described image processing window gradient and
Angle.
The scaling filter curve module 200 specifically can be used for:According to predetermined Rule of judgment, selection and described image
The corresponding scaling filter curve in edge;The scaling filter curve has the curvature adaptable with the angle of image border.
It should be noted that the device embodiment is based on identical inventive concept with embodiment of the method.Therefore, method is implemented
Corresponding contents in example are equally applicable to device embodiment, are no longer described in detail herein.
Those skilled in the art should further appreciate that, with reference to showing that the embodiments described herein is described
The image-scaling method of example property, can be realized with electronic hardware, computer software or the combination of the two, in order to clearly say
The interchangeability of bright hardware and software, generally describes the composition and step of each example according to function in the above description
Suddenly.These functions are performed with hardware or software mode actually, depending on the application-specific and design constraint bar of technical scheme
Part.
Those skilled in the art can realize described function to each specific application using distinct methods, but
It is this realization it is not considered that beyond the scope of this invention.Described computer software can be stored in embodied on computer readable storage Jie
In matter, the program is upon execution, it may include such as the flow of the embodiment of above-mentioned each method.Wherein, described storage medium can be
Magnetic disc, CD, read-only memory or random access memory etc..
Embodiments of the present invention are the foregoing is only, are not intended to limit the scope of the invention, it is every to utilize this
Equivalent structure or equivalent flow conversion that description of the invention and accompanying drawing content are made, or directly or indirectly it is used in other correlations
Technical field, is included within the scope of the present invention.