圖像亮度調整
撰寫一個程式從檔案讀取一張圖像,將圖像的每一個點像素的值各加上一個整數值 v
(-255 <= v <= 255),並將圖像儲存至一個新圖像檔案中。
使用環境:
Windows 10
Python 3.8
opencv-python 4.5.1.48
實作方法:
- 用imread()讀取資料夾中的圖片
- 再依照使用者輸入的值用迴圈先判斷像素值是否溢位,若是溢位了,大於255的話將上限值調為255,若小於0的話下限值調為0,若像素值沒有溢位則將值加入在圖片中每個像素點中
- 用imwrite將調過後的圖像另存起來
- 用imshow()將圖片展示於視窗中
執行結果:



沒有留言:
張貼留言