前提・実現したいこと
AnacondaでOpenCVを使用して画像を拡大する。
その際にOpenCVのresize()関数を使用しないで作成する。
発生している問題・エラーメッセージ
黒い画像が作成される。 for文をどこに設置し、どう書くか。
該当のソースコード
python
1import numpy as np 2import cv2 3 4# read image file 5img_src = cv2.imread('pompom.jpg') 6#width=421,height=427の画像である。 7 8# print the full numpy array 9np.set_printoptions(threshold=np.inf) 10 11 12# get height and width 13height, width = img_src.shape[:2] 14print(height, width) 15 16width = 842 17height = 854 18img_src = np.zeros((height, width, 3), np.uint8) 19 20 21# output image file 22cv2.imwrite('3-1.jpg', img_src)
試したこと
width=842から3行削除すると元の画像が作成された。
この画像の大きさは842×854である。
補足情報(FW/ツールのバージョンなど)
任意の画像を読みこんでサイズを取得
2×2倍のサイズの画増を作成し、そこに画素値をコピーしていく。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/10/03 16:45