1. 程式人生 > >基於Matlab的標記分水嶺分割演算法(imreconstruct)

基於Matlab的標記分水嶺分割演算法(imreconstruct)

1 綜述

Separating touching objects in an image is one of the more difficult image processing operations. The watershed transform is often applied to this problem. The watershed transform finds "catchment basins"(集水盆) and "watershed ridge lines"(山脊線) in an image by treating it as a surface where light pixels are high and dark pixels are low.

如果影象中的目標物體是連線在一起的,則分割起來會更困難,分水嶺分割演算法經常用於處理這類問題,通常會取得比較好的效果。分水嶺分割演算法把影象看成一幅“地形圖”,其中亮度比較強的區域畫素值較大,而比較暗的區域畫素值較小,通過尋找“匯水盆地”和“分水嶺界限”,對影象進行分割。

Segmentation using the watershed transform works better if you can identify, or "mark," foreground objects and background locations. Marker-controlled watershed segmentation follows this basic procedure:

直接應用分水嶺分割演算法的效果往往並不好,如果在影象中對前景物件和背景物件進行標註區別,再應用分水嶺演算法會取得較好的分割效果。基於標記控制的分水嶺分割方法有以下基本步驟:

1. Compute a segmentation function. This is an image whose dark regions are the objects you are trying to segment.

1.計算分割函式。影象中較暗的區域是要分割的物件。

2. Compute foreground markers. These are connected blobs of pixels within each of the objects.

2.計算前景標誌。這些是每個物件內部連線的斑點畫素。

3. Compute background markers. These are pixels that are not part of any object.

3.計算背景標誌。這些是不屬於任何物件的畫素。

4. Modify the segmentation function so that it only has minima at the foreground and background marker locations.

4.修改分割函式,使其僅在前景和後景標記位置有極小值。

5. Compute the watershed transform of the modified segmentation function.

5.對修改後的分割函式做分水嶺變換計算。

Use by Matlab Image Processing Toolbox

使用MATLAB影象處理工具箱

注:期間用到了很多影象處理工具箱的函式,例如fspecial、imfilter、watershed、label2rgb、imopen、imclose、imreconstruct、imcomplement、imregionalmax、bwareaopen、graythresh和imimposemin函式等。

2 步驟

Step 1: Read in the Color Image and Convert it to Grayscale

第一步:讀入彩色影象,將其轉化成灰度影象

clc; clear all; close all;

rgb = imread('pears.png');

if ndims(rgb) == 3

    I = rgb2gray(rgb);

else

    I = rgb;

end

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 2, 1); imshow(rgb); title('原圖');

subplot(1, 2, 2); imshow(I); title('灰度圖');

基於Matlab的標記分水嶺分割演算法 

Step 2: Use the Gradient Magnitude as the Segmentation Function

第2步:將梯度幅值作為分割函式

Use the Sobel edge masks, imfilter, and some simple arithmetic to compute the gradient magnitude. The gradient is high at the borders of the objects and low (mostly) inside the objects.

使用Sobel邊緣運算元對影象進行水平和垂直方向的濾波,然後求取模值,sobel運算元濾波後的影象在邊界處會顯示比較大的值,在沒有邊界處的值會很小。

hy = fspecial('sobel');

hx = hy';

Iy = imfilter(double(I), hy, 'replicate');

Ix = imfilter(double(I), hx, 'replicate');

gradmag = sqrt(Ix.^2 + Iy.^2);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 2, 1); imshow(I,[]), title('灰度影象')

subplot(1, 2, 2); imshow(gradmag,[]), title('梯度幅值影象')

基於Matlab的標記分水嶺分割演算法 

Can you segment the image by using the watershed transform directly on the gradient magnitude?

可否直接對梯度幅值影象使用分水嶺演算法?

L = watershed(gradmag);

Lrgb = label2rgb(L);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 2, 1); imshow(gradmag,[]), title('梯度幅值影象')

subplot(1, 2, 2); imshow(Lrgb); title('梯度幅值做分水嶺變換')

基於Matlab的標記分水嶺分割演算法 

No. Without additional preprocessing such as the marker computations below, using the watershed transform directly often results in "oversegmentation."

直接使用梯度模值影象進行分水嶺演算法得到的結果往往會存在過度分割的現象。因此通常需要分別對前景物件和背景物件進行標記,以獲得更好的分割效果。

Step 3: Mark the Foreground Objects

