.RAW的Smooth

  1. .RAW的Smooth

.RAW的Smooth

原文連結: https://darkblack01.blogspot.com/2011/05/blog-post_28.html
移植時的最後更新日期: 2015-12-23T14:16:57.720+08:00

#include <iostream>
#include <fstream>

using namespace std;

#define frameH 1920
#define frameV 1080

int main()

{
unsigned char *fp = new unsigned char [frameH*frameV];

fstream file;
file.open("W:\a.raw", fstream::in | fstream::binary);
if( !file.good())
cout << "file讀檔失敗" << endl;

file.read((char*) fp, frameH*frameV); //轉態unsigned char* 轉態成 char* 放入函式
file.close();

int *ifp = new int [frameH*frameV];

for(int i = 0 ; i < frameH ; ++i){
for(int j = 0 ; j < frameV ; ++j){
*(ifp+i+j*frameH) = *(fp+i+j*frameH);
}}

int temp;

for(int i = 1 ; i < frameH-1 ; ++i){
for(int j = 1 ; j < frameV-1 ; ++j){
temp =
*(ifp + (i-1) + (j-1)* frameH) +
*(ifp + i + (j-1)* frameH) +
*(ifp + (i+1) + (j-1)* frameH) +
*(ifp + (i-1) + j * frameH) +
*(ifp + i + j * frameH) +
*(ifp + (i+1) + j * frameH) +
*(ifp + (i-1) + (j+1)* frameH) +
*(ifp + i + (j+1)* frameH) +
*(ifp + (i+1) + (j+1)* frameH);

*(ifp+i+j*frameH) = (temp /9);
}}

for(int i = 0 ; i < frameH ; ++i){
for(int j = 0 ; j < frameV ; ++j){
*(fp+i+j*frameH) = *(ifp+i+j*frameH);
}}

fstream ofile;
ofile.open("W:\ba.raw", fstream::out | fstream::binary);
if( !ofile.good())
cout << "ofile讀檔失敗" << endl;

ofile.write((char*) fp, frameH*frameV); //轉態unsigned char* 轉態成 char* 放入函式
ofile.close();

delete [] fp;
delete [] ifp;
system("PAUSE");
return 0;
}