[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I do not frequent /g/ but even with I have seen multiple of
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 34
Thread images: 6
File: everypossiblephoto1.jpg (79 KB, 620x431) Image search: [Google]
everypossiblephoto1.jpg
79 KB, 620x431
I do not frequent /g/ 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 http://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.
>>
>>54533261
bump
>>
>>54533399
last try bump
>>
>>54533261
this is interesting
>>
>>54533619
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.
>>
>>54533638
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.

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

>>54533669
Could you point me in the right direction? All I'm finding is image processing and the likes.
>>
>>54533261
lol you think /g/ 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 http://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.
>>
>>54533261
explain and i might be of help. Why did you choose 5x5 in particular?
>>
>>54533735
>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.
>>
File: Capture.png (26 KB, 924x668) Image search: [Google]
Capture.png
26 KB, 924x668
Here's all the 2x2 ones

I'll try 5x5 in a bit
>>
>>54533770
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.

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

>>54533857
What is going on here? Because it looks like you've done it all already
>>
>>54533893
>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.
>>
>>54533893
I'll have a go too OP. Cool programming puzzle.
>>
File: Capture.png (33 KB, 924x668) Image search: [Google]
Capture.png
33 KB, 924x668
Turns out there's an easier way to do it with the Tuples function.
>>
>>54533759
>>54533784
Pillow looks like the more idiot friendly version, which I definitely need. I'm starting now.

>>54534154
Nice, I hope you have more experience than me, as I'm a wee bit over my head.
>>
>>54533261
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: http://stackoverflow.com/questions/3325546/how-to-color-a-pixel
>>
>>54533261
https://en.wikipedia.org/wiki/Netpbm_format
>>
>>54534239
That's what I'm working with with Pillow.

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

>>54534182
Can those images be saved? I'm not familiar with Mathematica
>>
File: 3x3.gif (115 KB, 64x64) Image search: [Google]
3x3.gif
115 KB, 64x64
>>54534302
>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}]]
>>
>>54534432
That's really neat. How much can you do with Mathematica if you have pretty basic programming knowledge? is it worth paying for?
>>
>>54534432
Neato
>>
File: Capture.png (19 KB, 1187x350) Image search: [Google]
Capture.png
19 KB, 1187x350
>>54534802
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.
>>
File: double.gif (949 KB, 360x364) Image search: [Google]
double.gif
949 KB, 360x364
>Here's code for finding and animating the trajectory of a double-pendulum
And here's the resulting animation in case you're interested.
>>
>>54533261
Here you go OP, I'm >>54533759

#!/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.
>>
>>54535247

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()
>>
>>54535247
>>54535861
Jesus, thanks anon, 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.

>>54535031
>>54535208
That is incredibly interesting, and also way out of my knowledge base.
>>
>>54533261
You are literally just counting up a 32 bit int and then storing the lowest 25 bits of it in a 5x5 image.
>>
>>54536190
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.
>>
>>54536237
I am literally incapable of higher thought, and programming isn't my field.

>>54536292
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?
>>
>>54536237
SAVAGE
>>
>>54533857
Not OP, but is this matlab?
>>
>>54537833
according to >>54534302 it is mathematica.
>>
>>54536237
D..DELETE THIS
Thread replies: 34
Thread images: 6

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.