日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言程序图片马赛克,关于c语言的图像均值滤波 请问大神为什么我的结果都是马赛克...

發(fā)布時間:2023/12/10 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言程序图片马赛克,关于c语言的图像均值滤波 请问大神为什么我的结果都是马赛克... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

該樓層疑似違規(guī)已被系統(tǒng)折疊?隱藏此樓查看此樓

#include

#include

#include

#include

#include

#include

#include "stdlib.h"

#include "string.h"

#define width 256

#define higth 256

//原圖象的寬度和高度

int lvbo(unsigned char D[])

{

int a;

a=(D[0]+D[1]+D[2]+D[3]+D[4]+D[5]+D[6]+D[7]+D[8]+D[9]+D[10]+D[11]+D[12]+D[13]+D[14]+D[15]+D[16]+D[17]+D[18]+D[19]+D[20]+D[21]+D[22]+D[23]+D[24])/25;

//printf("%d",a);

return a;

}

void main()

{

FILE *fp,*newfp;

int i,j;

unsigned char D[25];//定義選取框

unsigned char buffer[54+1024];//定義原圖像頭緩沖區(qū)

unsigned long length=width*higth;//圖像的總象素個數(shù)

unsigned char readData[higth][width]; //用于存儲原圖數(shù)據(jù)的數(shù)組

unsigned char writeData[higth][width]; //用于存儲原圖數(shù)據(jù)的數(shù)組

if(!(fp=fopen("C:\\Users\\Alan\\Desktop\\pic\\line.jpg","rb")))

{

printf("Open file1 error!\n");

return ;

}

if(!(newfp=fopen("C:\\Users\\Alan\\Desktop\\pic\\2.jpg","wb")))

{

printf("Open file2 error!\n");

return ;

}

fread(buffer,1,54+1024,fp);//讀取文件頭54個字節(jié)

fread(&readData[0][0], sizeof(unsigned char),length, fp);//從原圖讀入數(shù)據(jù)

for(i=0;i

{

for(j=0;j

{

writeData[i][j]=readData[i][j];

}

}

for(i=2;i

{

for(j=2;j

{

D[0]=readData[i-2][j-2];

D[1]=readData[i-2][j-1];

D[2]=readData[i-2][j];

D[3]=readData[i-2][j+1];

D[4]=readData[i-2][j+2];

D[5]=readData[i-1][j-2];

D[6]=readData[i-1][j-1];

D[7]=readData[i-1][j];

D[8]=readData[i-1][j+1];

D[9]=readData[i-1][j+2];

D[10]=readData[i][j-2];

D[11]=readData[i][j-1];

D[12]=readData[i][j];

D[13]=readData[i][j+1];

D[14]=readData[i][j+2];

D[15]=readData[i+1][j-2];

D[16]=readData[i+1][j-1];

D[17]=readData[i+1][j];

D[18]=readData[i+1][j+1];

D[19]=readData[i+1][j+2];

D[20]=readData[i+2][j-2];

D[21]=readData[i+2][j-1];

D[22]=readData[i+2][j];

D[23]=readData[i+2][j+1];

D[24]=readData[i+2][j+2];

writeData[i][j]=lvbo(D);

}

}

fwrite(buffer,sizeof(unsigned char),54+1024,newfp);

fwrite(writeData,sizeof(unsigned char),length,newfp);

fclose(newfp);

fclose(fp);

printf("success\n");

return ;

}

總結(jié)

以上是生活随笔為你收集整理的c语言程序图片马赛克,关于c语言的图像均值滤波 请问大神为什么我的结果都是马赛克...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。