第3步:標記前景物件

A variety of procedures could be applied here to find the foreground markers, which must be connected blobs of pixels inside each of the foreground objects. In this example you'll use morphological techniques called "opening-by-reconstruction" and "closing-by-reconstruction" to "clean" up the image. These operations will create flat maxima inside each object that can be located using imregionalmax.

有多種方法可以應用在這裡來獲得前景標記,這些標記必須是前景物件內部的連線斑點畫素。這個例子中,將使用形態學技術“基於開的重建”和“基於閉的重建”來清理影象。這些操作將會在每個物件內部建立單位極大值,使得可以使用imregionalmax來定位。

開運算和閉運算:先腐蝕後膨脹稱為開;先膨脹後腐蝕稱為閉。開和閉這兩種運算可以除去比結構元素小的特定影象細節,同時保證不產生全域性幾何失真。開運算可以把比結構元素小的突刺濾掉,切斷細長搭接而起到分離作用;閉運算可以把比結構元素小的缺口或孔填充上,搭接短的間隔而起到連線作用。

Opening is an erosion followed by a dilation, while opening-by-reconstruction is an erosion followed by a morphological reconstruction. Let's compare the two. First, compute the opening using imopen.

開操作是腐蝕後膨脹,基於開的重建(基於重建的開操作)是腐蝕後進行形態學重建。下面比較這兩種方式。首先,用imopen做開操作。

se = strel('disk', 20);

Io = imopen(I, se);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 2, 1); imshow(I, []); title('灰度影象');

subplot(1, 2, 2); imshow(Io), title('影象開操作')

基於Matlab的標記分水嶺分割演算法 

Next compute the opening-by-reconstruction using imerode and imreconstruct.

接下來,通過腐蝕後重建來做基於開的重建計算。

Ie = imerode(I, se);

Iobr = imreconstruct(Ie, I);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 2, 1); imshow(I, []); title('灰度影象');

subplot(1, 2, 2); imshow(Iobr, []), title('基於開的重建影象')

基於Matlab的標記分水嶺分割演算法 

Following the opening with a closing can remove the dark spots and stem marks. Compare a regular morphological closing with a closing-by-reconstruction. First try imclose:

開操作後,接著進行閉操作,可以移除較暗的斑點和枝幹標記。對比常規的形態學閉操作和基於閉的重建操作。首先,使用imclose:

Ioc = imclose(Io, se);

Ic = imclose(I, se);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(2, 2, 1); imshow(I, []); title('灰度影象');

subplot(2, 2, 2); imshow(Io, []); title('開操作影象');

subplot(2, 2, 3); imshow(Ic, []); title('閉操作影象');

subplot(2, 2, 4); imshow(Ioc, []), title('開閉操作');

基於Matlab的標記分水嶺分割演算法 


Now use imdilate followed by imreconstruct. Notice you must complement the image inputs and output of imreconstruct. IM2 = imcomplement(IM) computes the complement(補集) of the image IM. IM can be a binary, intensity, or RGB image. IM2 has the same class and size as IM.

現在使用imdilate,然後使用imreconstruct。注意必須對輸入影象求補,對imreconstruct輸出影象求補。IM2 = imcomplement(IM)計算影象IM的補集。IM可以是二值影象,或者RGB影象。IM2與IM有著相同的資料型別和大小。

Iobrd = imdilate(Iobr, se);

Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));

Iobrcbr = imcomplement(Iobrcbr);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(2, 2, 1); imshow(I, []); title('灰度影象');

subplot(2, 2, 2); imshow(Ioc, []); title('開閉操作');

subplot(2, 2, 3); imshow(Iobr, []); title('基於開的重建影象');

subplot(2, 2, 4); imshow(Iobrcbr, []), title('基於閉的重建影象');

基於Matlab的標記分水嶺分割演算法 

As you can see by comparing Iobrcbr with Ioc, reconstruction-based opening and closing are more effective than standard opening and closing at removing small blemishes without affecting the overall shapes of the objects. Calculate the regional maxima of Iobrcbr to obtain good foreground markers.

通過比較Iobrcbr和loc可以看到,在移除小汙點同時不影響物件全域性形狀的應用下,基於重建的開閉操作要比標準的開閉重建更加有效。計算Iobrcbr的區域性極大來得到更好的前景標記。

fgm = imregionalmax(Iobrcbr);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 3, 1); imshow(I, []); title('灰度影象');

