一、图像分割简介

理论知识参考:【基础教程】基于matlab图像处理图像分割【含Matlab源码 191期】

二、部分源代码

function susanseg
clear all; close all; clc
image= imread('cell.jpg');
% 用SUSAN算法进行边缘检测
image = susan(image,4);
figure, imshow(image,[]);
%imwrite(image, './susanout/susanout.jpg');
% 将image转为二值图像保存后,用图像处理工具
% 把其背景的所有连通区域处理为黑色,即只有细
% 胞体是白色,便于细胞数目的搜索
BW = im2bw(image, graythresh(image));
bounder_area = length(find(BW==0));
%imwrite(BW, './susanout/bw.jpg');
figure, imshow(BW);% 申明全局变量
global B Dir m n;
B = imread('./blackbackground.jpg');
B = im2bw(B, graythresh(B));
[m,n] = size(B);
figure, imshow(B);% 细胞的总面积,即细胞所占的像素数目,包括细胞的边界
% 由于SUSAN提取出的边界已被增宽,所以将边界像素数除以2
% 来作为细胞的边界像素数目
total_area = length(find(B==1)) + bounder_area/2;
NUM = 5; % 细胞面积阈值
count = 0; % 细胞总数
% 搜索方向向量,4邻域搜索
Dir = [-1 0; 0 1; 1 0; 0 -1;];
% 搜索方向向量,8邻域搜索
%Dir = [-1 0; -1 1; 0 1; 1 1; 1 0; 1 -1; 0 -1; -1 -1;];
for i = 1:mfor j = 1:nif B(i,j)==1 % 是细胞像素num = search(i,j,4) + 1; % 计算该细胞的像素数目if num>NUMcount = count  + 1;elsetotal_area = total_area - num; % 减掉不是细胞的面积endendend
end
%fid = fopen('./susanout/results.txt', 'wt');
fprintf('图像尺寸: %d * %d, SUSAN阈值: 4, 细胞面积阈值: %d\n', ...n, m, NUM);
fprintf('细胞总数: %d, 细胞总面积: %.2f, 平均细胞面积: %.2f\n', ...count, total_area, total_area/count);
%fprintf(fid,'图像尺寸: %d * %d, SUSAN阈值: 4, 细胞面积阈值: %d\n', ...
%    n, m, NUM);
%fprintf(fid,'细胞总数: %d, 细胞总面积: %.2f, 平均细胞面积: %.2f\n', ...
%    count, total_area, total_area/count);
%fclose(fid);
end
% -----------------------------------------------------------------------
%
% This function uses the SUSAN algorithm to find edges within an image
%
%
% >>image_out = susan(image_in,threshold)
%
%
% Input parameters ... The gray scale image, and the threshold
% image_out .. (class: double) image indicating found edges
% typical threshold values may be from 10 to 30
%
%
%The following steps are performed at each image pixel:
% ( from the SUSAN webpage, http://www.fmrib.ox.ac.uk/~steve/susan/susan/node4.html )
%
% Place a circular mask around the pixel in question.
% Calculate the number of pixels within the circular mask which have similar brightness to
% the nucleus. These define the USAN.
% Subtract USAN size from geometric threshold to produce edge strength image.
%
% Estimating moments to find the edge direction has not been implemented .
% Non-maximal suppresion to remove weak edges has not been implemented yet.
%
% example:
%
% >> image_in=imread('test_pattern.tif');
% >> image = susan(image_in,27);
% >> imshow(image,[])
%
%
% Abhishek Ivaturi
%
% -------------------------------------------------------------------------function image_out = susan(im,threshold)% check to see if the image is a color image...
%im= imread('test_pattern.tif')
%threshold=27;
d = length(size(im));
if d==3image=double(rgb2gray(im));
elseif d==2image=double(im);
end% mask for selecting the pixels within the circular region (37 pixels, as
% used in the SUSAN algorithmmask = ([ 0 0 1 1 1 0 0 ;0 1 1 1 1 1 0;1 1 1 1 1 1 1;1 1 1 1 1 1 1;1 1 1 1 1 1 1;0 1 1 1 1 1 0;0 0 1 1 1 0 0]);  % the output image indicating found edges
R=zeros(size(image));% define the USAN area
nmax = 3*37/4;% padding the image
[a b]=size(image);
new=zeros(a+7,b+7);
[c d]=size(new);
new(4:c-4,4:d-4)=image;for i=4:c-4for j=4:d-4current_image = new(i-3:i+3,j-3:j+3);current_masked_image = mask.*current_image;%   Uncomment here to implement binary thresholding%         current_masked_image(find(abs(current_masked_image-current_masked_image(4,4))>threshold))=0;
%         current_masked_image(find(abs(current_masked_image-current_masked_image(4,4))<=threshold))=1;%   This thresholding is more stablecurrent_thresholded = susan_threshold(current_masked_image,threshold);g=sum(current_thresholded(:));if nmax<gR(i,j) = g-nmax;elseR(i,j) = 0;endend
end

三、运行结果

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
[5]赵勇,方宗德,庞辉,王侃伟.基于量子粒子群优化算法的最小交叉熵多阈值图像分割[J].计算机应用研究. 2008,(04)

【细胞分割】基于matlab分水岭算法细胞分割计数【含Matlab源码 639期】相关推荐

  1. 【MVO TSP】基于matlab灰狼算法求解旅行商问题【含Matlab源码 1327期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[TSP]基于matlab灰狼算法求解旅行商问题[含Matlab源码 1327期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: ...

  2. 【BA TSP】基于matlab蜜蜂算法求解旅行商问题【含matlab源码 1248期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[TSP]基于matlab蜜蜂算法求解旅行商问题[含matlab源码 1248期] 获取代码方式2: 付费专栏Matlab路径规划(初级版 ...

  3. 【IA TSP】基于matlab免疫算法求解旅行商问题【含Matlab源码 195期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[旅行商问题]基于matlab免疫算法求解旅行商问题[含Matlab源码 195期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2 ...

  4. 【Matlab图像加密】正交拉丁方置乱算法图像加解密【含GUI源码 182期】

    一.代码运行视频(哔哩哔哩) [Matlab图像加密]正交拉丁方置乱算法图像加解密[含GUI源码 182期] 二.matlab版本及参考文献 一.代码运行视频(哔哩哔哩) [Matlab图像处理]自动 ...

  5. 【Matlab图像融合】小波变换遥感图像融合【含GUI源码 744期】

    一.代码运行视频(哔哩哔哩) [Matlab图像融合]小波变换遥感图像融合[含GUI源码 744期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 包子阳,余 ...

  6. 基于YOLOv5&Deepsort的山药计数系统(源码&教程)

    1.研究背景 目前缺少针对西南喀斯特山区作物种植地块破碎和多云雾天气导致影像存在阴影进而影响作物遥感识别精度等问题的研究,上述研究也未能找到较好消除杂草对作物植株识别影响的方法.此外,西南喀斯特山区作 ...

  7. 【Matlab验证码识别】遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别【含GUI源码 1694期】

    一.代码运行视频(哔哩哔哩) [Matlab验证码识别]遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别[含GUI源码 1694期] 二.matlab版本及参考文献 1 matlab ...

  8. 【Matlab人脸识别】BP神经网络人脸识别(含识别率)【含GUI源码 891期】

    一.代码运行视频(哔哩哔哩) [Matlab人脸识别]BP神经网络人脸识别(含识别率)[含GUI源码 891期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] ...

  9. 【Matlab人脸识别】形态学教室人数统计(带面板)【含GUI源码 1703期】

    一.代码运行视频(哔哩哔哩) [Matlab人脸识别]形态学教室人数统计(带面板)[含GUI源码 1703期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟 ...

  10. 【Matlab人脸识别】人脸实时检测与跟踪【含GUI源码 673期】

    一.代码运行视频(哔哩哔哩) [Matlab人脸识别]人脸实时检测与跟踪[含GUI源码 673期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟逸凡,柳益君 ...

最新文章

  1. MySQL数据类型与操作
  2. mac 下 使用 brew 配置 环境
  3. 当.NET遇到机器学习
  4. php 安装rabtmq amqp 扩展
  5. BZOJ 4000: [TJOI2015]棋盘( 状压dp + 矩阵快速幂 )
  6. Hadoop64位版本安装后遇到的警告处理
  7. 树:二叉树的非递归遍历算法
  8. 恢复误删的Windows文件
  9. Mybatis的直接执行SQL
  10. spreadJS初体验
  11. n1盒子救砖_新手教程教你N1盒子纯净刷机教程,实现OMV、HomeAssistant功能
  12. JVM 垃圾回收机制和常见的垃圾回收器
  13. 柯特斯公式的matlab代码,牛顿-柯特斯公式C语言的实现.pdf
  14. iis 设置php静态,PHP的Rewrite静态化服务器配置(包括IIS的静态华配置)
  15. 服务器紧急维修,Hypixel服务器紧急维护
  16. 基于多模型融合的用户画像分析统计方法研究
  17. selenium + 石墨文档 自动实现在固定位置写入文字
  18. java何时new_何时使用lambda,何时使用Proc.new?
  19. ubuntu-9.04DVD版linux系统安装秘诀
  20. 下图无序列表的html标记,ul标签-无序列表

热门文章

  1. Win下JDK的安装和简单使用教程
  2. 20191001每日一句
  3. 20190913每日一句
  4. 扇贝有道180628每日一句
  5. Atitit ati teck trend技术趋势资料包 C:\onedriver\OneDrive\Documents\0 it impttech topic\ati teck trend技术趋
  6. Atitit import sql fun 重要的sql功能扩展 ext 目录 1.1. Insert merge 1 1.2. Insert set 1 1.2.1. 13.2.5. LOAD
  7. Atitit QL查询语言总结 目录 1. QL = Query Language, 是查询语言的简称 1 2. 具体实现 1 2.1. Apcl 流程控制语言 1 2.2. 脚本流程控制 2 2.
  8. Atitit nlp自然语言处理类库(java python nodejs c#net) 目录 1.1. Python snownlp 1 1.2. NLP.js一个nodejs/javascri
  9. Atitit 项目风险管理 目录 1. 技术分险 2 1.1. 全面跟随大公司解决方案 2 1.2. 过度设计 2 1.3. 可读性 扩展性不足 2 1.4. 教条僵化 2 1.5. 技术方案超出了
  10. Atitit 为什么互联网机会这么大