NumPy - Why Logo has a Cube in it?
NumPy Logo - A Cube which correctly describes the essence of NumPy

NumPy - Why Logo has a Cube in it?

Most of us who use NumPy Library of Python may often wonder,

Why the Logo of NumPy Library has a Cube showing in it?

Have you ever thought how come our digital screen is so much colorful? Well in the context of Digital Screen which is a set of Pixels arranged in a Tabular form, a single pixel may take 16,777,216 different colors. This is because each pixel is a combination of 256 Intensity Levels of Red,?Green?and?Blue.


An Image comprising of 32 Rows of Pixels and 32 Columns of Pixel (Pixel Size: 32 x 32) [image - a]

The Color of a Pixel shall be White if the intensity of Red, Green and Blue is at Maximum i.e. 255 and Color of an Image shall be Black if intensity of all three components of RGB Color System is 0, which indicates an absence of Color.


An Image of Pixel Size 3 x 3 - A Total of 9 Pixels [image - b]

The Pixels that are Red have an RGB Color Code of (255, 0, 0) while pixels that are Green have an RGB Color Code of (0, 255, 0). Similarly, Pixels that are Blue in Color have an RGB Color Code of (0, 0, 255).

I always wondered how a Pixel accommodates the Intensity of 3 Colors and gives the Resultant Color on screen. Well, it turns out that it is basically a 3D Cube with one side exposed to us.


Visual Representation of Pixel on a Screen shows Colors [image - c]

It is quite similar to the NumPy 3-Dimensional Array. Infact we can store the Data of Pixel Colors in a 3-Dimensional NumPy Array.

# Importing NumPy Library
import numpy as np

# Importing Matplotlib Library
import matplotlib.pyplot as plt
 
# Creating a 3-Dimensional NumPy Array and assigning the Variable 'image' to it
image = np.array([[[255, 0, 0], [0, 255, 0], [0, 0, 255]],
                              [[0, 255, 0], [0, 0, 255], [255, 0, 0]],
                              [[0, 0, 255], [255, 0, 0], [0, 255, 0]]])

# Plotting the Image via Data stored in NumPy Array
plt.imshow(image)        

The Code above shall display an Image which shall be identical to [image - b].

Similarly, in order to have an Image of Pixel Size 3 x 3, with all Pixels white in Color, each component of the RGB Code of all the pixel needs to at the maximum.

# Importing NumPy Library
import numpy as np

# Importing Matplotlib Library
import matplotlib.pyplot as plt
 
# Creating a 3-Dimensional NumPy Array and assigning the Variable 'image' to it
image = np.array([[[255, 255, 255], [255, 255, 255], [255, 255, 255]],
                              [[255, 255, 255], [255, 255, 255], [255, 255, 255]],
                              [[255, 255, 255], [255, 255, 255], [255, 255, 255]]])

# Plotting the Image via Data stored in NumPy Array
plt.imshow(image)        

The Screen shall display Complete White Image as a result of this Code. Let us Visualize the entire background of how NumPy is storing the Data.


Visual Representation of Pixel on a Screen showing White [image - d]

This is just one of the Example how NumPy may help us in storing "Data". The Pixel RGB Color Code Intensity is indeed "Data".

If this article was able to help in understanding a new concept or just gave you a reminder of what you already knew. I would humbly request you to share and like it.

My YouTube Channel: Haris Jafri -YT Channel

My LinkedIn Profile: Haris Jafri - LinkedIn Profile

I love to study, write and teach, so if you have an idea, do let me know!

Shujah Ullah

Digital Control Systems || OT || IT || AI || ML || Cyber Security

5 个月

ND Array using Numpy is superb.

要查看或添加评论,请登录

Haris Jafri的更多文章

  • Capitalize Digital World

    Capitalize Digital World

    An idea keeps coming into my mind again and again. I will not say that it is disturbing me, but it is rather good to…

  • Prone to Societal Pressure

    Prone to Societal Pressure

    Good to write after such a long time. I often think, what should have more priority? The Destination or The Journey.

  • How Pakistani Companies can Survive the Upcoming Inflation?

    How Pakistani Companies can Survive the Upcoming Inflation?

    Now this article definitely shows some sort of frustration I am carrying with myself over quite some time now. But I…

  • What is a Tender in Business Terms?

    What is a Tender in Business Terms?

    A tender is a formal request for a proposal, quotation, or bid to supply goods or services. It is typically used in the…

  • Your Social Circle

    Your Social Circle

    Making friends with people who want the best for you can be one of the most rewarding and fulfilling experiences in…

  • Construction Industry - United Kingdom

    Construction Industry - United Kingdom

    The construction industry in the United Kingdom is a significant contributor to the country's economy, with a total…

  • Stay on Path

    Stay on Path

    I still remember it like yesterday! Aziz is a good friend of mine from University who called me in 2010 and told me…

  • Care! It is a Human Instinct!

    Care! It is a Human Instinct!

    Probably the only thing that helped, me and my wife survive the trauma of 4 Year Old Child death was Care. When I…

  • Build Community

    Build Community

    I was watching a Movie named "Defiance", starring Daniel Craig acting in the role of Tuvia Belsky. A Jew running in the…

  • Processed Food!

    Processed Food!

    Here I was with my wife driving towards the Maternity Hospital for delivery. It was a happy day, it was raining or…

社区洞察

其他会员也浏览了