ostu进行遥感图像的分割
城市地区道路网的简单的阈值分割。采用的是单ostu(最佳阈值分割)算法,废话少说,如果不太清楚该算法,请参考文献[1]中的图像分割这一章的介绍。程序直接运行的效果如下。
直接附加代码,希望对大家有一些益处,节约你的时间:
% 最大类方差法实现自适应图像阈值分割 % This implements is implemented by WENG, All rights reserved % Copy Rights (c) WENG % 2016-3-30 1639clear;clc;close all; warning off; %#ok<WNOFF> IMG = imread('steger_perfect_1_rg.tif');% fdoa1_rs1_rg.tif IMG_gray=double(rgb2gray(IMG)); [M,N]=size(IMG_gray);gray_level=256;% Histgram Histgram_normal=zeros(256,1);% value span, 1~256 for i_level=1:256,Histgram_normal(i_level)=sum(sum(IMG_gray==(i_level+1))); end Histgram_normal=Histgram_normal/(M*N); % histgram normalizem_overall=0; for m=1:gray_level,m_overall=m_overall+(m-1)*Histgram_normal(m);endsigma_max=0; sigma_B=zeros(gray_level,1); for i=1:gray_level,threshold=i-1;% calculate the number of the two class, the number is 0~1num1=0; for m=1:threshold-1num1=num1+Histgram_normal(m);endnum2=1-num1;% cal m1, m2m1=0;m2=0;for m=1:gray_levelif m<thresholdm1=m1+(m-1)*Histgram_normal(m);elsem2=m2+(m-1)*Histgram_normal(m);endend% calculate the std betweent the two classesm1=m1/num1;m2=m2/num2;sigma1=num1*(m1-m_overall)^2+num2*(m2-m_overall)^2;% save and updatesigma_B(i)=sigma1;if sigma1>sigma_maxoptical_T=threshold;sigma_max=sigma1;end endTh_optical=optical_T; Th_matalb=graythresh(IMG_gray)*255;%matlab函数求阈值 fprintf(1,'The otsu threshold and Threshold calculate by graythresh are:\n %.1f [best], %.1f\n\n',Th_optical,Th_matalb);% visual the result Threshold_Optimal_IMG=zeros(M,N); Threshold_graythresh_IMG=zeros(M,N); Threshold_Optimal_IMG(IMG_gray>Th_optical)=1; Threshold_graythresh_IMG(IMG_gray>Th_matalb)=1; figure,subplot(2,2,1);imshow(IMG,[]);title('Ori color image'); subplot(2,2,2);imshow(IMG_gray,[]);title('Ori gray image'); subplot(2,2,3);imshow(Threshold_graythresh_IMG,[]);title('Threshold calculated by graythresh'); subplot(2,2,4);imshow(Threshold_Optimal_IMG,[]);title('Threshold calculated by ostu');figure,subplot(1,2,1); hold on; plot(1:gray_level,sigma_B);title('The two TH marked on \sigma array'); xlabel('Th'); ylabel('\sigma_B'); plot(Th_optical+1,sigma_B(Th_optical+1),'xg','MarkerSize',8,'LineWidth',2); text(Th_optical+1,sigma_B(Th_optical+1)-50,'otsu threshold'); plot(Th_matalb+1,sigma_B(Th_matalb+1),'^r','MarkerSize',8,'LineWidth',2); text(Th_matalb+1,sigma_B(Th_matalb+1)-50,'graythresh calculated threshold'); hold off;subplot(1,2,2);plot(1:gray_level,Histgram_normal);title('Gray image Histgram'); hold on; plot(Th_optical+1,Histgram_normal(Th_optical+1),'xg','MarkerSize',8,'LineWidth',2); text(Th_optical+1,Histgram_normal(Th_optical+1)-50,'otsu threshold'); plot(Th_matalb+1,Histgram_normal(Th_matalb+1),'^r','MarkerSize',8,'LineWidth',2); text(Th_matalb+1,Histgram_normal(Th_matalb+1)-50,'graythresh calculated threshold'); hold off;% Image that can be classified by the threshold evaluate Sigma_G=std(IMG_gray(:)); eta_ostu=sigma_B(Th_optical+1)/Sigma_G; eta_matlab=sigma_B(Th_matalb+1)/Sigma_G; fprintf(1,'The separability of ostu and matlab graythresh func respectively are:\n%.3f, %.3f\n',eta_ostu,eta_matlab);
参考文献
[1] (美)冈萨雷斯(Gonzalez, R.C.), (美)伍兹(Woods,等. 数字图像处理[M]. 电子工业出版社, 2013.
ostu进行遥感图像的分割相关推荐
- 【Keras】基于SegNet和U-Net的遥感图像语义分割
from:[Keras]基于SegNet和U-Net的遥感图像语义分割 上两个月参加了个比赛,做的是对遥感高清图像做语义分割,美其名曰"天空之眼".这两周数据挖掘课期末projec ...
- Keras】基于SegNet和U-Net的遥感图像语义分割
from:[Keras]基于SegNet和U-Net的遥感图像语义分割 上两个月参加了个比赛,做的是对遥感高清图像做语义分割,美其名曰"天空之眼".这两周数据挖掘课期末projec ...
- 学习笔记-基于全局和局部对比自监督学习的高分辨率遥感图像语义分割-day1
基于全局和局部对比自监督学习的高分辨率遥感图像语义分割-day1 摘要 一. 引言 摘要 最近,监督深度学习在遥感图像(RSI)语义分割中取得了巨大成功. 然而,监督学习进行语义分割需要大量的标记样本 ...
- 遥感图像语义分割各公开数据集
遥感图像语义分割数据集 1. Gaofen Image Dataset(GID) 2. ISPRS Test Project on Urban Classification and 3D Buildi ...
- 无人机遥感图像语义分割数据集UAVid使用
一.无人机遥感图像语义分割数据集UAVid UAVid数据集是用于针对城市场景的语义分割任务的UAV视频数据集.它具有几个特点: 语义分割 4K分辨率无人机视频 8种物体类别 街景环境 示例图像: 下 ...
- 【论文阅读】SCAttNet:具有空间和通道注意机制的高分辨率遥感图像语义分割网络
[论文阅读]SCAttNet:具有空间和通道注意机制的高分辨率遥感图像语义分割网络 文章目录 [论文阅读]SCAttNet:具有空间和通道注意机制的高分辨率遥感图像语义分割网络 一.总体介绍 二.概述 ...
- 遥感图像语义分割——从原始图像开始制作自己的数据集(以高分二号为例)
遥感图像语义分割--从原始图像开始制作自己的数据集(以高分二号为例) 文章目录 遥感图像语义分割--从原始图像开始制作自己的数据集(以高分二号为例) 1.遥感影像获取 2.遥感数据预处理(影像融合) ...
- 学习笔记-基于全局和局部对比自监督学习的高分辨率遥感图像语义分割-day2
高分辨率遥感图像语义分割-day2 摘要 一.引言 二.方法 2.1 对比学习 2.2 全局风格与局部匹配对比学习网络(GLCNet) 2.2.1 全局风格对比学习模块: 2.2.2局部匹配对比学习: ...
- [论文阅读]面向全局:用于高分辨率遥感图像语义分割的宽上下transforms
[论文阅读]面向全局:用于高分辨率遥感图像语义分割的宽上下transforms 文章目录 [论文阅读]面向全局:用于高分辨率遥感图像语义分割的宽上下transforms 一.总体介绍 二.具体作用 3 ...
最新文章
- FLEX是什么及与FLASH的关系的介绍
- c: realloc()函数解析
- [Effective JavaScript 笔记]第59条:避免过度的强制转换
- 偏心率e用于描述某一轨道与圆轨道的区别
- 【算法图解|4】JavaScript 如何求数组的最大值和最小值
- CSS3 Flex布局(伸缩布局盒模型)学习
- 2015年《大数据》高被引论文Top10文章No.5——对大数据的再认识
- Android 多媒体开发学习之加载大图片
- 【C学习】全通纸笔王网上阅卷系统 APMS_Setup.exe IP修改程序 - 附C/C#/Delphi源码
- 读一个文本文件总是出现乱码怎么办
- 执行retn、call、leave指令的时候,esp和eip的变化情况
- Unity3D代码动态修改材质球的颜色
- 弘辽科技:什么是淘宝直通车卡位?有哪些卡位技巧?
- 十二周四次课(6月11日)
- 小程序源码整理最新的学习小程序的源码清单包含前后台
- [日推荐]『口红IN』女票生气了怎么哄?这里有妙招!
- 微软研发中心招聘的背后
- python 人工智能编程_最适合人工智能开发的5种编程语言
- Grpc系列二 Grpc4种服务方法的定义和实现
- windows10家庭版个人电脑提升网速
热门文章
- 概率论-3.2 边际分布与随机变量的独立性
- 让你IDA Pro 快速上手使用
- Android-NDK-EGL
- Dalvik控制VM详解
- linux 更改文件夹大小,Linux下改变文件大小
- win7未启用计算机远程访问,Win7系统下连接远程提示未启用对服务器的远程访问如何解决...
- ServiceMix中文教程
- JAVA的内省机制(introspector)与反射机制(reflection)
- spring ref historydesign philosophy
- springmvc 自定义view支持json和jsonp格式数据返回