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 7962563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:22:19+00:00 2026-06-04T05:22:19+00:00

In pygame, I have a surface: im = pygame.image.load(‘foo.png’).convert_alpha() im = pygame.transform.scale(im, (64, 64))

  • 0

In pygame, I have a surface:

im = pygame.image.load('foo.png').convert_alpha()
im = pygame.transform.scale(im, (64, 64))

How can I get a grayscale copy of the image, or convert the image data to grayscale? I have numpy.

  • 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-06-04T05:22:20+00:00Added an answer on June 4, 2026 at 5:22 am

    Use a Surfarray, and filter it with numpy or Numeric:

    def grayscale(self, img):
        arr = pygame.surfarray.array3d(img)
        #luminosity filter
        avgs = [[(r*0.298 + g*0.587 + b*0.114) for (r,g,b) in col] for col in arr]
        arr = numpy.array([[[avg,avg,avg] for avg in col] for col in avgs])
        return pygame.surfarray.make_surface(arr)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PyGame, I get flickering things. Boxes, circles, text, it all flickers. I can
I have image.I am trying to load a button on it.The image I'm loading
I have a pygame Surface and would like to invert the colors. Is there
I have been trying to get the pygame module to work with python3 in
So I have been fooling around with Pygame and have run into a problem
So with pygame you have a while loop that loops continuously, then your event
I have used PyGame for a while now, and quite enjoyed doing so, but
I'm working on a pygame project and have the main engine layed out. The
I have a customized version of SDL 1.2 and pygame 1.9.1 that implement SDL2's
I'm trying to learn pygame, And I found the best way to have the

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.