图片压缩 DCT变换 实时视频 - 2
2012-05-02 10:36
176 查看
上一篇的源码进行优化,将cosx运算提取出来,变成矩阵形式。
#include "stdafx.h"
#include <string.h>
#include <iostream>
#include <math.h>
using namespace std;
#define PI 3.1415926
int _tmain(int argc, _TCHAR* argv[])
{
double dInput[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
int iFactor[] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
double dOut[10] = {0};
double dOut1[10]= {0};
const int N = sizeof(dInput)/sizeof(double);
double* pdFactor = new double[N*N];
for (int row=0; row<N; row++)
{
for (int col=0; col<N; col++)
{
if (row==0)
pdFactor[row*N+col] = cos((2*col + 1)*PI*row/(2*N)) / sqrt((double)N);
else
pdFactor[row*N+col] = cos((2*col + 1)*PI*row/(2*N)) * sqrt(2.0) / sqrt((double)N);
}
}
for (int i=0; i<N; i++)
{
for (int j=0; j<N; j++)
{
dOut[i]+= dInput[j] * pdFactor[i*N+j];
}
}
printf("\n变换前:\n");
for (int i=0; i<N; i++)
{
printf("%f\t", dInput[i]);
}
printf("\n变换后:\n");
for (int i=0; i<N; i++)
{
printf("%f\t", dOut[i]);
}
//printf("\n去除高频:\n");
//for (int i=0; i<N; i++)
//{
// dOut[i] *= iFactor[i];
// printf("%f\t", dOut[i]);
//}
printf("\n逆变换:\n");
for (int i=0; i<N; i++)
{
for (int j=0; j<N; j++)
{
dOut1[i]+= dOut[j] * pdFactor[j*N+i];
}
}
for (int i=0; i<N; i++)
{
printf("%f\t", dOut1[i]);
}
getchar();
delete[] pdFactor;
} 由此源码发现。
参数因子pdFactor,由编码的逐行积相加,变为解码的逐列的积相加。
#include "stdafx.h"
#include <string.h>
#include <iostream>
#include <math.h>
using namespace std;
#define PI 3.1415926
int _tmain(int argc, _TCHAR* argv[])
{
double dInput[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
int iFactor[] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
double dOut[10] = {0};
double dOut1[10]= {0};
const int N = sizeof(dInput)/sizeof(double);
double* pdFactor = new double[N*N];
for (int row=0; row<N; row++)
{
for (int col=0; col<N; col++)
{
if (row==0)
pdFactor[row*N+col] = cos((2*col + 1)*PI*row/(2*N)) / sqrt((double)N);
else
pdFactor[row*N+col] = cos((2*col + 1)*PI*row/(2*N)) * sqrt(2.0) / sqrt((double)N);
}
}
for (int i=0; i<N; i++)
{
for (int j=0; j<N; j++)
{
dOut[i]+= dInput[j] * pdFactor[i*N+j];
}
}
printf("\n变换前:\n");
for (int i=0; i<N; i++)
{
printf("%f\t", dInput[i]);
}
printf("\n变换后:\n");
for (int i=0; i<N; i++)
{
printf("%f\t", dOut[i]);
}
//printf("\n去除高频:\n");
//for (int i=0; i<N; i++)
//{
// dOut[i] *= iFactor[i];
// printf("%f\t", dOut[i]);
//}
printf("\n逆变换:\n");
for (int i=0; i<N; i++)
{
for (int j=0; j<N; j++)
{
dOut1[i]+= dOut[j] * pdFactor[j*N+i];
}
}
for (int i=0; i<N; i++)
{
printf("%f\t", dOut1[i]);
}
getchar();
delete[] pdFactor;
} 由此源码发现。
参数因子pdFactor,由编码的逐行积相加,变为解码的逐列的积相加。
相关文章推荐
- 图片压缩 DCT变换 实时视频
- 图像拼接(九):双摄像头实时视频拼接(单应变换模型)
- 图像拼接(九):双摄像头实时视频拼接(单应变换模型)
- 利用VC++实现局域网实时视频传输
- python 读取视频,处理后,实时计算帧数fps的方法
- 基于pcDuino的WiFi实时视频监控智能小车——硬件部分(二)
- Android视频实时传输
- 【流媒體】Android 实时视频采集/编码/传输/解码/播放—方案调研(初)
- iOS 简单的视频直播功能开发(实时视音频流录制编码+RTMP传输+实时拉流解码播放)
- DCT 变换的一些思考
- ADSL拨号网络环境下实时视频广播的完美实现
- 【技术支持】ARM9无线遥控视频实时监控小车(一)--------小车的电机控制模块
- 【流媒體】Android 实时视频采集—MediaRecoder录制
- 采集音频和摄像头视频并实时H264编码及AAC编码
- android视频录制、另一部手机实时观看方案
- 视频流中实时人脸检测
- Android 实时视频采集—Cameara预览采集
- android视频录制、另一部手机实时观看方案
- [转]Android开发:实时处理摄像头预览帧视频------浅析PreviewCallback,onPreviewFrame,AsyncTask的综合应用
- opencv 2.4.6 摄像头实时保存视频