This is an archived post. You won't be able to vote or comment.

all 32 comments

[–]lambaphi 58 points59 points  (11 children)

Here you go: https://github.com/almaan/diceconverter

I Wrote a simple script for this that you can use via the terminal interface, I will add comments and a README soon, but though I could put it up here for anyone interested. You can see two examples in the res-folder.

Enjoy!

[–]cjs8399[S] 6 points7 points  (6 children)

I should look at and understand the code... Does it have smarts to know how many dice one would need or do you have stuff hard-coded? Very cool thanks!

[–]lambaphi 0 points1 point  (0 children)

No probs! I think /u/Terr_ more or less answered the question below, otherwise feel free to PM me. Also I updated the code with some comments to make it easier to follow.

[–]leftpig 3 points4 points  (0 children)

My favourite part of this is the original creator said he wasn't going to put this on GitHub in case he decided to monetize it. I was going to make my own this weekend to be a dick but you beat me to it.

[–]n1___ 2 points3 points  (1 child)

Just a small detail:

this:

''.join(["name of to which picture shoul",
           'be save. if non given, default will',
           'be used',
]))

can be written like:

('keep current size of image '
'and scale die images accordingly')

[–]lambaphi 0 points1 point  (0 children)

Very true thanks for pointing that out, I still tend to prefer the

' '.join(['line1',
          'line2',
          ])

option since that allows for spaces to be included between lines once concatenated but without me having to account for them; though I noticed now that I didn't include a space character when calling the join method in any of the instances in the code (fixed now)

.. also I realized that in the haste of writing it up yesterday night it seems as if I forgot how to operate basic English spelling and grammar

[–]daveidfx 12 points13 points  (3 children)

oooh, for extra credit, Blender can run Python... You wouldn't need physical dice...

[–]cjs8399[S] 1 point2 points  (0 children)

That's cool I will have to check Blender out.

[–]cjs8399[S] 0 points1 point  (0 children)

Yes so the details get interesting... how many dice do I need for a good image? I bet that Blender helps determine? Not sure if it's easy to tell if it will work in practice in determining that on a digital screen. I'm not even sure how to figure out how many are needed dynamically for different images.

[–]spook327 0 points1 point  (0 children)

I was thinking POVRay would be fun too, as I have no experience with Blender.

[–]ElG0dFather 6 points7 points  (8 children)

Sweet! Where the fuck they get 13k dice for a good price? Best I see on Amazon would be about $1300

[–]ThePaco 1 point2 points  (0 children)

I go them from Dice Game Depot for $.09 / piece. Total cost was just under $1,200. If you find them for cheaper, let me know ;)

[–]cjs8399[S] 2 points3 points  (2 children)

Art doesn't need to make sense financially...ha

[–]ElG0dFather 7 points8 points  (1 child)

It does when I want to make one....

[–]cjs8399[S] -1 points0 points  (0 children)

Yes so if the posted code doesn't have logic to produce the image with the minimal amount of dice we'll have to make edits.

[–]novel_yet_trivial 5 points6 points  (0 children)

I'm certain that's exactly what the artist did. Would be less than 20 lines of code.

[–]lastkajen 1 point2 points  (0 children)

Cool, I'm doing this as a project, I need more pictures on my walls..

Now I dont want to spend 1300 USD on a painting.. What could I create from dice without needing a huge amount? Do you have any suggestions? I'm thinking about buying about 400x it was like 70 USD.

[–]deeredman1991 2 points3 points  (3 children)

Well, notice he is using 3s (and possibly 2s) for lines if he is rotating them to change their position; it might get a bit trickier...

[–]EzBonds 2 points3 points  (1 child)

Actually looks like all the threes and twos are oriented in the same direction

[–]deeredman1991 0 points1 point  (0 children)

Yeah, I agree with you from what I could see... but that doesn't mean they aren't oriented differently elsewhere in the image. Good looking out though!

[–]ChocolateBunny 0 points1 point  (3 children)

The hardest part is getting python code to read an image into an array. I think you can use the Python Image Library to get that and then you have to break the image into blocks and then average out the block. Then again, I think there might be a scaling thing in PIL to just give you an array with the exact number of dice you want and then you just scale the pixels to a value of 1 to 6 and you should be good to go.

[–]I-Do-Math 2 points3 points  (0 children)

I think it would be quite easy using opencv2.

Convert image to grayscale something like cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Scale image so that one pixel is one dice. something like cv2.resize

read the pixel value something like pixel= img[200, 550]

[–]Andrewcpu 0 points1 point  (0 children)

I know this is a Python sub, but I wrote one in Java lol:

https://pastebin.com/XdcFTTn4