相关疑难解决方法(0)

仅使用numpy调整图像的对比度

我正在尝试为灰度颜色的图像编写对比度调整,但到目前为止找不到正确的方法。这是我想出的:

import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from scipy import misc
def fix_contrast(image):
    minimumColor = np.amin(image)
    maximumColor = np.amax(image)
    #avg = (minimumColor - maximumColor)/2 first attempt
    avg = np.mean(image) #second attempt
    colorDownMatrix = image < avg # also tried
    colorUpMatrix = image > avg 
    #also tried:   colorUpMatrix = image > avg * 1.2
    # and : colorDownMatrix = image < avg* 0.3

    image = image - minimumColor*colorDownMatrix
    image = image + maximumColor*colorUpMatrix
    lessThen0 = …
Run Code Online (Sandbox Code Playgroud)

python numpy python-3.x

1
推荐指数
2
解决办法
4214
查看次数

标签 统计

numpy ×1

python ×1

python-3.x ×1