
- Mahotas 教程
- Mahotas - 首頁
- Mahotas - 簡介
- Mahotas - 計算機視覺
- Mahotas - 歷史
- Mahotas - 特性
- Mahotas - 安裝
- Mahotas 影像處理
- Mahotas - 影像處理
- Mahotas - 載入影像
- Mahotas - 載入灰度影像
- Mahotas - 顯示影像
- Mahotas - 顯示影像形狀
- Mahotas - 儲存影像
- Mahotas - 影像質心
- Mahotas - 影像卷積
- Mahotas - 建立RGB影像
- Mahotas - 影像尤拉數
- Mahotas - 影像中零的比例
- Mahotas - 獲取影像矩
- Mahotas - 影像區域性最大值
- Mahotas - 影像橢圓軸
- Mahotas - 影像拉伸RGB
- Mahotas 顏色空間轉換
- Mahotas - 顏色空間轉換
- Mahotas - RGB轉灰度轉換
- Mahotas - RGB轉LAB轉換
- Mahotas - RGB轉棕褐色
- Mahotas - RGB轉XYZ轉換
- Mahotas - XYZ轉LAB轉換
- Mahotas - XYZ轉RGB轉換
- Mahotas - 增加伽馬校正
- Mahotas - 拉伸伽馬校正
- Mahotas 標記影像函式
- Mahotas - 標記影像函式
- Mahotas - 標記影像
- Mahotas - 過濾區域
- Mahotas - 邊界畫素
- Mahotas - 形態學運算
- Mahotas - 形態學運算元
- Mahotas - 查詢影像均值
- Mahotas - 裁剪影像
- Mahotas - 影像離心率
- Mahotas - 影像疊加
- Mahotas - 影像圓度
- Mahotas - 影像縮放
- Mahotas - 影像直方圖
- Mahotas - 影像膨脹
- Mahotas - 影像腐蝕
- Mahotas - 分水嶺演算法
- Mahotas - 影像開運算
- Mahotas - 影像閉運算
- Mahotas - 填充影像空洞
- Mahotas - 條件膨脹影像
- Mahotas - 條件腐蝕影像
- Mahotas - 影像條件分水嶺演算法
- Mahotas - 影像區域性最小值
- Mahotas - 影像區域最大值
- Mahotas - 影像區域最小值
- Mahotas - 高階概念
- Mahotas - 影像閾值化
- Mahotas - 設定閾值
- Mahotas - 軟閾值
- Mahotas - Bernsen區域性閾值化
- Mahotas - 小波變換
- 建立影像小波中心
- Mahotas - 距離變換
- Mahotas - 多邊形工具
- Mahotas - 區域性二值模式
- 閾值鄰域統計
- Mahotas - Haralick 特徵
- 標記區域的權重
- Mahotas - Zernike 特徵
- Mahotas - Zernike 矩
- Mahotas - 排序濾波器
- Mahotas - 二維拉普拉斯濾波器
- Mahotas - 多數濾波器
- Mahotas - 均值濾波器
- Mahotas - 中值濾波器
- Mahotas - Otsu 方法
- Mahotas - 高斯濾波
- Mahotas - Hit & Miss 變換
- Mahotas - 標記最大值陣列
- Mahotas - 影像均值
- Mahotas - SURF 密集點
- Mahotas - SURF積分影像
- Mahotas - Haar 變換
- 突出顯示影像最大值
- 計算線性二值模式
- 獲取標籤邊界
- 反轉 Haar 變換
- Riddler-Calvard 方法
- 標記區域的大小
- Mahotas - 模板匹配
- 加速魯棒特徵
- 移除帶邊界的標記
- Mahotas - Daubechies 小波
- Mahotas - Sobel 邊緣檢測
Mahotas - 獲取標籤邊界
獲取標籤邊界是指提取標記影像的邊界畫素。邊界可以定義為畫素位於影像邊緣的區域。邊界表示影像不同區域之間的過渡。
獲取標籤邊界涉及識別標記影像中的邊界區域並將它們與背景分離。
由於標記影像僅包含前景畫素和背景畫素,因此邊界很容易識別,因為它們位於背景區域的旁邊。
在 Mahotas 中獲取標籤邊界
在 Mahotas 中,我們可以使用`**mahotas.labeled.borders()**` 函式來獲取標籤的邊界。它分析標記影像的相鄰畫素並考慮連線模式以獲取邊界。
`mahotas.labeled.borders()` 函式
`mahotas.labeled.borders()` 函式以標記影像作為輸入,並返回一個帶有突出顯示邊界的影像。
在結果影像中,邊界畫素的值為 1,並且是前景的一部分。
語法
以下是 Mahotas 中 `borders()` 函式的基本語法:
mahotas.labeled.borders(labeled, Bc={3x3 cross}, out={np.zeros(labeled.shape, bool)})
其中:
`**labeled**` - 輸入的標記影像。
`**Bc (可選)**` - 用於連線的結構元素。
`**out (可選)**` - 輸出陣列(預設為與 `labeled` 形狀相同的新的陣列)。
示例
在下面的示例中,我們使用 `mh.labeled.borders()` 函式獲取標籤的邊界。
import mahotas as mh import numpy as np import matplotlib.pyplot as mtplt # Loading the image image = mh.imread('nature.jpeg', as_grey=True) # Applying thresholding image = image > image.mean() # Converting it to a labeled image labeled, num_objects = mh.label(image) # Geting border of labels borders = mh.labeled.borders(labeled) # Creating a figure and axes for subplots fig, axes = mtplt.subplots(1, 2) # Displaying the labeled image axes[0].imshow(labeled) axes[0].set_title('Labeled Image') axes[0].set_axis_off() # Displaying the borders axes[1].imshow(borders) axes[1].set_title('Border Labels') axes[1].set_axis_off() # Adjusting spacing between subplots mtplt.tight_layout() # Showing the figures mtplt.show()
輸出
以下是上述程式碼的輸出:

使用自定義結構元素獲取邊界
我們還可以使用自定義結構元素來獲取標籤的邊界。結構元素是一個僅包含 1 和 0 的陣列。它用於定義相鄰畫素的連線結構。
包含在連線分析中的畫素值為 1,而被排除的畫素值為 0。
在 Mahotas 中,我們使用 `mh.disk()` 函式建立一個自定義結構元素。然後,我們將此自定義結構元素設定為 `borders()` 函式中的 `Bc` 引數以獲取標籤的邊界。
示例
這裡,我們使用自定義結構元素獲取標籤的邊界。
import mahotas as mh import numpy as np import matplotlib.pyplot as mtplt # Loading the image image = mh.imread('sea.bmp', as_grey=True) # Applying thresholding image = image > image.mean() # Converting it to a labeled image labeled, num_objects = mh.label(image) # Geting border of labels borders = mh.labeled.borders(labeled, mh.disk(5)) # Creating a figure and axes for subplots fig, axes = mtplt.subplots(1, 2) # Displaying the labeled image axes[0].imshow(labeled) axes[0].set_title('Labeled Image') axes[0].set_axis_off() # Displaying the borders axes[1].imshow(borders) axes[1].set_title('Border Labels') axes[1].set_axis_off() # Adjusting spacing between subplots mtplt.tight_layout() # Showing the figures mtplt.show()
輸出
上述程式碼的輸出如下:

廣告