-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (34 loc) · 1.49 KB
/
main.cpp
File metadata and controls
36 lines (34 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include "files.h"
using namespace std;
int main()
{
setlocale(LC_ALL, "RUS");
BMP file( (char *)"D:\\Git\\INF\\src8.bmp" );
ofstream out("D:\\Git\\INF\\output.txt");
file.writeInfo();
file.writeMatrix();
file.writeFrequency();
cout << "\nEntropy: " << file.getEntropy() << endl;
file.writeCodesOfMessage(HUFFMAN);
file.writeCodesOfMessage(UNIFORM);
file.writeCodesOfMessage(SHANNON);
file.writeCodesOfSymbols(HUFFMAN);
file.writeCodesOfSymbols(UNIFORM);
file.writeCodesOfSymbols(SHANNON);
cout << "Size Uniform Codes: " << file.byteSizeCode(UNIFORM)<< endl;
cout << "Size Code Shannon: " << file.byteSizeCode(SHANNON)<< endl;
cout << "Size Code Huffman: " << file.byteSizeCode(HUFFMAN)<< endl << endl;
cout << "Compression ratio Shannon's code: " << file.byteSizeCode(UNIFORM) / file.byteSizeCode(SHANNON) << endl;
cout << "Compression ratio Huffman's code: " << file.byteSizeCode(UNIFORM) / file.byteSizeCode(HUFFMAN) << endl;
long double shannonSize, huffmanSize, uniformSize;
uniformSize = file.sizeCode(UNIFORM);
shannonSize = file.sizeCode(SHANNON);
huffmanSize = file.sizeCode(HUFFMAN);
cout << uniformSize << ' ' << shannonSize << ' ' << huffmanSize << '\n';
cout << "Redundancy Shannon's code: " << (uniformSize-shannonSize)/shannonSize << endl;
cout << "Redundancy Huffman's code: " << (uniformSize-huffmanSize)/huffmanSize << endl;
out.close();
//system("pause>>null");
return 0;
}