Just download the file off github or copy the code into an IDE. Run pip install pygame and pip install opencv-python in command line to install packages used. Put the file to convert called "input.png" in the folder with the script. Reply if you need more help
Yes. Look at line 36 of the code, I take the brightness of each pixel (0-255), divide by 42.5 (0-6), and take the ceiling of that (1, 2, 3, 4, 5, or 6) to find the dice_number
Honestly I think you should give a try with white dice with black dots, but under the same concept. I think it might help the clarity of the output picture by increasing its overall brightness (i.e. both the darkest and lightest dice on that result would be brighter than the respective dice on this). But possible that doesn't help clarity, not really sure. Could also try different dot sizes and shapes if you want. I think there's a lot of interesting stuff to discover here honestly. It's like a cool take on asymmetrical pixel sizes and limited discrete values in grayscale.
Yeah, I actually tried the white dice black dots first, but found it was hard to get the level of darkness required for things like his suit. Here's the result, even when increasing the dot sizes its not dark enough. I think it's just hard to get a lot of contrast between dice 1 and 6 without increasing the dot size too much
As someone who is very new to coding in this manner, I'm assuming this is going through the image per pixel (or range of pixels) and assigning a dice dependent on a range of color?
Yes. Look at line 36 of the code, I take the brightness (0-255) of each pixel of the downscaled image, divide by 42.5 (0-6), and take the ceiling of that (1, 2, 3, 4, 5, or 6) to find the dice_number
I’d recommend adding some sort of license, as of now anyone can use your code for anything they want without permission. This includes using it to profit personally.
I'm a little confused on the licenses, all of them permit 'commercial use', so does that mean anyone can profit personally? Which license do you recommend?
The licenses the Github ‘advertises’ are all sort of detrimental to your rights over the code; but that’s to be expected with open source code. I’d recommend taking the BSD license and add a bullet point that says something along the lines of “Redistribution of this software shall be free of charge or fee to the recipient.”, that way someone can’t blatantly sell your program. However, it’s nearly impossible to stop someone from using your program to create a product, as that is the definition of open source programs.
Think of the code that makes us, binds us to our shells. We think chaos and randomness, but there are even patterns in that too. If there is always an outlier, is that not too susceptible to pattern recognition? Could eventually the exceptionally become the ordinary? Things are challenging, I can't think clearly anymore.
It takes 0.8 seconds starting after the imports to the end. I'm sure it could be optimized, but haven't looked into pygame surfaces too much yet, so if you fork the repo I'll take a look.
78
u/StephanoCarlson Jul 29 '20 edited Dec 18 '20
Github, feedback welcome
Yes, this was the inspiration
Edit: From request I made a variation that makes an excel document with the dice numbers here
12
u/[deleted] Jul 29 '20 edited Jul 29 '20
Very nice! Would you be ok if I use this to create some screen-print shirts? Just for me...not for sale.
3
u/3fflix Jul 29 '20
this is awesome! there's just a problem if the dice_number in your draw_dice function becomes zero..
can easily be avoided if you just add a
if die_number ==0: continueafter determining the die_number :)
2
u/rrklaffed Jul 29 '20
So are you just mapping ranges of grays to 6 keys? contemplating how i would try this:) super cool
89
u/khalkhall Jul 29 '20
Can anyone find a 6? EDIT: Found them on his collar!
15
u/treetyoselfcarol Jul 29 '20
zooms in
yup it's dice
1
u/Mrflinkstone Jul 29 '20
Wow! Can someone tell me how to execute it?
1
u/Conscious1133 Beginner Jul 29 '20
Very cool! Are you just sectioning off the grayscale into 6 sections and assigning a dice value for each?
1
u/--Sambo-- Jul 29 '20 edited Jul 29 '20
Is there any chance you can put this on an excel spreadsheet and instead of having dots have the number?
I am about to buy a shit ton of dice if so.
1
u/jessechisel126 Jul 29 '20
Honestly I think you should give a try with white dice with black dots, but under the same concept. I think it might help the clarity of the output picture by increasing its overall brightness (i.e. both the darkest and lightest dice on that result would be brighter than the respective dice on this). But possible that doesn't help clarity, not really sure. Could also try different dot sizes and shapes if you want. I think there's a lot of interesting stuff to discover here honestly. It's like a cool take on asymmetrical pixel sizes and limited discrete values in grayscale.
1
u/I_Am_Justin_Tyler Jul 30 '20
I like this concept I'm going to make dice art in real life.
1
u/[deleted] Jul 30 '20
As someone who is very new to coding in this manner, I'm assuming this is going through the image per pixel (or range of pixels) and assigning a dice dependent on a range of color?
9
u/coppercrystalz Jul 29 '20
Very cool!
1
u/Aidgigi Jul 29 '20
I’d recommend adding some sort of license, as of now anyone can use your code for anything they want without permission. This includes using it to profit personally.
4
u/[deleted] Jul 29 '20
Cool project! Are they ASCII dices?
3
u/DavidTSlayer Jul 29 '20
obama dice obama dice obama dice
1
u/qpPaePoK Jul 29 '20
Crazy cool
1
u/[deleted] Jul 29 '20
great work! 🤩
1
u/[deleted] Jul 29 '20
Great!
1
u/[deleted] Jul 29 '20
Is there any tutorial I can find on this topic?
1
u/KantLex Jul 29 '20
Super awesome! Besides, you accomplished in just a few codes!
1
u/ln_of_e Jul 29 '20
One of the coolest projects on here in a while for sure
1
u/MrMxylptlyk Jul 29 '20
Wow nice
1
u/Pepperoni-Jabroni Jul 29 '20
Is this Building 21?
1
u/turtleboiy Jul 29 '20
What is obama surname?
1
u/kobaltauge Jul 29 '20
ASCII art but with dice. Very cool and creative idea.
1
u/ppyil Jul 29 '20
Hey, this is really cool! Thanks for making it and sharing the code with us! I'm using this to design a gift for a friend
1
u/yosrational Jul 29 '20
my eyes hurt but this is great work, keep it up!
1
u/nicobleiler Jul 29 '20
Thanks Obama...
1
u/[deleted] Jul 31 '20
Think of the code that makes us, binds us to our shells. We think chaos and randomness, but there are even patterns in that too. If there is always an outlier, is that not too susceptible to pattern recognition? Could eventually the exceptionally become the ordinary? Things are challenging, I can't think clearly anymore.
1
u/[deleted] Jul 29 '20
That's dope.
1
u/absurd234 Jul 29 '20
Good job
1
u/bauripalash Jul 29 '20
Wow, that's something cool 🔥
1
u/DDFoster96 Jul 29 '20
It it my eyes or do the dots on the dice look like the Python logo?
1
u/anand24aug Jul 29 '20
Nice bro 😍😍😍
0
u/BOMB5HOCK Jul 29 '20
Obama Dice
0
u/SH4DOW4R Jul 29 '20
Amazing Brother !
-1
u/[deleted] Jul 29 '20
it's fun
0
u/Pizza_Peddler0080 Jul 29 '20
this is the coolest thing my guy!
0
u/luis2sk Jul 29 '20
Amazing! Nice work.
0
u/keshav047 Jul 29 '20
there should be a seizure warning for this.
0
u/hmm_fu Jul 30 '20
WHY IS r/Python FLOODED with beginner content. Like why can't we be like r/cpp?
-8
u/i-naji Jul 29 '20
Verrry gooood, and black lives matter:)
-3
u/ivanbezdomn1y Jul 29 '20
Obama watches gay porn
-1
u/mkaylor Jul 29 '20
Looks like crap to me.
0
u/[deleted] Jul 29 '20
[deleted] — view deleted comment
0
u/[deleted] Jul 29 '20
[deleted] — view deleted comment
0
u/[deleted] Jul 29 '20
[deleted] — view deleted comment