10
10

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.

薄い画像をハッキリさせる

Posted at

概要

薄い画像をハッキリさせる必要があったので、いろいろ調べた。
まずはビフォーアフター

ビフォー

predict_raw_03.jpg

アフター

predict_03.jpg

動作環境

  • Ubuntu 16.04.4 LTS
  • Python 3.5.2
  • chainer 4.0.0
  • numpy 1.14.2
  • cupy 4.0.0
  • opencv-python 3.4.0.12

ソースコード

def cleary(img, clip_limit=3, grid=(8, 8), thresh=225):
    clahe = cv2.createCLAHE(clipLimit=clip_limit, tileGridSize=grid)
    dst = clahe.apply(img)
    th = dst.copy()
    th[dst > thresh] = 255
    return th

CLAHEによるヒストグラム調整

CLAHE(Contrast Limited Adaptive Histogram Equalization)を利用することでいい感じにコントラストを調整することができる。

clahe = cv2.createCLAHE(clipLimit=clip_limit, tileGridSize=grid)
dst = clahe.apply(img)

CLAHE解説

ノイズ除去

numpyのしきい値処理を実行することで白をよりくっきり強調できる。

th = dst.copy()
th[dst > thresh] = 255

以上。

10
10
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
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?