Applied Data Analysis in Python

In [1]:
import numpy as np
from pandas import DataFrame, Series
from skimage import io

photo = io.imread("https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/Swallow-tailed_bee-eater_%28Merops_hirundineus_chrysolaimus%29.jpg/768px-Swallow-tailed_bee-eater_%28Merops_hirundineus_chrysolaimus%29.jpg")

photo = np.array(photo, dtype=np.float64) / 255  # Scale values
w, h, d = original_shape = tuple(photo.shape)  # Get the current shape
image_array = np.reshape(photo, (w * h, d))  # Reshape to to 2D

pixels = DataFrame(image_array, columns=["Red", "Green", "Blue"])
In [2]:
pixels.corr()
Out[2]:
Red Green Blue
Red 1.000000 0.85383 0.749801
Green 0.853830 1.00000 0.781750
Blue 0.749801 0.78175 1.000000