资源简介
VectorQuantization 矢量量化数据压缩编码 对Lena图像压缩 平台vs c++编程

代码片段和文件信息
#include
#include
#include
#include
#define Mx 512
#define Nx 512
#define Ax 2
#define Bx 2
using namespace std;
struct Color
{
int R;
int G;
int B;
};
bool bmpRead(vector> &imageVec const char *fileName)
{
ifstream file(fileName ios::in | ios::binary);
if (!file)
return false;
// skip header
const ifstream::off_type headerSize = 54;
file.seekg(headerSize ios::beg);
// read body
for (size_t y = 0; y != imageVec.size(); ++y)
{
for (size_t x = 0; x != imageVec[0].size(); ++x)
{
char chR chG chB;
file.get(chB).get(chG).get(chR);
imageVec[y][x].B = chB;
imageVec[y][x].G = chG;
imageVec[y][x].R = chR;
if (imageVec[y][x].B < 0)
imageVec[y][x].B = 255 + imageVec[y][x].B;
if (imageVec[y][x].G < 0)
imageVec[y][x].G = 255 + imageVec[y][x].G;
if (imageVec[y][x].R < 0)
imageVec[y][x].R = 255 + imageVec[y][x].R;
}
}
file.close();
return true;
}
bool bmpWrite(vector> &imageVec const char *fileName)
{
const int headerSize = 54;
char header[headerSize] = {
0x42 0x4d 0 0 0 0 0 0 0 0
54 0 0 0 40 0 0 0 0 0 0 0 0 0 0 0 1 0 24 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 };
int ysize = imageVec.size();
int xsize = imageVec[0].size();
long file_size = (long)ysize * xsize * 3 + 54;
header[2] = (unsigned char)(file_size & 0x000000ff);
header[3] = (file_size >> 8) & 0x000000ff;
header[4] = (file_size >> 16) & 0x000000ff;
header[5] = (file_size >> 24) & 0x000000ff;
long width = xsize;
header[18] = width & 0x000000ff;
header[19] = (width >> 8) & 0x000000ff;
header[20] = (width >> 16) & 0x000000ff;
header[21] = (width >> 24) & 0x000000ff;
long height = ysize;
header[22] = height & 0x000000ff;
header[23] = (height >> 8) & 0x000000ff;
header[24] = (height >> 16) & 0x000000ff;
header[25] = (height >> 24) & 0x000000ff;
ofstream file(fileName ios::out | ios::binary);
if (!file)
return false;
// write header
file.write(header headerSize);
// write body
for (size_t y = 0; y != imageVec.size(); ++y)
{
for (size_t x = 0; x != imageVec[0].size(); ++x)
{
//char chB = imageVec[y][x].B;
//char chG = imageVec[y][x].G;
//char chR = imageVec[y][x].R;
int chB = (imageVec[y][x].B * 0.114 + imageVec[y][x].G * 0.587 + imageVec[y][x].R * 0.299);
// int chG = (imageVec[y][x].B+imageVec[y][x].G+imageVec[y][x].R)/3;
// int chR = (imageVec[y][x].B+imageVec[y][x].G+imageVec[y][x].R)/3;
file.put(chB).put(chB).put(chB);
//cout << chB <<““< }
}
file.close();
return true;
}
int main()
{
const size_t sizey = 512;
const size_t sizex = 512;
vector> imageVec(sizey vector(sizex));
vector> imageVecNew(sizey vector(sizex));
vector> codebook(65 vector(Ax * Bx));
vector> image((Mx / Ax) * (Nx / Bx) vector(Ax * Bx
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-25 22:13 VectorQuantization-master\
目录 0 2018-11-25 14:25 VectorQuantization-master\.vs\
目录 0 2018-11-25 14:25 VectorQuantization-master\.vs\VQ\
目录 0 2018-11-25 14:25 VectorQuantization-master\.vs\VQ\v14\
文件 23552 2018-03-22 02:46 VectorQuantization-master\.vs\VQ\v14\.suo
目录 0 2018-11-25 14:25 VectorQuantization-master\Debug\
文件 158720 2018-03-22 02:46 VectorQuantization-master\Debug\VQ.exe
文件 1461728 2018-03-22 02:46 VectorQuantization-master\Debug\VQ.ilk
文件 2347008 2018-03-22 02:46 VectorQuantization-master\Debug\VQ.pdb
文件 633 2018-03-22 02:46 VectorQuantization-master\README.md
目录 0 2018-11-25 14:25 VectorQuantization-master\VQ\
目录 0 2018-11-25 14:25 VectorQuantization-master\VQ\Debug\
文件 589338 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\Source.obj
文件 894 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\VQ.log
目录 0 2018-11-25 14:25 VectorQuantization-master\VQ\Debug\VQ.tlog\
文件 618 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\VQ.tlog\CL.command.1.tlog
文件 16140 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\VQ.tlog\CL.read.1.tlog
文件 396 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\VQ.tlog\CL.write.1.tlog
文件 194 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\VQ.tlog\VQ.lastbuildstate
文件 1066 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\VQ.tlog\li
文件 2830 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\VQ.tlog\li
文件 370 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\VQ.tlog\li
文件 379904 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\vc140.idb
文件 462848 2018-03-22 02:46 VectorQuantization-master\VQ\Debug\vc140.pdb
文件 8811 2018-03-22 02:46 VectorQuantization-master\VQ\Source.cpp
文件 7221 2018-03-22 02:46 VectorQuantization-master\VQ\VQ.vcxproj
文件 935 2018-03-22 02:46 VectorQuantization-master\VQ\VQ.vcxproj.filters
文件 8605696 2018-03-22 02:46 VectorQuantization-master\VQ.VC.db
文件 7340032 2018-11-25 19:37 VectorQuantization-master\VQ.sdf
文件 1260 2018-03-22 02:46 VectorQuantization-master\VQ.sln
文件 19968 2018-11-25 19:37 VectorQuantization-master\VQ.v12.suo
............此处省略3个文件信息
- 上一篇:MFC制作画板...
- 下一篇:CTP C#交易接口
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
评论
共有 条评论