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 1 year has passed since last update.

画像の対角部分を表示

Last updated at Posted at 2023-03-14

画像の対角部分を自由な幅で表示

画像処理をしていく過程で、対角部分を自由な幅で表示したい時用のメモとして保存しておきます。

code

# ライブラリのインポート
import cv2
from google.colab.patches import cv2_imshow
import numpy as np


# 画像の読み込み
path = ("Your image path")
img = cv2.imread(path)


# 読み込んだ画像をグレースケール化
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# 対角部分だけを表示する関数を定義
def show_diag(img, k_v):
  img_gray_tril = np.tril(img, k=k_v)
  img_gray_tril = np.triu(img_gray_tril, k=-k_v)
  # img_gray_tril
  return cv2_imshow(img_gray_tril)

# imageを表示する
show_diag(100)

結果

結果は、以下になります。
(*参考画像:https://www.irasutoya.com/2021/01/luffy.html)

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?