subplot(1, 3, 2); imshow(Iobrcbr, []); title('基於重建的開閉操作');

subplot(1, 3, 3); imshow(fgm, []); title('區域性極大影象');

基於Matlab的標記分水嶺分割演算法 

To help interpret the result, superimpose(疊加) the foreground marker image on the original image.

為了幫助理解這個結果,疊加前景標記到原圖上。

It1 = rgb(:, :, 1);

It2 = rgb(:, :, 2);

It3 = rgb(:, :, 3);

It1(fgm) = 255; It2(fgm) = 0; It3(fgm) = 0;

I2 = cat(3, It1, It2, It3);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(2, 2, 1); imshow(rgb, []); title('原影象');

subplot(2, 2, 2); imshow(Iobrcbr, []); title('基於重建的開閉操作');

subplot(2, 2, 3); imshow(fgm, []); title('區域性極大影象');

subplot(2, 2, 4); imshow(I2); title('區域性極大疊加到原影象');

基於Matlab的標記分水嶺分割演算法 

Notice that some of the mostly-occluded and shadowed objects are not marked, which means that these objects will not be segmented properly in the end result. Also, the foreground markers in some objects go right up to the objects' edge. That means you should clean the edges of the marker blobs and then shrink them a bit. You can do this by a closing followed by an erosion.

注意到大多閉塞處和陰影物件沒有被標記,這就意味著這些物件在結果中將不會得到合理的分割。而且,一些物件的前景標記會一直到物件的邊緣。這就意味著應該清理標記斑點的邊緣,然後收縮它們。可以通過閉操作和腐蝕操作來完成。

se2 = strel(ones(5,5));

fgm2 = imclose(fgm, se2);

fgm3 = imerode(fgm2, se2);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(2, 2, 1); imshow(Iobrcbr, []); title('基於重建的開閉操作');

subplot(2, 2, 2); imshow(fgm, []); title('區域性極大影象');

subplot(2, 2, 3); imshow(fgm2, []); title('閉操作');

subplot(2, 2, 4); imshow(fgm3, []); title('腐蝕操作');

基於Matlab的標記分水嶺分割演算法 

This procedure tends to leave some stray isolated pixels that must be removed. You can do this using bwareaopen, which removes all blobs that have fewer than a certain number of pixels. BW2 = bwareaopen(BW,P) removes from a binary image all connected components (objects) that have fewer than P pixels, producing another binary image, BW2.

這個過程將會留下一些偏離的孤立畫素,應該移除它們。可以使用bwareaopen,用來移除少於特定畫素個數的斑點。BW2 = bwareaopen(BW,P)從二值影象中移除所以少於P畫素值的連通塊,得到另外的二值影象BW2。

fgm4 = bwareaopen(fgm3, 20);

It1 = rgb(:, :, 1);

It2 = rgb(:, :, 2);

It3 = rgb(:, :, 3);

It1(fgm4) = 255; It2(fgm4) = 0; It3(fgm4) = 0;

I3 = cat(3, It1, It2, It3);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(2, 2, 1); imshow(I2, []); title('區域性極大疊加到原影象');

subplot(2, 2, 2); imshow(fgm3, []); title('閉腐蝕操作');

subplot(2, 2, 3); imshow(fgm4, []); title('去除小斑點操作');

subplot(2, 2, 4); imshow(I3, []); title('修改區域性極大疊加到原影象');

基於Matlab的標記分水嶺分割演算法 

Step 4: Compute Background Markers

Now you need to mark the background. In the cleaned-up image, Iobrcbr, the dark pixels belong to the background, so you could start with a thresholding operation.

第4步:計算背景標記

現在,需要標記背景。在清理後的影象Iobrcbr中,暗畫素屬於背景,所以可以從閾值操作開始。

bw = im2bw(Iobrcbr, graythresh(Iobrcbr));

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 2, 1); imshow(Iobrcbr, []); title('基於重建的開閉操作');

subplot(1, 2, 2); imshow(bw, []); title('閾值分割');



基於Matlab的標記分水嶺分割演算法 


The background pixels are in black, but ideally we don't want the background markers to be too close to the edges of the objects we are trying to segment. We'll "thin" the background by computing the "skeleton by influence zones", or SKIZ, of the foreground of bw. This can be done by computing the watershed transform of the distance transform of bw, and then looking for the watershed ridge lines (DL == 0) of the result. D = bwdist(BW) computes the Euclidean distance transform of the binary image BW. For each pixel in BW, the distance transform assigns a number that is the distance between that pixel and the nearest nonzero pixel of BW. bwdist uses the Euclidean distance metric by default. BW can have any dimension. D is the same size as BW.

