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

  • SEARCH
  • Home
  • 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 4037216
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:19:11+00:00 2026-05-20T12:19:11+00:00

I have a black and white image which every pixel values are loaded as

  • 0

I have a black and white image which every pixel values are loaded as a nested list with numpy (2948×1536). What i need to do is to grab the pixels from that list in a checkerboard pattern. So I need to extract pixels like this :

0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
….

How would this be done ? Is this a good idea to use a nested list for such a job ? If not, what would you suggest ?

Image processing is quite new to me.

Any help would be greatly appreciated,

  • 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-20T12:19:12+00:00Added an answer on May 20, 2026 at 12:19 pm

    Let’s use smaller dimensions so the result is easier to see:

    import numpy as np
    # w=2948
    # h=1536
    w=6
    h=4
    arr=np.arange(w*h).reshape(w,h)
    print(arr)
    print(arr.shape)
    # [[ 0  1  2  3]
    #  [ 4  5  6  7]
    #  [ 8  9 10 11]
    #  [12 13 14 15]
    #  [16 17 18 19]
    #  [20 21 22 23]]
    # (6, 4)
    

    We can construct a boolean array in a checkerboard pattern:

    coords=np.ogrid[0:w,0:h]
    idx=(coords[0]+coords[1])%2 == 1
    print(idx)
    print(idx.shape)
    # [[False  True False  True]
    #  [ True False  True False]
    #  [False  True False  True]
    #  [ True False  True False]
    #  [False  True False  True]
    #  [ True False  True False]]
    # (6, 4)
    

    Using this boolean array for indexing, we can extract the values we desire:

    checkerboard=arr[idx].reshape(w,h//2)
    print(checkerboard)
    print(checkerboard.shape)
    # [[ 1  3]
    #  [ 4  6]
    #  [ 9 11]
    #  [12 14]
    #  [17 19]
    #  [20 22]]
    # (6, 2)
    

    PS. Inspiration for this answer came from Ned Batchelder’s answer here.

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

Sidebar

Related Questions

I have a grayscale image, which I convert to black and white image, and
I have a black-white tiff image with 15369x15360 pixels and 8 bit depth now
I have an image which consists of two arbitrarily placed black 1px blobs on
What I am supposed to do. I have an black and white image (100x100px):
I have here an black/white png file of the dimensions 2156x1728 which I want
I have an image (5x5)pixels with 3 values which value 0, 128, and 255.
How can I draw a rectangle that have a black border and white background?
i have a programm that creates a black border an white corner (quadrangle). now
Say i have those 3 arrays : Product(milk,candy,chocolate) Colors(white,red,black) Rating(8,7,9) How to create a
I want my Spinner to have a black gradient background with white text on

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.