Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7406807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:36:49+00:00 2026-05-29T05:36:49+00:00

For example, a 3 pixel by 3 pixel jpeg image of a checkerboard should

  • 0

For example, a 3 pixel by 3 pixel jpeg image of a checkerboard should be something like

[[#000000, #FFFFFF, #000000],
[#FFFFFF, #000000, #FFFFFF],
[#000000, #FFFFFF, #000000]]

I feel like I may need to download PIL, but I cannot tell what the module does from their website. I also need to be able to generate images from these types of arrays. Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:36:50+00:00Added an answer on May 29, 2026 at 5:36 am

    Use the Image.getdata method. The method returns a generator that you can iterate over:

    from PIL import Image
    img = Image.open("a.png")
    data = img.getdata()
    for (r, g, b, a) in data:
        # do something with the pixel values
    

    To go the other way you use Image.putdata. This generates a tiny checkerboard picture:

    >>> img = Image.new("L", (3, 3))
    >>> data = [0, 255, 0, 255, 0, 255, 0, 255, 0]
    >>> img.putdata(data)
    >>> img.save("checkerboard.png")
    

    Here I created a grayscale image (only one “luminescence” channel) and so I just used a single integer value for each pixel.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, I have an 1024*768 JPEG image. I want to estimate the size
How can I get bits per pixel in bitmap image? example if pixel x=24
I need to put a view (a image for example) in a custom point
Does setWidth(int pixels) use device independent pixel or physical pixel as unit? For example,
I need an example algorithm that will draw pixels one at a time on
I am changing color values of each pixel in an image based on a
When i read a grayscaled image using for example in Opencv 2.3: Mat src
Is it possible to create a 1 pixel shadow image (say shadow.jpg) in photoshop,
For example I have a pixel with these values: CGFloat red = 34 //
Example: http://jsfiddle.net/xUrDc/ I'm trying to surround each li with a border exactly one pixel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.