/**************************双峰法**************************/
#include<stdio.h>
#include<conio.h>
/*#define BlackMax 30
#define WhiteMin 150 */
#define Row 33
#define Col 33
#define gray_value 256
int VideoData[Row][Col];
int Threshold,value;
/*int Whitecount=0,Blackcount=0,Averagecount=0,Whitesum=0,Blacksum=0,Averagesum=0;*/
main()
{ int n,j;
int peak1=0,peak2=0,valley,peak1_value,peak2_value;
int gray_num[gray_value]={0};
int VideoData[1][33]={39,39,40,39,39,41,41,41,43,44,44,44,44,44,22,21,21,24,44,44,44,44,44,44,44,44,44,43,41,41,41,41,39};
/*printf("Please input a matrix:\n");
for(j=0;j<Col;j++)
{
scanf("%d",&VideoData[0][j]);
}*/
/*统计第一行灰度生成直方图*/
for(n=0;n<Col;n++)
{
for(j=0;j<Col;j++)
{
if((VideoData[0][n]==VideoData[0][j])&&(VideoData[0][n]!=0))
{
value=VideoData[0][n];
gray_num[value]++;
if(n!=j) /*将后面重复的数字都清零*/
VideoData[0][j]=0;
}
}
}
for(value=0;value<gray_value;value++)
printf("%d ",gray_num[value]);
printf("\n");
getch();
/***************第一峰值****************/
for(value=0;value<gray_value;value++)
{
if(peak1<gray_num[value])
{peak1=gray_num[value];
peak1_value=value; /*peak1对应的灰度值*/
}
}
printf("The peak1_value is %d\n",peak1_value);
getch();
/***************第二峰值****************/
for(value=0;value<gray_value;value++)
{
if((peak2<gray_num[value])&&(gray_num[value]<peak1))
{peak2=gray_num[value];
peak2_value=value;/*peak2对应的灰度值*/
}
}
printf("The peak2_value is %d\n",peak2_value);
getch();
printf("peak1 is %d\npeak2 is %d\n",peak1,peak2);
/***************两峰之间谷底值****************/
if(peak1_value>peak2_value)
{
valley=peak1;
for(value=peak1_value;value>peak2_value;value--)
{
if(gray_num[value]!=0)
{if(valley>gray_num[value])
{valley=gray_num[value];
Threshold=value; } /*谷底对应的灰度值为阈值*/
}
}
printf("The valley is %d\n",valley);
printf("The threshold is %d\n",Threshold);
}
getch();
}
dpeak.rar_双峰 阈值 c
版权申诉
190 浏览量
2022-09-22
18:24:23
上传
评论
收藏 930B RAR 举报
alvarocfc
- 粉丝: 105
- 资源: 1万+
最新资源
- 基于Spring Bootd实现的图像去雾系统端,完成主要的前后端交互+源代码+文档说明
- 企业网站建设-PPT.ppt
- 办公自动化Microsoft-Office学习教程.doc
- 办公软件ECEL技巧培训课件-PPT.pptx
- 办公软件Word快捷键大全.doc
- Springboot集成SpringbootAdmin实现服务监控管理-源码
- 办公软件应用-计算机一级考试试题.doc
- 毕业设计-图像去雾,基于matlab实现的暗通道先验算法和Retinex图像增强算法制作的图形化界面程序仿真源码
- 基于python+opencv实现的暗通道先验的单幅图像去雾算法python仿真源代码+文档说明+截图演示(高分课程设计)
- 基于STM32G4与智能摄像头的疲劳驾驶检测系统源代码(96分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0