ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

【信源编码技术】实验3-均匀/矢量量化

2021-11-18 20:03:21  阅读:161  来源: 互联网

标签:编码 sena img .. sena22 矢量 信源 cb images


实验准备

被压缩图像

按光栅扫描顺序存储的256*256像素8位灰度图sena.img

sena.img

程序

均匀量化编码器uqimg_enc

使用方法:uqimg_enc [ -i infile ][ -o outfile ][ -l numlev ][ -b numbits ][ -m max_value ][ -t min_value ][ -x row_size ][ -y col_size ]

-i infile:The name of the file containing the input image. The image is assumed to be stored using 8 bits/pixel in raw format.

-o outfile:This will contain the compressed image. The various parameters required for decompression are also stored in the same file. If this option is not used the program writes the decorrelated image to standard out. This is useful if the output of the program is to be piped directly to a variable length coder.

-l numlev:This is the size of the quantizer reproduction alpha bet. If this value is provided numbits need not be specified. The number of bits needed to represent the lables, numbits, need not be specified. numbits is computed as [log_2 numlev] ([x] is the smallest integer greater than or equal to x).

-b numbits:This is the number of bits needed to specify a quantizer label. If this value is specified, the number of levels, numlev, need not be specified. numlev is computed as numlev = 2^numbits.

-m max_value:This is the maximum value that the input can take. This value along with min_value is used to compute the quantizer step size. The default max_value is 255.

-t min_value:This is the minimum value that the input can take. This value along with max_value is used to compute the quantizer step size. The default min_value is 0.

-x row_size:This is the number of pixels in each row of the image.

-y col_size:This is the number of rows of pixels. If the row_size and col_size are not provided the program attempts to check to see if the image corresponds to any of the standard sizes it is familiar with. To add to the list of standard sizes, edit image_size.c

均匀量化解码器uqimg_dec

使用方法:uqimg_dec [ -i infile ][ -o outfile ]

-i infile:This contains the compressed image. The various parameters required for decompression are also stored in the same file. If this option is not used the program reads from standard in. This is useful if the input to the program is to be generated by a variable length decoder.

-o outfile:The name of the file containing the reconstructed image. The image is stored using 8 bits/pixel in raw format. If this option is not used the image is written to standard out.

LBG算法程序trvqsp_img

使用方法:trvqsp_img ts_img codefile [ -b cb_size ][ -t block_height ][ -w block_width ]

-b cb_size:This is the size of the codebook.

-t block_height:This is the height of a block of pixels making up a vector.

-w block_width:This is the width of the block of pixels making up a vector. The dimension of the vector is block_height × block_width.

矢量量化编码器vqimg_enc

使用方法:vqimg_enc [ -i imagein ][ -o cmpfile ][ -c codebook ][ -x row_size ][ -y col_size ]

-i imagein:This is the image to be compressed. It is assumed that this image is a grey scale (8 bits/pixel) image stored in raster scan order.

-o cmpfile:This is the compressed file. The file also contains the name of the codebook used during vector quantization.

-c codebook:This is the codebook used for compression. The codebook can be generated using trvqsp_img.

-x row_size:This is the number of pixels in each row.

-y col_size:This is the number of rows in the image.

矢量量化解码器vqimg_dec

使用方法:vqimg_dec [ -i cmpfile ][ -o imageout ]

-i cmpfile:This is the compressed file. The file also contains the name of the codebook used during vector quantization.

-o imageout:This is the reconstructed image. It is assumed that this image is a grey scale (8 bits/pixel) image and is stored in raster scan order.

实验过程与结果

对sena.img进行均匀量化

均匀量化编码

uqimg_enc项目属性→调试→命令参数:

-i ../images/sena.img -o ../images/quantized_img/sena_1bit.quan -b 1

-i ../images/sena.img -o ../images/quantized_img/sena_2bit.quan -b 2

-i ../images/sena.img -o ../images/quantized_img/sena_4bit.quan -b 4

-i ../images/sena.img -o ../images/quantized_img/sena_6bit.quan -b 6

分别得到输入文件sena.img的量化比特数分别为1、2、4、6的量化索引文件sena_1bit.quan、sena_2bit.quan、sena_4bit.quan、sena_6bit.quan

均匀量化解码

uqimg_dec项目属性→调试→命令参数:

-i ../images/quantized_img/sena_1bit.quan -o ../images/reconstructed_img/sena_1bit_re.img

