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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:55:57+00:00 2026-05-28T06:55:57+00:00

So far I’ve come up with following: screen_array = pygame.surfarray.pixels2d(self.screen) noise_small = numpy.random.random((self.width/4,self.height/4)) *

  • 0

So far I’ve come up with following:

screen_array = pygame.surfarray.pixels2d(self.screen)
noise_small = numpy.random.random((self.width/4,self.height/4)) * 0.2 + 0.4
noise_big = noise_small .repeat(4, 0).repeat(4, 1)
screen_array *= noise_big

But this adds separate noise on every channel.

I know I could also use pygame.surfarray.pixels3d and then numpy.tile the noise array, but that’s way too slow for me (well, what I’m doing now is also pretty slow, but nevermind that).

  • 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-28T06:55:57+00:00Added an answer on May 28, 2026 at 6:55 am

    Each element in the array returned by pygame.surfarray.pixels2d is a number obtained by packing the 3 channels into a single integer, and I don’t know of a simple method to take advantage of the array structure to do a fast and simple multiplication with this.

    However, I still think your best bet is to use pygame.surfarray.pixels3d, but not to use numpy.tile. You could do something like this :

        screen_array = pygame.surfarray.pixels3d(self.screen)
        noise_small = numpy.random.random((self.width/4,self.height/4)) * 0.2 + 0.4
        noise_big = noise_small .repeat(4, 0).repeat(4, 1)
        screen_array *= noise_big[:, :, numpy.newaxis]
    

    Notice the [:, :, numpy.newaxis]. This reshape the noise_big to be of shape (X, Y, 1) instead of (X, Y), which allows direct multiplication with the screen_array object, having shape (X, Y, 3). When that happens, the single element of the third axis is multiplied with all 3 channels. This way of tackling the problem is more efficient than using numpy.tile.

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

Sidebar

Related Questions

As far as i know it is not possible to do the following in
So far, I've tried the following: public class Widget { public int Id; public
So far I have used the following statements in SQLAlchemy to implement table inheritance
So far i have the following code, but it doesn't seem to be working,
So far I've got the following regex that matches against regular domains but not
Far as best practices are concerned, which is better: public void SomeMethod(string str) {
As far as I know, foreign keys (FK) are used to aid the programmer
So far I have encountered adjacency list, nested sets and nested intervals as models
As far as I know, Flash has to pass info off to another external
As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...)

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.