imshow() and pixel intensity

Hi all,

Just trying to understand how the value of the matrix fed to imshow()
function determines the intensity of the pixel in grey scale mode.
Consider the example code:

import random
import matplotlib.pyplot as plt
import matplotlib.cm as cm

def pixels(n=3):
    pixel_data = []
    for _ in range(n):
        row = []
        for _ in range(n):
            row.append(random.randint(1, 10))
        pixel_data.append(row)
    return pixel_data

if __name__ == '__main__':
    pixel_data = pixels()
    print(pixel_data)
    plt.imshow(pixel_data, origin='lower', cmap=cm.Greys_r)
    plt.show()

The pixel_data here is the 3*3 "matrix":
[[7, 4, 6], [7, 7, 6], [4, 7, 9]]

How does the values here determine what shade of grey I see in the image?

Thank you in advance.

Best,
Amit.

···

--
http://echorand.me

Got my answer here:

···

On Sun, May 17, 2015 at 10:02 PM, Amit Saha <amitsaha.in@...287...> wrote:

Hi all,

Just trying to understand how the value of the matrix fed to imshow()
function determines the intensity of the pixel in grey scale mode.
Consider the example code:

import random
import matplotlib.pyplot as plt
import matplotlib.cm as cm

def pixels(n=3):
    pixel_data =
    for _ in range(n):
        row =
        for _ in range(n):
            row.append(random.randint(1, 10))
        pixel_data.append(row)
    return pixel_data

if __name__ == '__main__':
    pixel_data = pixels()
    print(pixel_data)
    plt.imshow(pixel_data, origin='lower', cmap=cm.Greys_r)
    plt.show()

The pixel_data here is the 3*3 "matrix":
[[7, 4, 6], [7, 7, 6], [4, 7, 9]]

How does the values here determine what shade of grey I see in the image?

Thank you in advance.

Best,
Amit.

--
http://echorand.me

--