背景畫素在黑色區域,但是理想情形下,不必要求背景標記太接近於要分割的物件邊緣。通過計算“骨架影響範圍”來“細化”背景,或者SKIZ,bw的前景。這個可以通過計算bw的距離變換的分水嶺變換來實現,然後尋找結果的分水嶺脊線(DL==0)。D = bwdist(BW)計算二值影象BW的歐幾里得矩陣。對BW的每一個畫素,距離變換指定畫素和最近的BW非零畫素的距離。bwdist預設使用歐幾里得距離公式。BW可以由任意維數,D與BW有同樣的大小。

D = bwdist(bw);

DL = watershed(D);

bgm = DL == 0;

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(2, 2, 1); imshow(Iobrcbr, []); title('基於重建的開閉操作');

subplot(2, 2, 2); imshow(bw, []); title('閾值分割');

subplot(2, 2, 3); imshow(label2rgb(DL), []); title('分水嶺變換示意圖');

subplot(2, 2, 4); imshow(bgm, []); title('分水嶺變換脊線圖');

基於Matlab的標記分水嶺分割演算法 

Step 5: Compute the Watershed Transform of the Segmentation Function.

The function imimposemin can be used to modify an image so that it has regional minima only in certain desired locations. Here you can use imimposemin to modify the gradient magnitude image so that its only regional minima occur at foreground and background marker pixels.

第5步:計算分割函式的分水嶺變換

函式imimposemin可以用來修改影象,使其只是在特定的要求位置有區域性極小。這裡可以使用imimposemin來修改梯度幅值影象,使其只在前景和後景標記畫素有區域性極小。

gradmag2 = imimposemin(gradmag, bgm | fgm4);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(2, 2, 2); imshow(fgm4, []); title('前景標記');

subplot(2, 2, 3); imshow(gradmag, []); title('梯度幅值影象');

subplot(2, 2, 4); imshow(gradmag2, []); title('修改梯度幅值影象');

基於Matlab的標記分水嶺分割演算法 

Finally we are ready to compute the watershed-based segmentation.

最後,可以做基於分水嶺的影象分割計算。

Step 6: Visualize the Result

One visualization technique is to superimpose the foreground markers, background markers, and segmented object boundaries on the original image. You can use dilation as needed to make certain aspects, such as the object boundaries, more visible. Object boundaries are located where L == 0.

第6步:檢視結果

一個視覺化技術是疊加前景標記、背景標記、分割物件邊界到初始影象。可以使用膨脹來實現某些要求,比如物件邊界,更加清晰可見。物件邊界定位於L==0的位置。

It1 = rgb(:, :, 1);

It2 = rgb(:, :, 2);

It3 = rgb(:, :, 3);

fgm5 = imdilate(L == 0, ones(3, 3)) | bgm | fgm4;

It1(fgm5) = 255; It2(fgm5) = 0; It3(fgm5) = 0;

I4 = cat(3, It1, It2, It3);

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 2, 1); imshow(rgb, []); title('原影象');

subplot(1, 2, 2); imshow(I4, []); title('標記和物件邊緣疊加到原影象');

基於Matlab的標記分水嶺分割演算法 

This visualization illustrates how the locations of the foreground and background markers affect the result. In a couple of locations, partially occluded darker objects were merged with their brighter neighbor objects because the occluded objects did not have foreground markers.

視覺化說明了前景和後景標記如何影響結果。在幾個位置,部分的較暗物件與它們相鄰的較亮的鄰接物件相融合,這是因為受遮擋的物件沒有前景標記。

Another useful visualization technique is to display the label matrix as a color image. Label matrices, such as those produced by watershed and bwlabel, can be converted to truecolor images for visualization purposes by using label2rgb.

另外一個有用的視覺化技術是將標記矩陣作為彩色影象進行顯示。標記矩陣,比如通過watershed和bwlabel得到的,可以使用label2rgb轉換到真彩圖像來顯示。

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 2, 1); imshow(rgb, []); title('原影象');

subplot(1, 2, 2); imshow(Lrgb); title('彩色分水嶺標記矩陣');

基於Matlab的標記分水嶺分割演算法 

