一、基于audacity软件的元音分析
自行录制 a、e、i三个元音,并利用audacity软件分析三个元音的时域波形和频域波形,总结其特点。
1.时域和频域波形
e波形
i波形a波形
2.分析
1.时域波形:
元音音频一般具有短时周期性,同时波形具有周期性,短时过零率较低。
2.频域波形:
存在多个共振峰,能量主要集中在较低频的范围内,由低频向高频衰减。
二、RGB文件熵的计算
代码如下:
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
FILE* f;
f = fopen("E:\\数据压缩\\第一次作业\\test.rgb", "rb");
unsigned char* rgb, * B_buffer, * G_buffer, * R_buffer;
rgb = (unsigned char*)malloc(256 * 256 * 3 * sizeof(unsigned char));
B_buffer = (unsigned char*)malloc(256 * 256 * sizeof(unsigned char));
G_buffer = (unsigned char*)malloc(256 * 256 * sizeof(unsigned char));
R_buffer = (unsigned char*)malloc(256 * 256 * sizeof(unsigned char));
double B_count[256] = { 0 };
double G_count[256] = { 0 };
double R_count[256] = { 0 };
double B_H[256] = { 0 };
double G_H[256] = { 0 };
double R_H[256] = { 0 };
double BH = 0;
double GH = 0;
double RH = 0;
fread(rgb, 1, 256 * 256 * 3, f);
for (int h = 0; h < 256; h++)
{
int i = 0;
for (int w = 0; w < 256 * 3; w = w + 3)
{
*(B_buffer + h * 256 + i) = *(rgb + h * 256 * 3 + w);
*(G_buffer + h * 256 + i) = *(rgb + h * 256 * 3 + w + 1);
*(R_buffer + h * 256 + i) = *(rgb + h * 256 * 3 + w + 2);
i++;
}
}
for (int g = 0; g < 256; g++)
{
for (int j = 0; j < 256 * 256; j++)
{
if (*(B_buffer + j) == g)
{
B_count[g] ++;
}
if (*(G_buffer + j) == g)
{
G_count[g] ++;
}
if (*(R_buffer + j) == g)
{
R_count[g] ++;
}
}
}
for (int t = 0; t < 256; t++)
{
B_count[t] = B_count[t] / (256 * 256);
G_count[t] = G_count[t] / (256 * 256);
R_count[t] = R_count[t] / (256 * 256);
}
for (int n = 0; n < 256; n++)
{
if (*(B_count + n) != 0)
{
B_H[n] = -B_count[n] * (log(B_count[n]) / log(2.0));
}
if (*(G_count + n) != 0)
{
G_H[n] = -G_count[n] * (log(G_count[n]) / log(2.0));
}
if (*(R_count + n) != 0)
{
R_H[n] = -R_count[n] * (log(R_count[n]) / log(2.0));
}
}
for (int sum = 0; sum < 256; sum++)
{
BH += B_H[sum];
GH += G_H[sum];
RH += R_H[sum];
}
cout << "B的熵为" << BH << endl;
cout << "G的熵为" << GH << endl;
cout << "R的熵为" << RH << endl;
}