Creating noise images with Python and OpenGL

  • Context: Python 
  • Thread starter Thread starter Avatrin
  • Start date Start date
  • Tags Tags
    Images Noise Python
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 2K views
Avatrin
Messages
242
Reaction score
6
Hi

I am learning how to do a line integral convolution with OpenGL given a vector field. So, as a first step, I need to learn how to create an nxn noise image. Are there any good tutorials/books I can use to learn how to do this?
 
Physics news on Phys.org
Here's one way:

Python:
import random
n=3
nxn = [[random.random() for i in range(n)] for j in range(n)]

You can replace random.random() with an expression to magnify the random values as random.random() values vary from 0.0 to 1.0

so 5*randomrandom() will give you a spread of 0.0 to 5.0

and (5*randomrandom()+3) will give you a range of 3.0 to 8.0 as examples.
 
  • Skeptical
Likes   Reactions: Avatrin
Alright, but this doesn't output an image. That's why I am asking for a tutorial or a book; I am not sure a forum post is going to tell me how to create images with OpenGL.