I do not frequent Sup Forums but even with I have seen multiple of versions of this thread here...

I do not frequent Sup Forums but even with I have seen multiple of versions of this thread here, but I can't seem to find any more info.

Lets say, I want to generate every 5x5, 2 color image. This will be 2^25 or 33,554,432.

According to jan.ucc.nau.edu/lrm22/pixels2bytes/calculator.htm
A 1 bit color depth with a resolution of 5x5 will have a file size of 3.125 bytes. That means that the total size of these images will only be 104,857,600 bytes, or in better terms 104.8576 mb.

So, the question, how would I do this?
I have basic experience in java and /very/ basic experience in python.

Other urls found in this thread:

netpbm.sourceforge.net/doc/ppm.html
stackoverflow.com/questions/3325546/how-to-color-a-pixel
en.wikipedia.org/wiki/Netpbm_format
twitter.com/SFWRedditGifs

bump

last try bump

this is interesting

you make all the possible 5x5 matrices and then convert them to image files?

learn how to use image libraries for the language of your choice, you big dummy. It's literally as simple as that and maybe some nested for loops.

This thread has happened before, but usually OP is an idiot and wants to make all 1920x1080 pictures or something, and it never gets into how would it would be coded, just how it's impractical.

>all the possible 5x5 matrices
would that be a bit impractical?

Could you point me in the right direction? All I'm finding is image processing and the likes.

lol you think Sup Forums is actually full of smart problem solvers, that's cute. This board is mostly shitposting about consumer hardware.

Anyway, you could use the Plain PPM image format to do this. It's a text-based representation of colors and pixels, the spec is at netpbm.sourceforge.net/doc/ppm.html

Write a python script which iterates over a few range()s of the color depth you want, you'll get text output of a single image in PPM format.

If you want to convert that to PNG or something, you can use ImageMagick's "convert" utility.

I have done this to generate images of random black and white noise, it works well.

explain and i might be of help. Why did you choose 5x5 in particular?

>Could you point me in the right direction? All I'm finding is image processing and the likes.

I don't use either language, but Pillow looks like what you're looking for in Python.

Here's all the 2x2 ones

I'll try 5x5 in a bit

Because anything bigger than that (ex 6x6) would be 2^36 images which total size would be 214.7483648 gb, which is a teeny bit out of my reach.

Thanks will take a look and try to make something work, will update.

What is going on here? Because it looks like you've done it all already

>What is going on here?
Mathematica has a function for transforming matrices into images (python has one two called implot in matplotlib I think). I just made all the 2x2 binary matrices with the Table function and mapped said image function over it.

I'll have a go too OP. Cool programming puzzle.

Turns out there's an easier way to do it with the Tuples function.

Pillow looks like the more idiot friendly version, which I definitely need. I'm starting now.

Nice, I hope you have more experience than me, as I'm a wee bit over my head.

The class java.awt.BufferedImage has a method setRGB(int x, int y, int rgb) which sets the color of an individual pixel. Additionally, you might want to look at java.awt.Color, especially its getRGB() method, which can convert Colors into integers that you can put into the int rgb parameter of setRGB.

Source: stackoverflow.com/questions/3325546/how-to-color-a-pixel

en.wikipedia.org/wiki/Netpbm_format

That's what I'm working with with Pillow.

That'd most likely be easier for me but I'm going to try do this in python.

Can those images be saved? I'm not familiar with Mathematica

>Can those images be saved?
Yeah you can even make a GIF with them.

Export["3x3.gif", ImageResize[Image[#], {64, 64}] & /@ Tuples[{0, 1}, {3, 3}]]

That's really neat. How much can you do with Mathematica if you have pretty basic programming knowledge? is it worth paying for?

Neato

You can do a lot. It has pros and cons like any other language but it has a lot of really well made and useful standard library functions like that Export which handles a shitload of different file formats.

Plus it's fully symbolic when it comes to math so you can do stuff like derivatives and integrals no problem. Here's code for finding and animating the trajectory of a double-pendulum that I did a while back.

I'm not sure how much it costs or if the price is worth it; I pirated it. If you don't want to do that, Raspbian comes with a free copy so you could probably boot up a VM and use it there.

>Here's code for finding and animating the trajectory of a double-pendulum
And here's the resulting animation in case you're interested.

Here you go OP, I'm #!/usr/bin/python

for imagenum in range(33554432):
filename = "image"+str(imagenum).zfill(8)+".ppm"
file = open(filename, "w")

pixels = bin(imagenum)[2:].zfill(25)
file.write("P3 5 5 1\n")

for pixel in range(len(pixels)):
if (pixel % 5) == 0:
file.write("\n")
thisrow = " {0} {1} {2} ".format(pixels[pixel], pixels[pixel], pixels[pixel])
file.write(thisrow)
file.write("\n")
file.close()


These are in PPM format like I described. If you want PNG then:

for file in *.ppm; do convert "$file" "${file%.ppm}.png"; rm "$file"; done


I'm sure Pythonic Pythonistas will take issue with my crap code, but it works.

Sorry that will generate you one more image than you want. Here's a version which can generate all 1-bit images of any dimensions:

#!/usr/bin/python
# make every 5x5 image
dimension = 5

number_of_images = ((2**dimension)**dimension) - 1
namepadlen = len(str(number_of_images))
pixpadlen = len(str(bin(number_of_images)[2:]))

for imagenum in range(number_of_images):
filename = "img" + str(imagenum).zfill(namepadlen) + ".ppm"
file = open(filename, "w")
file.write("P3 {0} {0} 1\n".format(dimension, dimension))

pixels = bin(imagenum)[2:].zfill(pixpadlen)
for pixel in range(len(pixels)):
if (pixel % dimension) == 0:
file.write("\n")
thisrow = " {0} {1} {2} ".format(pixels[pixel], pixels[pixel], pixels[pixel])
file.write(thisrow)
file.write("\n")
file.close()

Jesus, thanks user, you just saved me an hour or 2 of fumbling around.
So in ppm format that'll be 6.610223104 gb and in png Id assume much less.

As well as a fun mess around experiment, I have an idea on what to do with these that I believe may be very interesting. More of a muh psychology kind of thing but it might be fun. I'm on #pasta on Rizon if you wish to see what becomes of it, I have to sleep now, and thanks again for straight up doing it for me.

That is incredibly interesting, and also way out of my knowledge base.

You are literally just counting up a 32 bit int and then storing the lowest 25 bits of it in a 5x5 image.

No worries

Sorry, second version has a bug too, you'll need to change
for imagenum in range(number_of_images):

to:
for imagenum in range(number_of_images+1):

to generate the all-white image.

Also, file size is tricky. Despite the fact each file is only a few bytes, an individual file consumes an entire file block, which is usually 4 KiB.

If my calculations are correct, you'll need 128 GiB to store every 5x5 image.

I am literally incapable of higher thought, and programming isn't my field.

Thanks again, but on file size, I generated the first 50k or so ppm and they all were 197 bytes, I'm assuming I'm missing something?

SAVAGE

Not OP, but is this matlab?

according to it is mathematica.

D..DELETE THIS