img = QPixmap.grabWindow(QApplication.desktop().winId(), x=0, y=100, height
    =20, width=20).toImage()
for x in range(0, 20):
    for y in range(0, 20):
        c = img.pixel(x, y)
colors = QColor(c).getRgbF()
print('(%s,%s) = %s' % (x, y, colors))
How to get RGB values of QPixmap or QImage pixel - Qt, PyQt