Page 166 - python
P. 166

140




                            red = int(r**(1/gamma))

                            green = int(g**(1/gamma))
                            blue = int(b**(1/gamma))
                            img2.putpixel((x,y),(red,green,blue))
                    gamma = 0.7

                    img3 = Image.new("RGB", (img1.size[0], img1.size[1]), "white")
                    for x in range(0, img1.size[0]):
                         for y in range(0, img1.size[1]):

                            r,g,b = list(img1.getpixel((x,y)))
                            red = int(r**(1/gamma))
                            green = int(g**(1/gamma))
                            blue = int(b**(1/gamma))
                            img3.putpixel((x,y),(red,green,blue))


                    fig = plt.figure(figsize=(10,5))

                    ax = fig.add_subplot(1,3,1)
                    ax.imshow(img1)
                    ax.set_title('Original')


                    ax1 = fig.add_subplot(1,3,2)

                    ax1.imshow(img2)
                    ax1.set_title('Gamma 0.8')

                    ax2 = fig.add_subplot(1,3,3)

                    ax2.imshow(img3)
                    ax2.set_title('Gamma 0.7')
                    plt.show()


                   ผลลัพธ :














                                    ภาพประกอบที่ 11.9 แสดงผลลัพธการปรับคาแกมมาของภาพ
   161   162   163   164   165   166   167   168   169   170   171