Summary of the invention
The invention provides a kind of image processing method and system, in order to solve complicated, the slow problem of the special effect treatment process that has image in the prior art.
The invention provides following technical scheme:
A kind of image processing method may further comprise the steps:
View data is decoded, and directly from decoded data, obtain the related coefficient of target image;
According to the type of effect of target image the value of described related coefficient is set, makes target image have the special-effect of expection;
Directly the related coefficient after being provided with is encoded.
Described relevant coefficient comprises coefficient relevant with brightness and the coefficient relevant with colourity.
Described relevant coefficient comprises DC coefficient and ac coefficient.
Described decoding is meant the entropy decoding; Described coding is meant entropy coding.
The described related coefficient of part is 0.
The type of described Flame Image Process comprise that black and white effect process, mosaic effect are handled, film result is handled and the effect process of missing old times or old friends in one or more.
A kind of image processing method may further comprise the steps:
View data is decoded and inverse quantization, and obtain the related coefficient of target image the direct data behind inverse quantization;
According to the type of effect of target image the value of described related coefficient is set, makes target image have the special-effect of expection;
Directly the related coefficient after being provided with is quantized and encode.
Described decoding is meant the entropy decoding; Described coding is meant entropy coding.
The described related coefficient of part is 0.
The type of described Flame Image Process comprise that black and white effect process, mosaic effect are handled, film result is handled and the effect process of missing old times or old friends in one or more.
A kind of image processing system comprises:
Decoding device is used for view data is decoded and inverse quantization, and obtains the related coefficient of target image the direct data behind inverse quantization;
Treating apparatus is used for being provided with according to the type of effect of target image the value of described related coefficient, makes target image have the special-effect of expection;
Code device is used for directly the related coefficient after being provided with being quantized and encoding.
Described decoding device comprises:
The compression coding module is used for view data is decoded;
Inverse quantization module is used for the coefficient that obtains after the decoding is carried out inverse quantization, and obtains the related coefficient of target image the direct data behind inverse quantization.
Described code device comprises:
Quantization modules is used for directly the related coefficient after being provided with being quantized;
The compressed encoding module is used for the coefficient after quantizing is encoded.
A kind of image processing system comprises:
Decoding device is used for view data is decoded, and directly obtains the related coefficient of target image from decoded data;
Treating apparatus is used for being provided with according to the type of effect of target image the value of described related coefficient, makes target image have the special-effect of expection;
Code device is used for directly the related coefficient after being provided with being encoded.
Beneficial effect of the present invention is as follows:
1, the present invention decodes and inverse quantization to image compression data, carries out special effect processing then, has omitted inverse transformation and conversion process the most complicated in the processing procedure, makes that whole special effect processing process is simplified significantly.
2, the present invention also provides a kind of scheme, just it is carried out special effect processing after image compression data is decoded, and directly the coefficient after the special effect processing is encoded then, has further simplified treatment scheme.
3, the present invention is applicable to multiple image or picture compression standard.
Also comparatively simple when 4, using system of the present invention realization.
Embodiment
In order to solve complicated, the slow problem of the special effect treatment process that has image in the prior art, the present invention does not carry out IDCT and DCT process, before the IDCT process related data is carried out special effect treatment.
Present embodiment is that example describes with JPEG, and other Standard of image compression is identical with the processing procedure of JPEG.
The first step of JPEG compression algorithm is exactly the piece (block) that the yuv data of entire image is divided into 8X8 respectively, and each block is done dct transform.Obtain the coefficient of the 8X8 on the frequency field respectively.Therefore, the final step of decompression algorithm is exactly the IDCT computing of being each block.Present embodiment was exactly before doing the IDCT computing, and the coefficient on the frequency field of the 8X8 of each block is processed, and obtained some special-effects.
Present embodiment provides two kinds of schemes, and scheme one is that view data is carried out entropy decoding, inverse quantization, special effect processing, quantification and entropy coding; Scheme two is that view data is carried out entropy decoding, special effect processing and entropy coding.
Scheme one
Referring to Fig. 2, realize in the present embodiment that the system that image special effect is handled comprises decoding device 201, treating apparatus 202 and code device 203.
Decoding device 201 is at first decoded to compressing image data, adopts the entropy decoding in the present embodiment, particularly Huffman (huffman) decoding in the entropy decoding; Then, the image coefficient that obtains after the decoding is carried out inverse quantization, obtain the IDCT coefficient.
The part or all of IDCT coefficient for the treatment of apparatus 202 special efficacy type change as required makes the IDCT coefficient after the change carry special efficacy information.
IDCT coefficient after 203 pairs of changes of code device quantizes, and filters out high fdrequency component, makes things convenient for subsequent compression, then the coefficient after quantizing is encoded, and adopts the huffman coding in the entropy coding, particularly entropy coding in the present embodiment.
Referring to Fig. 3, decoding device 201 comprises compression coding module 301 and inverse quantization module in the present embodiment
302。
301 pairs of compressing image datas of compression coding module are decoded, and obtain image coefficient, adopt the entropy decoding in the present embodiment, particularly the Hofmann decoding in the entropy decoding.
The image coefficient that obtains after 302 pairs of decodings of inverse quantization module is carried out inverse quantization, obtains the IDCT coefficient.
Referring to Fig. 4, code device 203 comprises quantization modules 401 and compressed encoding module 402 in the present embodiment.
IDCT coefficient after 401 pairs of changes of quantization modules quantizes, and filters out high fdrequency component, makes things convenient for subsequent compression.
Coefficient after 402 pairs of quantifications of compressed encoding module carries out compressed encoding, adopts the huffman coding in the entropy coding, particularly entropy coding in the present embodiment.
Referring to Fig. 5, the idiographic flow of image special effect disposal route is as follows in the present embodiment:
Step 501: there are not the data that can directly use in the image compression data, thus must carry out the entropy decoding to it, and recover the block of 8X8, obtain the coefficient relevant with YUV.This entropy decoding comprises Hofmann decoding, (because use is huffman coding when compression.) and in the Hofmann decoding process with reference to huffman coding table.
Step 502: according to quantization table or by quantitative formula all coefficients are carried out inverse quantization, promptly do multiplication, recover the raw image data on the frequency domain as far as possible.
Work as u, during v=0, the coefficient F (0,0) behind the DCT is called direct current (DC) coefficient; Work as u, v ≠ 0 o'clock, (u v) is called interchange (AC) coefficient to the coefficient F behind the DCT.For example:
Y_freg: the expression luminance Y component is finished the coefficient after the DCT.
U_freg: expression colourity U component is finished the coefficient after the DCT.
V_freg: expression colourity V component is finished the coefficient after the DCT.
Y_DC_freg: the expression luminance Y component is finished the DC coefficient after the DCT.
Y_AC_freg: the expression luminance Y component is finished the AC coefficient after the DCT.
U_DC_freg: expression colourity U component is finished the DC coefficient after the DCT.
U_AC_freg: expression colourity U component is finished the AC coefficient after the DCT.
V_DC_freg: expression colourity V component is finished the DC coefficient after the DCT.
V_AC_freg: expression colourity V component is finished the AC coefficient after the DCT.
Step 503: according to the special efficacy type, relevant YUV coefficient is set to corresponding particular value, can receive the image of special-effect after decompressing afterwards, and the special efficacy type comprises black and white special efficacy, mosaic special efficacy, egative film special efficacy and the special efficacy etc. of missing old times or old friends.
One, the black and white special efficacy for example.
Method: as long as the U_freg and the V_freg component that have color information all are changed to 0.That is: Y_freg=Y_freg, U_freg=0, V_freg=0.
Two, mosaic effect for example.
Method: as long as all DC coefficients of brightness and colourity are kept, all AC coefficients all are changed to 0 and get final product.That is: Y_DC_freg=Y_DC_freg, Y_AC_freg=0, U_DC_freg=U_DC_freg, U_AC_freg=0, V_DC_freg=V_DC_freg, V_AC_freg=0.
Three, the egative film special efficacy for example.
Method: as long as Y_freg, U_freg and three whole negates of component of V_freg, positive becoming is negative, and that bears becomes positive getting final product.That is: Y_freg=-Y_freg, U_freg=-U_freg, V_freg=-V_freg.
Four, miss old times or old friends special efficacy for example.
Method: as long as have the U_freg of color information and the DC coefficient of V_freg component is set to suitable value, turning to be yellow for the effect that makes image, is 4 o'clock at quantization parameter, and the DC coefficient is made as-152 and 160 respectively, and the AC coefficient is set to 0, and Y_freg is constant.That is: Y_freg=Y_freg, U_DC_freg=-152, U_AC_freg=0, V_DC_freg=160, V_AC_freg=0.
The special efficacy of missing old times or old friends is meant, makes picture seem to send out old, and therefore, color does not fix-152 and 160, also can get other value according to the needs and the quantization parameter of effect, makes image seem whole relatively certain color.
Owing to,,, continue following steps so after view data is carried out special effect processing, need it is compressed how with the compressed format memory image file at present in order to save storage space:
Step 504: according to quantization table or by quantitative formula all coefficients are quantized, with the value of each coefficient divided by correspondence in the quantization table.Because the value in the upper left corner is less in the quantization table, the value in the lower right corner is bigger, has so just played the maintenance low frequency component, suppresses the purpose of high fdrequency component, filters out the high fdrequency component that the information of carrying is less and information is not too important, is convenient to follow-up compression and handles.
Step 505: the coefficient after quantizing is carried out entropy coding, carry out data compression.
Said method is behind inverse quantization relevant data to be carried out special effect processing, quantizes and compressed encoding again.Introduce a kind of more simple effect processing method below.
Scheme two
Respectively installing that the system that the realization image special effect is handled in the present embodiment comprises is as follows:
201 pairs of compressing image datas of decoding device are decoded and are obtained the target image coefficient.
The part or all of target image coefficient for the treatment of apparatus 202 special efficacy type change as required.
Target image coefficient after 203 pairs of changes of code device is encoded.
Decoding device 201 does not comprise inverse quantization module 302 in this programme, and respective coding device 203 does not comprise quantization modules 401.
As seen the special effect processing process is simplified significantly.
Referring to Fig. 6, the idiographic flow of another kind of image special effect disposal route is as follows in the present embodiment:
Step 601: image compression data is carried out the entropy decoding, owing to the data that do not have in the image compression data directly to use, thus must carry out Hofmann decoding to it according to huffman coding table, and recover the block of 8X8, obtain the coefficient relevant with YUV.
Step 602: according to the special efficacy type, relevant YUV coefficient is set to corresponding particular value, and the special efficacy type comprises black and white special efficacy, mosaic special efficacy, egative film special efficacy and the special efficacy etc. of missing old times or old friends.
If:
Y_freg: the expression luminance Y component is finished DCT and is quantized coefficient afterwards.
U_freg: expression colourity U component is finished DCT and is quantized coefficient afterwards.
V_freg: expression colourity V component is finished DCT and is quantized coefficient afterwards.
Y_DC_freg: the expression luminance Y component is finished DCT and is quantized DC coefficient afterwards.
Y_AC_freg: the expression luminance Y component is finished DCT and is quantized AC coefficient afterwards.
U_DC_freg: expression colourity U component is finished DCT and is quantized DC coefficient afterwards.
U_AC_freg: expression colourity U component is finished DCT and is quantized AC coefficient afterwards.
V_DC_freg: expression colourity V component is finished DCT and is quantized DC coefficient afterwards.
V_AC_freg: expression colourity V component is finished DCT and is quantized AC coefficient afterwards.
One, the black and white special efficacy is given an example, referring to black white image shown in Figure 7.
Method: as long as the U_freg and the V_freg component that have color information all are changed to 0.That is: Y_freg=Y_freg, U_freg=0, V_freg=0.
Two, mosaic effect is given an example, referring to mosaic image shown in Figure 8.
Method: as long as all DC coefficients of brightness and colourity are kept, all AC coefficients all are changed to 0 and get final product.That is: Y_DC_freg=Y_DC_freg, Y_AC_freg=0, U_DC_freg=U_DC_freg, U_AC_freg=0, V_DC_freg=V_DC_freg, V_AC_freg=0.
Three, the egative film special efficacy is given an example, referring to negative map picture shown in Figure 9.
Method: as long as Y_freg, U_freg and three whole negates of component of V_freg, positive becoming is negative, and that bears becomes positive getting final product.That is: Y_freg=-Y_freg, U_freg=-U_freg, V_freg=-V_freg.
Four, miss old times or old friends special efficacy for example, referring to the image of missing old times or old friends shown in Figure 10.
Method: as long as have the U_freg of color information and the DC coefficient of V_freg component is set to suitable value, turn to be yellow for the effect that makes image, the DC coefficient is made as-38 and 40 respectively, the AC coefficient is set to 0, and Y_freg is constant.That is: Y_freg=Y_freg, U_DC_freg=-38, U_AC_freg=0, V_DC_freg=40, V_AC_freg=0.
Make picture seem to send out old owing to miss old times or old friends, therefore, color does not fix-38 and 40, can get other value as required yet, makes image seem whole relatively certain color.
Because present embodiment is just view data to be carried out special effect processing in entropy decoding back, and inverse quantization and IDCT process do not take place, thus in compression process, do not need to carry out DCT and quantizing process yet, so step below directly carrying out:
Step 603: all coefficients are carried out entropy coding, particularly carry out huffman coding, realize data compression.
Because quantification and inverse quantization, DCT and IDCT are two reversible processes, and what obtain at last usually after compressed image is carried out special effect processing also is compressed image, so above-mentioned two reversible processes can be omitted.And the original compression view data cannot directly be carried out special effect processing, is necessary so press entropy decoding and entropy coding process.
The present invention decodes and inverse quantization to image compression data, carries out special effect processing then, has omitted the most complicated inverse transformation and the conversion process of processing procedure, makes that whole special effect processing process is simplified significantly.The present invention also provides a kind of scheme, just it is carried out special effect processing after image compression data is decoded, and then the coefficient after the special effect processing is encoded, and has further simplified treatment scheme.In addition, the present invention is applicable to multiple image or picture compression standard.Also comparatively simple when using system of the present invention realization.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.