Embodiment
In order to make object of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, be not intended to limit the present invention.
In the embodiment of the present invention, a width source images is split as multiple data block, when after reading data block, interpolation processing and coded treatment is carried out to this data block, until by multiple data block interpolation of fractionation and end-of-encode.
Embodiments provide one: image scaling, coding method and system.
Described method comprises: obtain source images size, and the size of image and the size of each data block after specifying interpolation after specifying interpolation;
Determine the sequence number of the current data block from source images reading;
The data block read from source images is determined according to the size of each data block after the size of image after the size of source images, interpolation, interpolation and described data block sequence number;
Successively following steps are performed to each data block read:
Interpolation processing is carried out to the data block read;
Data block after terminating interpolation processing carries out coded treatment.
Described system comprises: parameter determination unit, for obtaining source images size, and after specifying interpolation image size and specify the size of each data block after interpolation;
Data block sequence number determining unit, for determining the sequence number of the current data block from source images reading;
Data block determining unit, determines the data block read from source images for the size of each data block after the size of image after the size according to source images, interpolation, interpolation and described data block sequence number;
Interpolation process unit, for carrying out interpolation processing to the data block read;
Coding processing unit, carries out coded treatment for the data block after terminating interpolation processing.
One width source images is divided into multiple data block by the embodiment of the present invention, and carries out interpolation processing to the plurality of data block respectively and the data block after terminating interpolation processing carries out corresponding coded treatment.Owing to not needing just to encode after an image scaling terminates, and do not need to preserve the entire image that convergent-divergent terminates acquisition, therefore, it is possible to effectively reduce the times to be encoded such as view data and the memory space after preserving convergent-divergent shared by image yet.In order to technical solutions according to the invention are described, be described below by specific embodiment.
embodiment one:
Fig. 1 shows the flow chart of image scaling that first embodiment of the invention provides, coding method, and in the present embodiment, an image is divided into multiple data block, and carries out interpolation, coded treatment to the plurality of data block, details are as follows.
In step s 11, obtain source images size, and the size of image and the size of each data block after specifying interpolation after specifying interpolation.
In the present embodiment, a first selected width source images, determines whether to carry out convergent-divergent, coded treatment to this width source images.After determining to need that corresponding convergent-divergent and coded treatment are carried out to this width source images, obtain the size of this source images, and specify the image size that this width image can obtain after interpolation processing, and the data block size that in the data block size assigned source image that at every turn can process according to encoder, each data block can obtain after interpolation processing.
Such as, by one large little be 640 × 480 source images, specify it after interpolation processing, be amplified to 1280 × 960.Because encoder is encoded to the data block that size is 8 × 8 usually, each data block size obtained after therefore can specifying interpolation processing is 8 × 8.
In step s 12, the sequence number of the current data block from source images reading is determined.
Wherein, determine that the step of the sequence number of the current data block from source images reading is specially:
A, with the most top left corner pixel point of source images for initial point, the right is x-axis positive direction, below for y-axis positive direction sets up rectangular coordinate system.In the present embodiment, set up a rectangular coordinate system, this rectangular coordinate system is with the most upper left angle point of source images for initial point, and to the right, y-axis positive direction is downward for x-axis positive direction.
B, the horizontal direction sequence number determining the data block of current reading according to this rectangular coordinate system and vertical direction sequence number.In the present embodiment, horizontal direction sequence number and the vertical direction sequence number of the current data block from source images reading is determined according to the rectangular coordinate system set up.Specifically as shown in Figure 2, wherein, N represents the horizontal direction sequence number of this data block, and M represents the vertical direction sequence number of this data block.From the upper left corner of source images, from left to right, each data block of source images is read from top to bottom.
In step s 13, the data block read from source images is determined according to the size of each data block after the size of image after the size of source images, interpolation, interpolation and this data block sequence number.
The present embodiment is by determining to determine to read those data blocks from source images from the starting point coordinate of source images read block and the data block size of reading.Coordinate due to the first pixel of Computer Storage image is (0,0), therefore the starting point abscissa (x coordinate) being the data block of 1 from source images read level direction sequence number is 0, and the starting point ordinate (y coordinate) being the data block of 1 from source images reading vertical direction sequence number is also 0.
Wherein, determine that the step of the data block read from source images is specially according to the size of each data block after the size of image after the size of source images, interpolation, interpolation and this data block sequence number:
C, when read level direction sequence number is not 1 and vertical direction sequence number is not the data block of 1, determine starting point abscissa and the starting point ordinate of the data block read from source images according to the size of each data block after the size of image after the size of source images, interpolation, interpolation and this data block sequence number.Suppose that the size of source images is src_hsize × src_vsize, the current horizontal direction sequence number read from source images is N number of (N is more than or equal to 2) data block, vertical direction sequence number is M block (M is more than or equal to 2), after appointment interpolation, the size of image is des_hsize × des_vsize, and after appointment interpolation, the size of each data block is k_hsize × k_vsize.First introducing two intermediate variable x_cnt, y_cnt, is the N number of piece of horizontal direction in the current data block obtained from source images, during M block of vertical direction, then:
x_cnt=[(src_hsize-1)×N×k_hsize÷(des_hsize-1)]
-[(src_hsize-1)×(N-1)×k_hsize÷(des_hsize-1)]+1(N=1)
x_cnt=[(src_hsize-1)×N×k_hsize÷(des_hsize-1)]
-[(src_hsize-1)×(N-1)×k_hsize÷(des_hsize-1)](N≥2)
y_cnt=[(src_vsize-1)×M×k_vsize÷(des_vsize-1)]
-[(src_vsize-1)×(M-1)×k_vsize÷(des_vsize-1)]+1(M=1)
y_cnt=[(src_vsize-1)×M×k_vsize÷(des_vsize-1)]
-[(src_vsize-1)×(M-1)×k_vsize÷(des_vsize-1)](M≥2)
Wherein, bracket [] represents floor operation.Represent that before then src_x_position equals horizontal direction, the x_cnt sum of N-1 block subtracts 1, namely from the abscissa corresponding to the starting point coordinate of source images read block and ordinate respectively with src_x_position and src_y_position
before src_y_position equals vertical direction, the y_cnt sum of M-1 block subtracts 1, namely
D, determine the data block size that reads from source images according to the size of each data block after the size of image after the size of source images, interpolation, interpolation and this data block sequence number.In the present embodiment, determine the data block size that need read from source images according to the size of whole source images, the image size after interpolation processing of specifying, the size of each data block after interpolation processing of specifying and the sequence number (horizontal direction sequence number and vertical direction sequence number) of the current data block from source images reading.Suppose that the data block size that need read from source images is t_hsize × t_vsize, if the data block read is first data block of horizontal direction, the intermediate variable x_cnt that then t_hsize equals this block adds 1, if not first of read level direction data block, then the intermediate variable x_cnt that t_hsize equals this block adds 2; If read first data block of vertical direction, then the intermediate variable y_cnt that t_vsize equals this block adds 1, if not read first data block of vertical direction, then the intermediate variable y_cnt that t_vsize equals this block adds 2.
Certainly, also can be determined the source image data that need read from source images by the starting point coordinate and terminal point coordinate determining reading data, repeat no more herein.
After source images reads the data block of specifying size, step S14 and S15 is performed to each data block read.
In step S14, interpolation processing is carried out to the data block read.
In the present embodiment, one by one interpolation processing is carried out to the source image data read in units of each piecemeal.Such as, after have read horizontal direction sequence number from source images be the data block of 1, according to the initial interpolation coefficient of level of picture level direction this data block of Size calculation after source picture level direction size and interpolation; After have read vertical direction sequence number from source images be the data block of 1, according to the vertical initial interpolation coefficient of this data block of picture vertical direction Size calculation after source picture vertical direction size and interpolation, and use the initial interpolation coefficient of this level or vertical initial interpolation coefficient to carry out level or vertical interpolation process to the data block read, then after interpolation processing terminates, preserve the Horizontal interpolation coefficient of this data block or the level initial interpolation coefficient of vertical interpolation coefficient as right side data block or the vertical initial interpolation coefficient of bottom data block.
Be 1 when have read horizontal direction sequence number from source images, vertical direction sequence number is also after the data block of 1.According to the initial interpolation coefficient of level of picture level direction this data block of Size calculation after source picture level direction size and interpolation, according to the vertical initial interpolation coefficient of this data block of picture vertical direction Size calculation after source picture vertical direction size and interpolation, the initial interpolation coefficient of this level is used to carry out horizontal and vertical interpolation processing with vertical initial interpolation coefficient to the data block read, the Horizontal interpolation coefficient of this data block and the level initial interpolation coefficient of vertical interpolation coefficient as right side data block and the vertical initial interpolation coefficient of bottom data block is preserved again after interpolation processing terminates.
Be 2 and after vertical direction sequence number is the data block of 1 when have read horizontal direction sequence number from source images, the horizontal direction sequence number of preserving is 1 and vertical direction sequence number is also the level initial interpolation coefficient of Horizontal interpolation coefficient as this data block of the data block of 1, according to the vertical initial interpolation coefficient of this data block of picture vertical direction Size calculation after source picture vertical direction size and interpolation, the initial interpolation coefficient of this level is used to carry out horizontal and vertical interpolation processing with vertical initial interpolation coefficient to the data block read, the Horizontal interpolation coefficient of this data block and the level initial interpolation coefficient of vertical interpolation coefficient as right side data block and the vertical initial interpolation coefficient of bottom data block is preserved again after interpolation processing terminates.
Be 1 and after vertical direction sequence number is the data block of 2 when have read horizontal direction sequence number from source images, according to the initial interpolation coefficient of level of picture level direction this data block of Size calculation after source picture level direction size and interpolation, the horizontal direction sequence number of preserving is 1 and vertical direction sequence number is also the vertical initial interpolation coefficient of vertical interpolation coefficient as this data block of the data block of 1, the initial interpolation coefficient of this level is used to carry out horizontal and vertical interpolation processing with vertical initial interpolation coefficient to the data block read, the Horizontal interpolation coefficient of this data block and the level initial interpolation coefficient of vertical interpolation coefficient as right side data block and the vertical initial interpolation coefficient of bottom data block is preserved again after interpolation processing terminates.
Be 2 and after vertical direction sequence number is the data block of 2 when have read horizontal direction sequence number from source images, the horizontal direction sequence number of preserving is 1 and vertical direction sequence number is the level initial interpolation coefficient of Horizontal interpolation coefficient as this data block of the data block of 2, the horizontal direction sequence number of preserving is 2 and vertical direction sequence number is the vertical initial interpolation coefficient of vertical interpolation coefficient as this data block of the data block of 1, the initial interpolation coefficient of this level is used to carry out horizontal and vertical interpolation processing with vertical initial interpolation coefficient to the data block read, the Horizontal interpolation coefficient of this data block and the level initial interpolation coefficient of vertical interpolation coefficient as right side data block and the vertical initial interpolation coefficient of bottom data block is preserved again after interpolation processing terminates.
In the present embodiment, when performing interpolation processing to each block data of source images, be all by left side block Horizontal interpolation at the end of interpolation coefficient, initial interpolation coefficient when starting as right side block Horizontal interpolation, and the interpolation coefficient at the end of upper block vertical interpolation, initial interpolation coefficient when then starting as lower block vertical interpolation, like this, the image obtained after effectively ensureing piecemeal interpolation is still continuous print, there is no the vestige of zone of fracture, the basis ensureing interpolation speed also maintains the good experience of user.
In step S15, the data block after terminating interpolation processing carries out coded treatment.
In the present embodiment, when the interpolation processing of a data block terminates, then at once coded treatment is carried out to the data block that this interpolation processing terminates.Wherein, coded system has multiple, as JPEG coding etc.
In the first embodiment of the invention, a width source images is divided into multiple data block, and respectively interpolation processing is carried out to the plurality of data block and the data block after terminating interpolation processing carries out corresponding coded treatment.Owing to not needing just to encode after an image scaling terminates, and do not need to preserve the entire image that convergent-divergent terminates acquisition, therefore, it is possible to effectively reduce the times to be encoded such as view data and the memory space after preserving convergent-divergent shared by image yet.In addition, occur simultaneously because the data of adjacent two data blocks in multiple data blocks that source images is divided into exist some, and the data block on right side carries out with the data block on the left of it interpolation coefficient that interpolation terminates rear acquisition to carry out interpolation, bottom data block carries out with its top data block the interpolation coefficient that interpolation terminates rear acquisition to carry out interpolation, therefore the image obtained after effectively ensureing piecemeal interpolation is still continuous print, there is no the vestige of zone of fracture, the basis ensureing interpolation speed also maintains the good experience of user.
embodiment two:
Fig. 3 shows the structure of image scaling that second embodiment of the invention provides, coded system, for convenience of explanation, illustrate only the part relevant to the embodiment of the present invention.
This image scaling, coded system may be used for the various information processing terminals by wired or wireless network connection server, such as mobile phone, pocket computer (Pocket Personal Computer, PPC), palmtop PC, computer, notebook computer, personal digital assistant (Personal Digital Assistant, PDA) etc., can be run on the software unit in these terminals, the unit that hardware cell or software and hardware combine, also can be integrated in these terminals as independently suspension member or run in the application system of these terminals, wherein:
Parameter determination unit 31, for obtaining source images size, and after specifying interpolation image size and specify the size of each data block after interpolation.
Data block sequence number determining unit 32, for determining the sequence number of the current data block from source images reading.
Wherein, data block sequence number determining unit 32 comprises: establishment of coordinate system module 321 and data block sequence number determination module 322.
Establishment of coordinate system module 321, for the most top left corner pixel point of source images for initial point, the right is x-axis positive direction, below for y-axis positive direction sets up rectangular coordinate system.
Data block sequence number determination module 322, for determining horizontal direction sequence number and the vertical direction sequence number of the data block of current reading according to this rectangular coordinate system.
Data block determining unit 33, determines the data block read from source images for the size of each data block after the size of image after the size according to source images, interpolation, interpolation and this data block sequence number.
Wherein, data block determining unit 33 comprises: the first point coordinates determination module 331 of data block, data block first size determination module 332, the second starting point coordinate determination module 333 of data block and the second size determination module 334 of data block.
The first point coordinates determination module 331 of data block is 0 for the starting point abscissa that to determine from source images read level direction sequence number be the data block of 1, and from source images, to read vertical direction sequence number be the starting point ordinate of the data block of 1 is also 0.
First size determination module 332 of data block, for when read level direction sequence number is the data block of 1, according to formula
x_cnt=[(src_hsize-1)×N×k_hsize÷(des_hsize-1)]
-[(src_hsize-1)×(N-1)×k_hsize÷(des_hsize-1)]+1(N=1)
And t_hsize=x_cnt+1 (N=1) determines the horizontal size of the data block read from source images, when reading vertical direction sequence number is the data block of 1, according to formula
y_cnt=[(src_vsize-1)×M×k_vsize÷(des_vsize-1)]
-[(src_vsize-1)×(M-1)×k_vsize÷(des_vsize-1)]+1(M=1)
And t_vsize=y_cnt+1 (M=1) determines the vertical dimension of the data block read from source images, wherein, bracket [] represents floor operation, src_hsize and src_vsize is respectively horizontal size and the vertical dimension of source images, N and M is respectively horizontal direction sequence number and the vertical direction sequence number of the data block of reading, the horizontal size of k_hsize and k_vsize each data block after being respectively interpolation and vertical dimension, des_hsize and des_vsize is respectively horizontal size and the vertical dimension of image after interpolation.
Second starting point coordinate determination module 333 of data block, for when read level direction sequence number is not 1 and vertical direction sequence number is not the data block of 1, the starting point coordinate according to following formula determination data block:
x_cnt=[(src_hsize-1)×N×k_hsize÷(des_hsize-1)]
-[(src_hsize-1)×(N-1)×k_hsize÷(des_hsize-1)]+1(N=1)
x_cnt=[(src_hsize-1)×N×k_hsize÷(des_hsize-1)]
-[(src_hsize-1)×(N-1)×k_hsize÷(des_hsize-1)](N≥2)
y_cnt=[(src_vsize-1)×M×k_vsize÷(des_vsize-1)]
-[(src_vsize-1)×(M-1)×k_vsize÷(des_vsize-1)]+1(M=1)
y_cnt=[(src_vsize-1)×M×k_vsize÷(des_vsize-1)]
-[(src_vsize-1)×(M-1)×k_vsize÷(des_vsize-1)](M≥2)
Wherein, bracket [] represents floor operation, src_hsize and src_vsize is respectively horizontal size and the vertical dimension of source images, N and M is respectively horizontal direction sequence number and the vertical direction sequence number of the data block of reading, the horizontal size of k_hsize and k_vsize each data block after being respectively interpolation and vertical dimension, des_hsize and des_vsize is respectively horizontal size and the vertical dimension of image after interpolation, x_cnt
ifor x_cnt value when horizontal direction sequence number is i, y_cnt
ifor y_cnt value when vertical direction sequence number is i, src_x_position and src_y_position represents starting point abscissa and the starting point ordinate of the data block read from source images respectively.
Second size determination module 334 of data block, for when read level direction sequence number is not 1 and vertical direction sequence number is not the data block of 1, horizontal size and vertical dimension according to following formula determination data block:
x_cnt=[(src_hsize-1)×N×k_hsize÷(des_hsize-1)]
-[(src_hsize-1)×(N-1)×k_hsize÷(des_hsize-1)](N≥2)
y_cnt=[(src_vsize-1)×M×k_vsize÷(des_vsize-1)]
-[(src_vsize-1)×(M-1)×k_vsize÷(des_vsize-1)](M≥2)
T_hsize=x_cnt+2 (N >=2) and t_vsize=y_cnt+2 (M >=2), wherein, bracket [] represents floor operation, src_hsize and src_vsize is respectively horizontal size and the vertical dimension of source images, N and M is respectively horizontal direction sequence number and the vertical direction sequence number of the data block of reading, the horizontal size of k_hsize and k_vsize each data block after being respectively interpolation and vertical dimension, des_hsize and des_vsize is respectively horizontal size and the vertical dimension of image after interpolation.
Interpolation process unit 34, for carrying out interpolation processing to the data block read.
In the present embodiment, when performing interpolation processing to each block data of source images, be all by left side block interpolation at the end of Horizontal interpolation coefficient, initial interpolation coefficient when starting as right side block Horizontal interpolation, and the vertical interpolation coefficient at the end of upper block interpolation, initial interpolation coefficient when then starting as lower block vertical interpolation, like this, the image obtained after effectively ensureing piecemeal interpolation is still continuous print, there is no the vestige of zone of fracture, the basis ensureing interpolation speed also maintains the good experience of user.
Coding processing unit 35, carries out coded treatment for the data block after terminating interpolation processing.
In second embodiment of the invention, data block determining unit 33 determines the data block that need read from source images according to the parameters that parameter determination unit 31 and data block sequence number determining unit 32 are determined, and independently interpolation processing is carried out to each data block read, after a data block interpolation processing terminates, directly coded treatment is carried out to this data block, therefore effectively can also reduce the times to be encoded such as view data and the memory space after preserving convergent-divergent shared by image on the basis ensureing user's good experience.
embodiment three:
Multiple data block is divided into a width source images carries out interpolation and coded treatment to be illustrated more clearly in, be described with an embody rule example below.
Suppose that source images size is 640 × 480, specify this source images to be amplified to 1280 × 960 after interpolation processing, suppose that encoder processes the data block of 18 × 8 size at every turn, then the size of a data block after interpolation processing of assigned source image is 8 × 8.Data due to a pixel need 1 byte space to preserve, and therefore after buffer memory interpolation, the unit of 8 × 8 data blocks only needs 64 bytes of storage space.According to the formula of embodiment one or embodiment two, work as N=1, during M=1, be (0 from the starting point coordinate of source images read block, 0), after determining the starting point coordinate of read block, the value of intermediate variable is determined according to formula x_cnt=[(640-1) × 1 × 8 ÷ (1280-1)]-[(640-1) × (1-1) × 8 ÷ (1280-1)]+1=4, and the horizontal size t_hsize=4+1=5 obtained from source images read block, in like manner, according to the respective formula of embodiment one or embodiment two, obtain t_vsize=4+1=5, namely from coordinate be (0, 0) start, reading source images size is the data block of 5 × 5.Read the data of source images from left to right, namely N=2 is worked as, during M=1, N=2 is read from source images, the starting point abscissa of the data block that M=1 is corresponding is 4-1=3, starting point ordinate is 0, namely N=2 is worked as, during M=1, first data reading this data block are coordinate (3, 0) corresponding data, the intermediate variable of this data block is calculated again according to formula x_cnt=[(640-1) × 2 × 8 ÷ (1280-1)] below-[(640-1) × (1-1) × 8 ÷ (1280-1)]=4, then from the horizontal size t_hsize=4+2=6 of source images read block, corresponding t_vsize=5.According to the method described above, from left to right, read the data block of source images from top to bottom, known through calculating, the maximum of t_hsize and t_vsize is all 6, then source data buffer unit only needs the memory space of 36 bytes to store source block.The times to be encoded such as each data block only have original (8 × 8) ÷ (1280 × 960) doubly, be about 5/100000ths, after storing interpolation, picture requisite space also only has original (8 × 8) ÷ (1280 × 960) doubly, is about 5/100000ths.
One width source images is divided into multiple data block by the present invention, and carries out interpolation processing to the plurality of data block respectively and the data block after terminating interpolation processing carries out corresponding coded treatment.Owing to not needing just to encode after an image scaling terminates, and do not need to preserve the entire image that convergent-divergent terminates acquisition, therefore, it is possible to effectively reduce the times to be encoded such as view data and the memory space after preserving convergent-divergent shared by image yet.In addition, occur simultaneously because the data of adjacent two data blocks in multiple data blocks that source images is divided into exist some, and the data block on right side carries out using the data block on the left of it the initial interpolation coefficient of Horizontal interpolation coefficient as its Horizontal interpolation that Horizontal interpolation terminates rear acquisition, bottom data block carries out using its top data block the initial interpolation coefficient of vertical interpolation coefficient as its vertical interpolation that vertical interpolation terminates rear acquisition, therefore the image obtained after effectively ensureing piecemeal interpolation is still continuous print, there is no the vestige of zone of fracture, the basis ensureing interpolation speed also maintains the good experience of user.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any amendments done within the spirit and principles in the present invention, equivalent replacement and improvement etc., all should be included within protection scope of the present invention.