Matlab去除二值图像小对象 bwareaopen

2023-05-16

From: https://ww2.mathworks.cn/help/images/ref/bwareaopen.html

bwareaopen

Remove small objects from binary image

collapse all in page

Syntax

BW2 = bwareaopen(BW,P)

BW2 = bwareaopen(BW,P,conn)

Description

example

BW2 = bwareaopen(BW,P) removes all connected components (objects) that have fewer than P pixels from the binary image BW, producing another binary image, BW2. This operation is known as an area opening.

BW2 = bwareaopen(BW,P,conn) removes all connected components, where conn specifies the desired connectivity.

Examples

collapse all

Remove Objects in Image Containing Fewer Than 50 Pixels

Try This Example

Read binary image.

BW = imread('text.png');

Remove objects containing fewer than 50 pixels using bwareaopen function.

BW2 = bwareaopen(BW, 50);

Display original image next to morphologically opened image.

imshowpair(BW,BW2,'montage')

Input Arguments

collapse all

BW — Binary image
real, nonsparse, logical or numeric array of any dimension

Binary image, specified as a nonsparse, logical or numeric array of any dimension.

Example: BW2 = bwareaopen(BW, 50);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

P — Maximum number of pixels in objects
nonnegative, integer-valued, numeric scalar

Maximum number of pixels in objects, specified as a nonnegative, integer-valued, numeric scalar.

Example: BW2 = bwareaopen(BW, 50);

Data Types: double

conn — Pixel connectivity
4 | 8 | 6 | 18 | 26 | 3-by-3-by- ... -by-3 matrix of 0s and 1s

Pixel connectivity, specified as one of the values in this table. The default connectivity is 8 for 2-D images, and 26 for 3-D images.

Value

Meaning

Two-Dimensional Connectivities

4-connected

Pixels are connected if their edges touch. Two adjoining pixels are part of the same object if they are both on and are connected along the horizontal or vertical direction.

8-connected

Pixels are connected if their edges or corners touch. Two adjoining pixels are part of the same object if they are both on and are connected along the horizontal, vertical, or diagonal direction.

Three-Dimensional Connectivities

6-connected

Pixels are connected if their faces touch. Two adjoining pixels are part of the same object if they are both on and are connected in:

  • One of these directions: in, out, left, right, up, and down

 

18-connected

Pixels are connected if their faces or edges touch. Two adjoining pixels are part of the same object if they are both on and are connected in

  • One of these directions: in, out, left, right, up, and down

  • A combination of two directions, such as right-down or in-up

 

26-connected

Pixels are connected if their faces, edges, or corners touch. Two adjoining pixels are part of the same object if they are both on and are connected in

  • One of these directions: in, out, left, right, up, and down

  • A combination of two directions, such as right-down or in-up

  • A combination of three directions, such as in-right-up or in-left-down

 

For higher dimensions, bwareaopen uses the default value conndef(ndims(BW),'maximal').

Connectivity can also be defined in a more general way for any dimension by specifying a 3-by-3-by- ... -by-3 matrix of 0s and 1s. The 1-valued elements define neighborhood locations relative to the center element of conn. Note that conn must be symmetric about its center element. See Specifying Custom Connectivities for more information.

Data Types: double | logical

Output Arguments

collapse all

BW2 — Image that has been morphologically opened
nonsparse, logical array of any dimension

Image that has been morphologically opened, specified as a nonsparse, logical array the same size as BW.

Algorithms

