2017-07-20 28 views
0

scikit-imageで検出された等高線にバウンディングボックスを描画する方法を見つけようとしましたが、scikit-imageメソッドのfind_contoursが座標点の2次元配列を返すため、何も見つかりませんでした検出された輪郭のScikit-Imageで検出された輪郭にバウンディングボックスを描画する方法は?

+0

あなたが検出された輪郭の配列に最小 - とmax-coordnates(x、y)を得ることができます。今度は、そのためのバウンディングボックスを生成します。 – KimKulling

+0

@KimKullingしたがって、始点として(x、y)を取り、開始点にランダムな値を加えて終点にすることによって、バウンディングボックスを描画することを提案しています。 しかし、サイクリング画像で輪郭の領域を見つける方法はありますか? – maheshkumar

+1

ギャラリーには検出された輪郭を描画する方法の例が含まれています:http://scikit-image.org/docs/dev/auto_examples/edges/plot_contours.html#sphx-glr-auto-examples-edges-plot-contours-pyまた、ボックス描画機能も実装しています。 –

答えて

2

あなたのイメージに境界を描画するコードのこの部分を使用することができます。

# Loop through contours and draw the bounds in red 
contours = skimage.measure.find_contours(img, level) 

for contour in contours: 
    img = drawShape(img, contour, [255, 0, 0]) 

def drawShape(img, coordinates, color) 
    # In order to draw our line in red 
    img = skimage.color.gray2rgb(img) 

    # Make sure the coordinates are expressed as integers 
    coordinates = coordinates.astype(int) 

    img[coordinates[:, 0], coordinates[:, 1]] = color 

    return img 
関連する問題