<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Setting Up Data
We use Image module from Python Imaging library to digitize 2-d plot from Uttley et al. (2014)
Step1:  Initialize an intensity array.
Step2:  Below, we retrieve each pixel and then calculate darkness value. The perceived brightness is given by
Step3:  Invert along Y-axis to account for some conventions.
<ASSISTANT_TASK:>
Python Code:
from PIL import Image
im = Image.open('2d.png')
width, height = im.size
Explanation: Setting Up Data
We use Image module from Python Imaging library to digitize 2-d plot from Uttley et al. (2014)
End of explanation
intensity = np.array([[1 for j in range(width)] for i in range(height)])
Explanation: Initialize an intensity array.
End of explanation
for x in range(0, height):
    for y in range(0, width):
        RGB = im.getpixel((y, x))
        intensity[x][y] = (0.2126 * (255-RGB[0]) + 0.7152 * (255-RGB[1]) + 0.0722 * (255-RGB[2]))
Explanation: Below, we retrieve each pixel and then calculate darkness value. The perceived brightness is given by:
0.2126R + 0.7152G + 0.0722*B
To get darkness, the formula is corrected as follows:
0.2126(255-R) + 0.7152(255-G) + 0.0722*(255-B)
End of explanation
intensity = intensity[::-1]
np.savetxt('intensity.txt', intensity)
Explanation: Invert along Y-axis to account for some conventions.
End of explanation
<END_TASK>