You can use transparency to superimpose this pseudo-color label matrix on top of the original intensity image.

可以使用透明度來疊加這個偽彩色標記矩陣在原亮度影象上進行顯示。

figure('units', 'normalized', 'position', [0 0 1 1]);

subplot(1, 2, 1); imshow(rgb, []); title('原影象');

subplot(1, 2, 2); imshow(rgb, []); hold on;

himage = imshow(Lrgb);

set(himage, 'AlphaData', 0.3);

title('標記矩陣疊加到原影象');

基於Matlab的標記分水嶺分割演算法 

總結

程式碼:

clc; clear all; close all;

rgb = imread('pears.png');

if ndims(rgb) == 3

    I = rgb2gray(rgb);

else

    I = rgb;

end

hy = fspecial('sobel');

hx = hy';

Iy = imfilter(double(I), hy, 'replicate');

Ix = imfilter(double(I), hx, 'replicate');

gradmag = sqrt(Ix.^2 + Iy.^2);

L = watershed(gradmag);

Lrgb = label2rgb(L);

se = strel('disk', 20);

Io = imopen(I, se);

Ie = imerode(I, se);

Iobr = imreconstruct(Ie, I);

Ioc = imclose(Io, se);

Iobrd = imdilate(Iobr, se);

Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));

Iobrcbr = imcomplement(Iobrcbr);

fgm = imregionalmax(Iobrcbr);

It1 = rgb(:, :, 1);

It2 = rgb(:, :, 2);

It3 = rgb(:, :, 3);

It1(fgm) = 255; It2(fgm) = 0; It3(fgm) = 0;

I2 = cat(3, It1, It2, It3);

se2 = strel(ones(5,5));

fgm2 = imclose(fgm, se2);

fgm3 = imerode(fgm2, se2);

fgm4 = bwareaopen(fgm3, 20);

It1 = rgb(:, :, 1);

It2 = rgb(:, :, 2);

It3 = rgb(:, :, 3);

It1(fgm4) = 255; It2(fgm4) = 0; It3(fgm4) = 0;

I3 = cat(3, It1, It2, It3);

bw = im2bw(Iobrcbr, graythresh(Iobrcbr));

D = bwdist(bw);

DL = watershed(D);

bgm = DL == 0;

gradmag2 = imimposemin(gradmag, bgm | fgm4);

L = watershed(gradmag2);

It1 = rgb(:, :, 1);

It2 = rgb(:, :, 2);

It3 = rgb(:, :, 3);

fgm5 = imdilate(L == 0, ones(3, 3)) | bgm | fgm4;

It1(fgm5) = 255; It2(fgm5) = 0; It3(fgm5) = 0;

I4 = cat(3, It1, It2, It3);

Lrgb = label2rgb(L, 'jet', 'w', 'shuffle');

相關推薦

基於Matlab標記分水嶺分割演算法(imreconstruct)

1 綜述 Separating touching objects in an image is one of the more difficult image processing operations. The watershed transform is often a

基於標記符的分水嶺分割演算法

-------------------------------------------------------------------------------------------------------------------- 附錄A&nbs

matlab之watershed分水嶺分割演算法

Separating touching objects in an image is one of the more difficult image processing operations. The watershed transform is often app

Matlab學習筆記】【數學形態學】分水嶺分割演算法

分水嶺演算法的概念及原理: 分水嶺分割方法,是一種基於拓撲理論的數學形態學的分割方法,其基本思想是把影象看作是測地學上的拓撲地貌,影象中每一點畫素的灰度值表示該點的海拔高度,每一個區域性極小值及其影響區域稱為集水盆,而集水盆的邊界則形成分水嶺。分水嶺的概念和形成可以通過模擬浸入過程來說明。在每一個區域性

opencv學習筆記五十六:分水嶺分割演算法

一、基於分水嶺的分割演算法是受自然界地貌啟發而來的對灰度圖的地形學解釋,我們考慮以下三點: 1. 區域性最小值點,該點對應一個盆地的最低點,當我們在盆地裡滴一滴水的時候,由於重力作用,水最終會匯聚到該點。注意:可能存在一個最小值面,該平面內的都是最小值點。 2. 盆地的其

Python之opencv 分水嶺分割演算法