-i ../images/quantized_img/sena_2bit.quan -o ../images/reconstructed_img/sena_2bit_re.img

-i ../images/quantized_img/sena_4bit.quan -o ../images/reconstructed_img/sena_4bit_re.img

-i ../images/quantized_img/sena_6bit.quan -o ../images/reconstructed_img/sena_6bit_re.img

分别得到输入量化索引文件sena_1bit.quan、sena_2bit.quan、sena_4bit.quan、sena_6bit.quan的输出重建文件sena_1bit_re.img、sena_2bit_re.img、sena_4bit_re.img、sena_6bit_re.img

均匀量化结果

量化比特数原始大小量化后大小压缩率PSNR
164.0KB8.02KB12.5%18.6
264.0KB16.0KB25.0%21.5
464.0KB32.0KB50.0%35.0
664.0KB48.0KB75.0%46.5

对sena.img进行矢量量化

LBG算法

trvqsp_img项目属性→调试→命令参数:

../images/sena.img ../images/codebooks/sena22_16.cb -b 16 -w 2 -t 2

../images/sena.img ../images/codebooks/sena22_32.cb -b 32 -w 2 -t 2

../images/sena.img ../images/codebooks/sena22_64.cb -b 64 -w 2 -t 2

../images/sena.img ../images/codebooks/sena22_128.cb -b 128 -w 2 -t 2

../images/sena.img ../images/codebooks/sena22_256.cb -b 256 -w 2 -t 2

分别得到输入文件sena.img的将宽2高2的像素块合并为矢量经LBG算法划分为16、32、64、128、256个区域(码书大小、码矢数量)的码书文件sena22_16.cb、sena22_32.cb、sena22_64.cb、sena22_128.cb、sena22_256.cb

矢量量化编码

vqimg_enc项目属性→调试→命令参数:

-i ../images/sena.img -o ../images/quantized_img/sena22_16.vquan -c ../images/codebooks/sena22_16.cb

-i ../images/sena.img -o ../images/quantized_img/sena22_32.vquan -c ../images/codebooks/sena22_32.cb

-i ../images/sena.img -o ../images/quantized_img/sena22_64.vquan -c ../images/codebooks/sena22_64.cb

-i ../images/sena.img -o ../images/quantized_img/sena22_128.vquan -c ../images/codebooks/sena22_128.cb

-i ../images/sena.img -o ../images/quantized_img/sena22_256.vquan -c ../images/codebooks/sena22_256.cb

分别得到输入文件sena.img分别经码书sena22_16.cb、sena22_32.cb、sena22_64.cb、sena22_128.cb、sena22_256.cb进行编码得到的量化索引文件sena22_16.vquan、sena22_32.vquan、sena22_64.vquan、sena22_128.vquan、sena22_256.vquan

矢量量化解码

vqimg_dec项目属性→调试→命令参数:

-i ../images/quantized_img/sena22_16.vquan -o ../images/reconstructed_img/sena22_16_re.img

-i ../images/quantized_img/sena22_32.vquan -o ../images/reconstructed_img/sena22_32_re.img

-i ../images/quantized_img/sena22_64.vquan -o ../images/reconstructed_img/sena22_64_re.img

-i ../images/quantized_img/sena22_128.vquan -o ../images/reconstructed_img/sena22_128_re.img

-i ../images/quantized_img/sena22_256.vquan -o ../images/reconstructed_img/sena22_256_re.img

分别得到输入量化索引文件sena22_16.vquan、sena22_32.vquan、sena22_64.vquan、sena22_128.vquan、sena22_256.vquan的输出重建图像sena22_16_re.img、sena22_32_re.img、sena22_64_re.img、sena22_128_re.img、sena22_256_re.img

矢量量化结果

码矢划分原始大小量化+码书大小压缩率PSNR
1664.0KB8.04KB+76B12.7%32.5
3264.0KB10.0KB+140B15.8%34.8
6464.0KB12.0KB+268B19.2%36.5
12864.0KB14.0KB+524B22.7%38.2
25664.0KB16.0KB+1.01KB26.6%39.8

均匀量化与矢量量化对比

本实验以sena.img为例,由实验结果可见,矢量量化相较于均匀量化的压缩性能更强。

标签:编码,sena,img,..,sena22,矢量,信源,cb,images
来源: https://blog.csdn.net/weixin_45616624/article/details/121399190

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有