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

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#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];//定义原图像头缓冲区

unsigned long length=width*higth;//图像的总象素个数

unsigned char readData[higth][width]; //用于存储原图数据的数组

unsigned char writeData[higth][width]; //用于存储原图数据的数组

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个字节

fread(&readData[0][0], sizeof(unsigned char),length, fp);//从原图读入数据

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 ;

}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/440411.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【HDU - 1533】Going Home(网络流,二分图最优匹配,KM算法)

题干: On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little man, you need to pay a $1 travel fee for every step h…

c语言程序设计现代方法快速排序,C语言实现快速排序改进版

利用三者取中法改进快速排序,具体内容如下实现取数组中第一个,中间和最后一个元素的中间元素作为划分元素(否则将这些元素排除在划分过程之外).大小为11或更小的数组在划分过程中被忽略,然后使用插入排序来完成排序.#include #include #include #include #include #…

c语言一个数组后添加元素append,jQuery 追加元素、拼接元素的方法总结(append、html、insertBefore、before等)...

1. append & appendTo 的功能均为:在被选元素结尾(仍在元素内部)插入指定内容,但是内容和选择器的位置不同(1) append()方法:$("#test").append("测试"); //在id为test元素内部末尾插入测试(2) appendTo()方法&…

【ZOJ - 4024】Peak(模拟,水题)

题干: A sequence of integers is called a peak, if and only if there exists exactly one integer such that , and for all , and for all . Given an integer sequence, please tell us if its a peak or not. Input There are multiple test cases. …

【ZOJ - 4029】Now Loading!!!(整除分块,思维,二分,前缀和)

题干: 其中 zi 是第i次询问后的z。 解题报告: 因为有取log运算,所以分母的取值肯定不会超过30种,所以分每一个分母的时候,用前缀和优化一个和,最后求乘积就行了。(其实不需要快速幂&#xff0c…

迷宫小游戏c语言代码,C语言编写的迷宫小游戏-源代码

#include #define N 20/*迷宫的大小,可改变*/int oldmap[N][N];/*递归用的数组,用全局变量节约时间*/int yes0;/*yes是判断是否找到路的标志,1找到,0没找到*/int way[100][2],wayn0;/*way数组是显示路线用的,wayn是统计走了几个格子*/void Init(void);/*…

【ZOJ - 4032】Magic Points (思维,几何,构造)

题干: 解题报告: 想到了,这样绕圈构造。但是这样有个问题,最后一个点如何构造。 刚开始想的是n奇数 , 就8 10 这样的连一条,n偶数 就8 11 这样的连一条,随便构造一下就行,但是发…

s7-200 plc 梯形图转换成c语言的方法,S7-200PLC模拟量4-20mA转换成整数程序算法示例.pdf...

S7200PLC 模拟量4 -20 mA 转换成整数程序算法示例S7200PLC 模拟量4 -20 mA 转换成整数程序算法示例,以及模拟量数据滤波平缓处理,消除曲线的尖峰毛刺程序示例。连续采集10 个数,找出最大值,最小值&#xff…

【ZOJ - 4033】CONTINUE...? (思维,整体思想,分组思想)

题干: DreamGrid has classmates numbered from to . Some of them are boys and the others are girls. Each classmate has some gems, and more specifically, the -th classmate has gems. DreamGrid would like to divide the classmates into four group…

android 仿真翻页动画,Android 两Activity之间动画效果(1)---------翻页效果

用Android rotate动画实现翻页效果,效果如图:要实现上面动画,首先搞明白rotate动画原理;(1)Degrees坐标:0度(360度)270度90度 顺时针旋转 180(2)rotate 关键属性fromDegrees 开始旋转时角度 toDegrees 结束时的角…

android 存储不被垃圾清理,手机内存足够大,就不需要清理垃圾了?你错了!

原标题:手机内存足够大,就不需要清理垃圾了?你错了!中新网4月20日电今天,人们使用智能手机的时间已超过电脑,希望在任何时候、任何地方,一部手机搞定所有。对手机的流畅度、性能和安全的要求越来越高。新手机刚到手时非常流畅,用一段时间就出现各种卡顿,网民对猎豹…

【蓝桥杯 - 真题】六角幻方(dfs+剪枝)

标题:六角幻方 把 1 2 3 ... 19 共19个整数排列成六角形状,如下: * * * * * * * * * * * * * * * * * * * 要求每个直线上的数字之和必须相等。共有15条直线哦! 再给点线索吧!我们预先填好了2个数字&…

【2019浙江省赛 - J】Welcome Party(并查集,bfs,优先队列,建图)

题干: The 44th World Finals of the International Collegiate Programming Contest (ICPC 2020) will be held in Moscow, Russia. To celebrate this annual event for the best competitive programmers around the world, it is decided to host a welcome pa…

app android de,Android Deobfuscation

Android Deobfuscation11/11/2019本文内容ProGuard、DexGuard 和 R8 是用于对 Android 应用程序的代码进行优化和模糊处理的工具。 它会删除未使用的代码、重命名具有语义模糊名称的类、字段和方法,使基本代码更小,更难反向工程。 若要在 Android 应用中…

【2019浙江省赛 - B】Element Swapping(思维,数学)

题干: DreamGrid has an integer sequence and he likes it very much. Unfortunately, his naughty roommate BaoBao swapped two elements and () in the sequence when DreamGrid wasnt at home. When DreamGrid comes back, he finds with dismay that his …

android 没有指令,android – 运行时没有命令输出:’am start -n

最近,当我试图在我的设备上运行我的Android应用程序时,我必须在实际启动之前从Eclipse运行它几次.我试图重新安装JRE,JDK和IDE,我试图切换工作区.我还让Eclipse为Java VM使用更多的RAM.我的IDE,JRE,JDK,ADT和ADT插件都是最新的.对此有任何建议非常感谢.No command output when …

【2019浙江省赛 - E】Sequence in the Pocket(思维)

题干: DreamGrid has just found an integer sequence in his right pocket. As DreamGrid is bored, he decides to play with the sequence. He can perform the following operation any number of times (including zero time): select an element and move i…

android和ios系统的内存,WP和Saipan系统的流畅程度相当于ios,占用的内存很少,但是为什么要用Android取代它...

当涉及到WP和Symbian系统时,许可能没有听说过它,但是对于大多数关注智能手机市场增长的消费者来说,它已经为人们所熟悉,并且许已经使用了它. 当时在功能性机器上使用了Saipan系统,但是您会发现该系统的流畅性与当时的i…

【CodeForces - 1042C】Array Product(思维,有坑细节)

题干: You are given an array aa consisting of nn integers. You can perform the following operations with it: Choose some positions ii and jj (1≤i,j≤n,i≠j1≤i,j≤n,i≠j), write the value of ai⋅ajai⋅aj into the jj-th cell and remove the num…

红米pro android o刷机,红米Pro如何刷机?你可以通过这两种方法获取root权限!

小米官网最近发布了关于红米pro的消息,相信很多米粉们已经上手了,那么新到手的机子怎么刷机呢?下面小编为大家带来一个完整的红米Pro官方卡刷机教程,希望可以帮助到大家。红米Pro卡刷升级教程:准备工作1.进入红米Pro刷…