0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

numpy で画像(2D data)からバウンディングボックスを求めるメモ

Posted at

背景

nunmpy で画像の部分領域のバウンディングボックスを求めたい.

ピクセルがあるしきい値を超えている画像領域を求めたいとか.

方法

numpy.where あたりを使います.

where では条件にマッチしたインデックスが帰ってくるので, それの端を取れば bound min/max が求まります.

ただ, where だといくらか効率悪いぽいようなので, bounding box のように最終的に bmin/bmax の配列インデックスが取得できればいい場合は. argwhere or nonzero を使うのがよさそうです.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?