目录
rgb文件三通道分量的熵计算的编程实现
元音的时域频域波形分析基于Audacity
rgb文件三通道分量的熵计算的编程实现
该实验使用c++语言实现,所使用测试文件test.rgb分辨率为256*256。
# include# include using namespace std; #define MAX 256 #define SIZE 256*256 int main() { unsigned char* buffer = new unsigned char[SIZE * 3]; FILE* fp = fopen("/Users/lby/Desktop/数据压缩/test1/test.rgb", "rb"); fread(buffer, 1, SIZE * 3, fp); double hr = 0; double hg = 0; double hb = 0; unsigned char* rbuf = new unsigned char[SIZE]; unsigned char* gbuf = new unsigned char[SIZE]; unsigned char* bbuf = new unsigned char[SIZE]; double rcount[MAX] = {0 } ; double gcount[MAX] = {0 } ; double bcount[MAX] = {0 } ; for (int i = 0; i < SIZE; i++) { //bgr排列 bbuf[i] = buffer[i * 3]; gbuf[i] = buffer[i * 3 + 1]; rbuf[i] = buffer[i * 3 + 2]; } for(int i = 0; i < SIZE ; i++) { //灰度级出现次数 rcount[rbuf[i]]++; gcount[gbuf[i]]++; bcount[bbuf[i]]++; } for(int i = 0 ; i < MAX ; i++) { //灰度级出现概率 rcount[i] = rcount[i] / (SIZE) ; gcount[i] = gcount[i] / (SIZE); bcount[i] = bcount[i] / (SIZE); } for (int i = 0; i < 256 ; i++) { //各通道熵 if(rcount[i] != 0) hr = hr - rcount[i] * log(rcount[i]) / log(2.0); if(gcount[i] != 0) hg = hg - gcount[i] * log(gcount[i]) / log(2.0); if(bcount[i] != 0) hb = hb - bcount[i] * log(bcount[i]) / log(2.0); } fclose(fp); cout << "r熵=" << hr << endl; cout << "g熵=" << hg << endl; cout << "b熵=" << hb << endl; return 0; }
并运行得到以下结果
元音的时域频域波形分析基于Audacity
选取了三个原因u,i,e进行录制,并利用Audacity从时域及频域角度进行分析
u
i
e
总结
虽然通过分析,三个元音的时域波形和频谱并不完全相同,但可以发现有共同的特点:
- 时域波形具有一定的周期性频域上峰值基本出现在低频区域


![[数据压缩] rgb文件三通道分量的熵计算及元音的时域频域波形分析 [数据压缩] rgb文件三通道分量的熵计算及元音的时域频域波形分析](http://www.mshxw.com/aiimages/31/767591.png)
