Yukii's Blog

  • Scraps
  • V2

  1. Home
  2. Scraps
  3. 大津の二値化法

大津の二値化法

グレースケールの画像を白黒に変換したい時などに利用。 ある閾値で2つのクラスに分割するとき、クラスの分散の加重平均を最小化する手法。

OpenCV では、 `cv2.threshold` の引数などにて指定可能。

src: https://ja.wikipedia.org/wiki/%E5%A4%A7%E6%B4%A5%E3%81%AE%E4%BA%8C%E5%80%A4%E5%8C%96%E6%B3%95

Related Scraps:

OpenCV

画像は、BGR 系であるとする。 一方、 Matplotlib は RGB 系を想定する。 形式変換のためには、 np.flip(img, axis=-1) を実行すると良い。

cv2.HoughLines

cv2.Houghlines(img, rho, theta, thres)
  • (rho, theta): グリッド化する (r,θ)(r, \theta)(r,θ) の最小単位
  • thres: 投票回数の閾値

ハフ変換

r=xcos⁡(θ)+ysin⁡(θ)r = x \cos(\theta) + y \sin(\theta)r=xcos(θ)+ysin(θ)

代表的なのは、上記式による直線の検出手法。

線分検知

OpenCV においては、 Line Segment Detector と houghLinesP が割と汎用的に利用できそう。

---2022/10/06


© 2018-2022 Yukii