使用Qimage的pixel遍历像素点提示越界

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
def adjustContrast(image:QImage, value) -> QImage:
    width, height = image.width(), image.height()
    newImage = QImage(width, height, QImage.Format_RGBA8888)
    if value >= 0:
        value = 1 / (1 - value / 100.0) - 1
    else:
        value /= 100.0
    for h in range(height):
        for w in range(width):
            pixel = QColor(image.pixel(w, h))
            color = [bound(0, 255, (c - 127) * value + c) for c in [pixel.red(), pixel.green(), pixel.blue()]]
            newImage.setPixel(w, h, qRgba(*color, pixel.alpha()))
    return newImage

运行结果及报错内容

我看pixel传入的是int类型,也没有范围限制,不明白坐标为什么会超出范围

img

我的解答思路和尝试过的方法
我想要达到的结果