imfill[亲测有效]

(44) 2023-06-27 14:12

Hi,大家好,我是编程小6,很荣幸遇见你,我把这些年在开发过程中遇到的问题或想法写出来,今天说一说imfill[亲测有效],希望能够帮助你!!!。

文章目录

    • Syntax
    • Description
    • Examples
    • Input Arguments
    • Output Arguments

填充图像区域和孔

Syntax

BW2 = imfill(BW,locations)
BW2 = imfill(BW,locations,conn)
BW2 = imfill(BW,'holes')
BW2 = imfill(BW,conn,'holes')
I2 = imfill(I)
I2 = imfill(I,conn)
BW2 = imfill(BW)
BW2 = imfill(BW,0,conn)
[BW2, locations_out] = imfill(BW)

Description

BW2 = imfill(BW,locations)从位置中指定的点开始,对输入二进制图像BW的背景像素执行泛洪填充操作。

BW2 = imfill(BW,locations,conn)填充由位置定义的区域,其中conn指定连接性。

BW2 = imfill(BW,'holes')填充输入二进制图像BW中的孔。按照这种语法,孔是一组背景像素,
无法通过从图像边缘填充背景来达到。

BW2 = imfill(BW,conn,'holes')填充二进制图像BW中的孔,其中conn指定连接性。

I2 = imfill(I)填充灰度图像I中的孔。在此语法中,孔定义为由较亮像素围绕的深色像素区域。

I2 = imfill(I,conn)填充灰度图像I中的孔,其中conn指定连接性。

BW2 = imfill(BW)在屏幕上显示二进制图像BW,并允许您通过使用鼠标交互选择点来定义要填充的区域。
要使用此语法,BW必须是2D图像。
按Backspace或Delete键删除先前选择的点。按住Shift键单击,右键单击或双击以选择终点并开始填充操作。
按Return键完成选择而不添加点。

BW2 = imfill(BW,0,conn)使您可以在交互式指定位置时覆盖默认连接。

[BW2,locations_out] = imfill(BW)返回在locations_out中交互选择的点的位置。要使用此语法,
BW必须是2D图像。

Examples

从指定的起点填充图像

clear all
close all
clc
BW1 = logical([1 0 0 0 0 0 0 0
               1 1 1 1 1 0 0 0
               1 0 0 0 1 0 1 0
               1 0 0 0 1 1 1 0
               1 1 1 1 0 1 1 1
               1 0 0 1 1 0 1 0
               1 0 0 0 1 0 1 0
               1 0 0 0 1 1 1 0]);

BW2 = imfill(BW1,[3 3],8)

BW2 = 8x8 logical array

   1   0   0   0   0   0   0   0
   1   1   1   1   1   0   0   0
   1   1   1   1   1   0   1   0
   1   1   1   1   1   1   1   0
   1   1   1   1   1   1   1   1
   1   0   0   1   1   1   1   0
   1   0   0   0   1   1   1   0
   1   0   0   0   1   1   1   0

填充二进制图像中的孔

clear all
close all
clc
I = imread('coins.png');
figure
imshow(I)
title('Original Image')
%将图像转换为二进制图像。
BW = imbinarize(I);
figure
imshow(BW)
title('Original Image Converted to Binary Image')
%在二进制图像中填充孔并显示结果。
BW2 = imfill(BW,'holes');
figure
imshow(BW2)
title('Filled Image')

imfill[亲测有效]_https://bianchenghao6.com/blog__第1张
imfill[亲测有效]_https://bianchenghao6.com/blog__第2张
imfill[亲测有效]_https://bianchenghao6.com/blog__第3张
填充灰度图像中的孔

I = imread('tire.tif');
I2 = imfill(I);
figure, imshow(I), figure, imshow(I2)

imfill[亲测有效]_https://bianchenghao6.com/blog__第4张
imfill[亲测有效]_https://bianchenghao6.com/blog__第5张

Input Arguments

locations-标识像素位置的线性索引
正整数的数值向量| 正整数的二维数值矩阵
线性索引,标识像素位置,指定为正整数的数字矢量或二维数字矩阵。 如果位置是p×1向量,则它包含起始位置的线性索引。 如果位置是p-by-ndims(BW)矩阵,则每一行都包含一个起始位置的数组索引。

Output Arguments

locations_out-像素位置的线性索引
数值向量| 数值矩阵
像素位置的线性索引,以数字向量或矩阵形式返回。

I2 —填充的灰度图像
数值数组
填充的灰度图像,以数字数组形式返回

上一篇

已是最后文章

下一篇

已是最新文章

发表回复