分水嶺分割演算法 分水嶺分割演算法的定義網上隨便百度一下就可以知道了,我就說一下我的理解,有不對的希望大家也可以幫忙指正。 對於分水嶺分割,我的理解是,一幅影象是由不同大小的灰度級畫素值構成的,可以把不同的大小想象成不同高度的山脈,接著在地表(就是從畫素灰度

opencv分水嶺分割演算法C++是

#include #include #include #include #include "watershedsegmenter.h"using namespace std;using namespace cv;int

基於MATLAB的模擬退火演算法求解TSP問題

旅行商問題,即TSP問題(Travelling Salesman Problem)又譯為旅行推銷員問題、貨郎擔問題,是數學領域中著名問題之一。假設有一個旅行商人要拜訪n個城市,他必須選擇所要走的路徑,路徑的限制是每個城市只能拜訪一次,而且最後要回到原來出發的城市

基於邊緣的影象分割——分水嶺演算法(watershed)演算法分析(附opencv原始碼分析)

最近需要做一個影象分割的程式,查了opencv的原始碼,發現opencv裡實現的影象分割一共有兩個方法,watershed和mean-shift演算法。這兩個演算法的具體實現都在segmentation.cpp檔案內。 watershed(分水嶺演算法)方法是一種基於邊界點

影象分割演算法基於梯度分水嶺分割演算法

程式碼實現:import matplotlib.pyplot as plt from scipy import ndimage as ndi from skimage import morphology,color,data,filters import cv2 # ima

基於八叉樹的區域增長點雲分割演算法

該篇文章出自2015年ICIP會議,主要介紹影象分割領域一種新的區域生長演算法  [TOC] 參考:https://blog.csdn.net/cjx2lxj/article/details/50529618  提出的問題 鐳射雷達探測到城市環境的物體表面構成三維幾何

基於深度學習的影象語義分割演算法綜述(截止20180715)

這篇文章講述卷積神經網路在影象語義分割(semantic image segmentation)的應用。影象分割這項計算機視覺任務需要判定一張圖片中特定區域的所屬類別。 這個影象裡有什麼?它在影象中哪個位置? 更具體地說,影象語義分割的目標是將影象的每個畫素所

基於MATLAB的Sobel邊緣檢測演算法實現

  影象邊緣就是影象灰度值突變的地方,也就是影象在該部分的畫素值變化速度非常之快,就比如在座標軸上一條曲線有剛開始的平滑突然來個大轉彎,在變化出的導數非常大。 Sobel運算元主要用作邊緣檢測,它是一離散型差分運算元,用來計算影象亮度函式灰度之近似值。   邊緣是指其周圍

基於MATLAB的dijkstra演算法及其應用

clc; clear; close all; %% 載入設定資料 points = load('c:\\niu\\點的資料.txt'); lines = load('c:\\niu\\邊資料.txt'); A = ones(size(points, 1))*Inf; for i = 1 : size(A, 1

基於OpenCV和C++實現最大閾值分割演算法

程式碼如下:: /********************************************************************************************************** *檔案說明: * 基於Ope

基於最大穩定區域的影象分割演算法

面向灰度圖的最大穩定區域分割演算法最早由J. Matas在BMVC2002上提出,題目為Robust wide-baseline stereo from maximally stable extremal regions 演算法流程如下 1. 對於所有畫素按

基於深度學習的影象語義分割演算法綜述

   作者: 葉  虎            編輯:趙一帆           前  言本文翻譯

基於MATLAB的djikstra演算法實現

clc; clear; close all; %% 載入設定資料 points = load('c:\\niu\\點的資料.txt'); lines = load('c:\\niu\\邊資料.txt'); A = ones(size(points, 1))*Inf; for i = 1 : size(A, 1

點雲分割基於邊界的分割演算法(一)

基於邊界的點雲分割演算法通過檢測區域邊界得到分割塊。主要演算法有: 一、通過點雲強度的劇烈變化得到點雲邊界; 二、計算邊界梯度,計算點雲表面的法矢方向梯度變化以及3D線匹配; 三、對於距離影象的掃描線分割演算法,但不適用於密度不均勻的點雲資料。 四、通過

基於並查集+Kruskal演算法matlab程式及最小生成樹繪圖

學了一天最小生成樹,稍稍總結一下,這是第一篇 kruskal演算法 關於kruskal演算法已有大量的資料,不再贅述,演算法流程為: 得到鄰接矩陣和權值; 初始化,連線距離最小的兩點; 連線距離次小的兩點,如果形成迴路則取消連線;重複上述連線步驟,直到所