The basic steps are

  1. Determine the connected components:

    CC = bwconncomp(BW, conn);
  2. Compute the area of each component:

    S = regionprops(CC, 'Area');
  3. Remove small objects:

    L = labelmatrix(CC);
    BW2 = ismember(L, find([S.Area] >= P));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Matlab去除二值图像小对象 bwareaopen 的相关文章

  • 1、Oracle PL/SQL中的字符串及函数介绍

    该文章是 PL SQL基础 xff08 3 xff09 xff1a 小专题 系列文章之一 Oracle中常用的字符串类型有 xff1a 固定长度 xff08 CHAR等 xff09 可变长度 xff08 VARCHAR2等 xff09 和大
  • 2、Oracle PL/SQL字符串分割截取

    该文章是 PL SQL基础 xff08 3 xff09 xff1a 小专题 系列文章之一 Oracle中的instr和substr函数 Oracle PL SQL中可以通过instr xff08 获取特定字符串的索引 xff09 和subs
  • 4、Oracle PL/SQL编译错误查看与处理

    该文章是 PL SQL基础 xff08 3 xff09 xff1a 小专题 系列文章之一 在编译Oracle PL SQL函数等时 xff0c 难免会遇到错误 例如 xff1a Function GETSTR1 已编译 Errors che
  • 3、Oracle PL/SQL中Date格式及格式转换

    该文章是 PL SQL基础 xff08 3 xff09 xff1a 小专题 系列文章之一 Oracle 插入日期 xff08 时间 xff09 时报错 xff1a ORA 01861 文字与格式字符串不匹配 这是由于插入的日期格式和数据库现
  • 5、Oracle数据库insert后获取自增的ID

    该文章是 PL SQL基础 xff08 3 xff09 xff1a 小专题 系列文章之一 在 insert 后使用 select 序列名 CURRVAL from dual 可以获取 insert后自增的ID 具体 SQL 语句 xff1a
  • 解决cmd 中ping>nul语句提示命令符无法识别

    问题描述 xff1a 在批量使用chrome exe ftp data hdf amp ping n10 127 0 0 1 gt nul 下载数据时 xff0c 命令行没有因为ping命令暂停 解决 xff1a 怀疑是ping这部分命令存
  • C#控件限制输入字符数且可用退格

    对于C 控件 xff08 例如textbox xff09 的输入限制长度 xff0c 直接想到的方法是在控件的KeyPress事件时判断控件已有的字符数来限制 假设控件名称为DAForm myBox4 xff0c KeyPress事件简单的
  • XXX事件的重载均与委托"System.EventHandler"不匹配

    在给动态创建控件添加事件时容易遇到的一个错误就是 xff1a XXX事件的重载均与委托 34 System EventHandler 34 不匹配 假设控件是MovePicBox xff0c 使用如下代码添加KeyPress事件 xff0c
  • 外部启动c#窗体程序传参问题

    问题 xff1a 需要在一个软件里启动另一个独立的C 窗体软件并传入参数 xff0c 例如下面的启动语句 string language 61 34 en us 34 System Diagnostics Process Start 34
  • C#控件控制输入文本长度

    C 在控制控件输入文本的长度时要注意两个问题 xff1a 1 传递的事件参数类型要是 KeyPressEventArgs xff1b 2 对退格键 xff08 backspace xff09 做例外处理 xff0c 不然在输入到最大程度时无
  • python打印等腰三角形

    d 61 int input 39 enter an int 39 l 61 39 39 2 d 1 d 初始化列表 for i in range d l i 61 list l i 字符串转列表 x 61 i y 61 0 x 61 d
  • 7、Oracle的;与ORA-00911: invalid character

    写SQL查询 Oracle中的数据时容易遇到一个奇怪的问题 xff1a 在一般的SQL developer查询分析器中写好的SQL语句运行一切正常 xff0c 放到C 写的程序中提交 ORACLE执行就报错 错误代码如下 xff1a ORA
  • C语言变量声明加冒号的用法

    有些信息在存储时 xff0c 并不需要占用一个完整的字节 xff0c 而只需占几个或一个二进制位 例如在存放一个开关量时 xff0c 只有0和1 两种状态 xff0c 用一位二进位即可 为了节省存储空间 xff0c 并使处理简便 xff0c
  • Matlab adjust axis tick labels, limits, and tick locations

    From https cn mathworks com matlabcentral answers 92565 how do i control axis tick labels limits and axes tick locations
  • Matlab 旋转坐标轴标记文本

    在绘图中当X坐标轴标记 xff08 注意不是坐标轴名称的标签 xff09 是文本且较密集的时候我们会希望能够旋转标签以容得下所有内容 xff0c 当Y坐标轴标记是文本时 xff0c 我们也希望文本可以顺着Y轴的方向 这些都需要旋转坐标轴的标
  • Matlab - Extract values from boxplot(从箱图中获取数据)

    From http stackoverflow com questions 9728970 matlab extract values from boxplot How to extract values from built in box
  • matlab写hdf文件(含地理信息文件hdfeos)

    本文介绍matlab写hdf4和hdf5的一些方法 hdf的一些基础信息可以参考 xff1a https sanwen8 cn p 1fcFE9f html 1 matlab写hdf4文件 通常有两种方法 xff1a 1 xff09 mat
  • oracle ORA-01000: maximum open cursors exceeded问题的解决方法

    From http blog csdn net uskystars article details 46679835 项目在运行过程中 xff0c 后台报错 xff1a Java代码 ORA 01000 maximum open curso
  • emgu.cv的图像金字塔操作

    emgu cv里有三个常用的影像金字塔 xff08 重采样 xff0c 每一级倍数2 xff09 函数 xff1a 1 BuildPyramid int maxLevel 建立多级影像金字塔 C 例子 xff1a Int maxLevel
  • ENVI栅格裸数据生成shp和kml矢量文件

    ENVI栅格裸数据生成shp和kml矢量文件 生成kml文件需要用到ArcMap xff0c 但是ArcMap不能直接加载ENVI裸数据 xff0c 需要在ENVI里将栅格数据转为shp或另存为ArcViewRaster 前者生成kml文件

随机推荐