Close
0%
0%

DIY Knit Portrait

Software to create your own Knit-like string pictures.

Public Chat
Similar projects worth following
I created 2 programs that lets you make your own "Knit" pictures. Based on the description of how the algorithm for the original Knit pictures works, I created my own algorithm that takes an image and converts it into a string picture.

Knit_Generator.exe can convert images to string pictures and exports the instructions.

Knit_Instructor.exe can open the instructions and tells you how to string the frame.

Download here:
https://drive.google.com/open?id=19rcw84hp6OVy7-0c_rH_Gss5SRGS3Bu5

Here's the page of Petros Vrellis, the artists that first used this method (to my knowledge): http://artof01.com/vrellis/works/knit.html
  • Settings explained

    Raphael Schaaf4 days ago 1 comment

    Since I get some questions about the settings from time to time I thought I'd explain them a bit better:

    Radius:

    The radius of the circle in pixels. Does not have any connection to how large you want to make the actual portrait. A bigger radius will make a more precise portrait, but will also take longer to compute. Use a small radius for quick previews and a bigger one when creating the final instructions for your portrait.

    Hooks:

    The number of hooks or nails you will use. More hooks make for nicer portraits with less geometric artifacts, but take longer to compute. Keep in mind how close together you can fit the hooks/nails.

    Lines:

    The number of lines that will be drawn between the hooks. Good values generaly between 2000-3000. When the generating process is near its end and all the new lines are placed around the border of the ring you have too many lines. When they are still being placed through the ring you have to few lines. Try to find a good balance.

    Contrast:

    The most tricky one to figure out. Basically the value that gets subtracted from every pixel when a line passes through it. A higher value should be used for thicker threads or smaller portraits. 20-50 seems to work fine.

    Scale:

    Zoom in and out of the picture with 1 & 2.

    Offset:

    Move the picture with the arrow keys.

    Detailled view:

    To open & close a more detailled view of what is going on during the generating process press D. This will show all the lines calculated so far and the remainder of the source image. Will slow down the calculation imensely, so don't leave it open.

View project log

  • 1
    How to use Knit_Generator
    1. Open Knit_Generator.exe.
    2. Press Space to load an image (.png, .jpg, .bmp should work).
    3. Position the part of the image you want converted inside the circle using the arrow keys to move it and 1 & 2 to scale it.
    4. Set the number of hooks, radius of the circle (bigger = more accurate but slower calculation), number of lines and contrast (contrast is inverse, higher number will create a flatter image).
    5. Press Enter to start the calculation (takes a couple of seconds to initalize).
    6. Pressing D during the calculation switches the drawing of the lines on and off. Can be used as a preview, but will slow down the calculations extremely if left on.
    7. When finished, press S to export the generated image as an .ini file containing the instructions for assembly.
  • 2
    How to use Knit_Instructor
    1. Open Knit_Instructor.exe.
    2. Press O to open a previously generted ini file.
    3. A single line will be displayed at a time, with the instructions from and to which hook to connect the string.
    4. Cycle through the steps with Enter and Backspace.
    5. Use J if you want to jump to a specific step.
    6. Use T to toggle the Image on and off.

View all instructions

Enjoy this project?

Share

Discussions

shaya0181 wrote 11 hours ago point

what is contrast calculator for ?

  Are you sure? yes | no

Raphael Schaaf wrote 11 hours ago point

In theory you can calculate the optimal contrast value to use, but I have no idea if it really works...

  Are you sure? yes | no

Dan Royer wrote 10 hours ago point

did you use RGB or CIELAB color space?

  Are you sure? yes | no

Dan Royer wrote 16 hours ago point

I have a slightly older version of the same algorithm that runs in Processing so that you don't need to trust an EXE file or be stuck with Microsoft products.  https://github.com/i-make-robots/weaving_algorithm  Includes a few different styles like square, circle, and color (still experimental)

  Are you sure? yes | no

Raphael Schaaf wrote 11 hours ago point

Nice, do you have any example images of color images? Do you split the image in 4 separate images for the CMYK channels and then run the same algorithm on each or did you use a different approach?

And what do you think would be the optimal way to string a color picture? Do all the lines of a single color at once, or do one C, one M, one Y, one K, repeat.

  Are you sure? yes | no

Dan Royer wrote 11 hours ago point

I've tried a few things with color images, including CMYK.  nothing really satisfies yet.

  Are you sure? yes | no

idisc wrote 10/21/2019 at 08:48 point

Proof of concept. Here are two thread portraits I made of John Lennon https://imgur.com/q5PShL6 and Alexander the Great https://imgur.com/NzFcZMs Thanks Raphael.

  Are you sure? yes | no

Gerben wrote 10/21/2019 at 15:29 point

Looks very nice. Thanks for sharing.

  Are you sure? yes | no

Raphael Schaaf wrote 10/26/2019 at 02:17 point

WOW! That's awesome :D

I just bought some of the materials for my first string portrait. I want to make a self portrait :)

  Are you sure? yes | no

idisc wrote 10/28/2019 at 17:45 point

I used a 39 centimeter wooden disk from an IKEA lazy susan and painted it with matt white paint. A CNC was used to evenly drill holes into the wood. Appropriate brass nails were used. I numbered the nails from 0 to 199 with adhesive paper labels. The lazy susan was left on the base to make it easy to spin to the appropriate nail positions, and the lazy susan was removed upon completion. Hope this will make construction easy.

  Are you sure? yes | no

Raphael Schaaf wrote 10/26/2019 at 03:19 point

Can you tell me how similar they are to the preview generated by the program?

  Are you sure? yes | no

idisc wrote 10/28/2019 at 17:36 point

The results are similar, however you have to have extreme contrast (black on white) and where black becomes too invasive you can mask the area and apply a light coat of white spray paint to soften the excessive black.

  Are you sure? yes | no

idisc wrote 11/08/2018 at 14:55 point

Rafael,  Do you have plans to create the DIY knit for a square shaped knit?

  Are you sure? yes | no

Raphael Schaaf wrote 04/14/2019 at 20:42 point

It wouldn't be too difficult to do, but I'm not planning on investing much more time in this project

  Are you sure? yes | no

Gerben wrote 04/15/2019 at 15:23 point

I've tried squares, but they don't look . At least in simulation. You get some weird "interference" patterns. It also looks more geometric/blocky, instead of the more organic results you get with circles. Same for hexagons, though not that extreme. Circles tent to look the best, somehow.

Here's my semi-finished online "knitter": https://gerben.algemeenbekend.nl/threadtone/
Where you can select multiple shapes.

  Are you sure? yes | no

Raphael Schaaf wrote 04/21/2019 at 08:42 point

@Gerben Wow that's really interesting!

As far as I can tell the main problem with squares / hexagons / etc is that there will never be a jump to a hook on the same edge, which severly limits the number of options for a jump, on a square you get 25% fewer hooks as an availlable target.

The second problem that I can see is that the diagonals will always have the highest weight / priority, since there will be the most pixels between them, which causes them to be favored over other hooks.

Maybe one way to partialy fix these problems would be to only use a circular image, even when you have a square frame?

  Are you sure? yes | no

Gerben wrote 04/21/2019 at 12:47 point

@Raphael Schaaf  No sure if that first one is really a big issue.

As to the second problem you mentioned. On a circle, lines to the direct opposite are preferred to more diagonal lines, as those lines are shorter. I've experimented a bit with dividing the total number of black pixels on a line, by the length of the line, to negate this effect.
The downside was that the algorithm then preferred very short lines. I think I added a minimum length or something, which had the funny side-effect of  creating a second circle, a fixed offset from the edge. I think that's where I stopped, as other projects got priority.

Never really finished it. It seems pretty much everyone only does the software side of this project. I've only seen 2 projects with finished string-art.

PS I even made a page, that would speak the number of the nail that was next, so all I needed to do was press "next", an listen where to go next. (-:

  Are you sure? yes | no

chaterrony wrote 08/03/2018 at 17:04 point

I was so fascinated by your pictures, that I did an app for Android which does the same. Reason: I have no windows... (hope that my 2012 iMac dies soon to be able to purchase a windows machine again)

BUT! The power of a tablet of smart phone is so little, that it takes decades to calculate... My "longest" try was with 50 strings and it took 5min! :-( So I abandoned this. 

But my question (as I didn't got as far to be able to test it myself): You check the darkest connection from a certain point to all other points. The darkest is taken. What do you make next? Do you just go to the next point  and do the same calculation (this is the way I did it)? Or do you have another system how to pick the next point to check the next connection?

  Are you sure? yes | no

Raphael Schaaf wrote 08/06/2018 at 07:24 point

Hi, that's cool, what did you program the app in?

You're right, the point you arrive at is taken as the new starting point for the next check.

It's a very time consuming calculation, if you are able to use the GPU it could probably run much faster...

  Are you sure? yes | no

chaterrony wrote 08/07/2018 at 20:56 point

So, please don't block me immediately when I tell you how I programmed it... It's on "ai app inventor". I am trying to work with Visual Studio, but it's quite a hard start as a newbie... One day... who knows :-)

I'm for sure disappointed on the functionalities of this software (usually I work with Arduino, and even the Arduino IDE is better!) and the programming by moving blocks...

I have modified the app and I have shared it on the appinventor website: ai2.appinventor.mit.edu/?galleryId=5560843821514752

Anybody who has ideas/suggestions how to improve the code is very welcome to let me know! Thanks in advance!

  Are you sure? yes | no

Raphael Schaaf wrote 08/08/2018 at 07:16 point

That's cool, I started programming with the block functions in Game Maker :D

I still use Game Maker to this day, even for this project, but nowadays I use the built in scripting language :)

  Are you sure? yes | no

Khalid Khattak wrote 05/17/2018 at 03:36 point

Awesome superb program.. I am in fabrication of DIY embroidery machine.. All I want to get X-Y coordinate and connecting string numbers .. It will be really awesome to embroidered such patterns...

  Are you sure? yes | no

Raphael Schaaf wrote 05/24/2018 at 07:43 point

Nice, but you will probably need a piece of software to convert the instruction file to something that your embroidery machine understands :)

  Are you sure? yes | no

Khalid Khattak wrote 05/24/2018 at 07:57 point

Dear Raphael, in the past i wrote an embroidery program that convert DST Tajima file format into simple G&M code. You can see in the following video.
I just need your help in this... end coordinates of connecting lines...
https://www.youtube.com/watch?v=5IKwKiq_b7w

  Are you sure? yes | no

unaiaroza wrote 04/28/2018 at 20:47 point

Can I load the exported file into cura and print it with a 3D printer?

  Are you sure? yes | no

Raphael Schaaf wrote 04/28/2018 at 22:19 point

No idea what cura is capable of, but I highly doubt it...

  Are you sure? yes | no

unaiaroza wrote 04/28/2018 at 22:59 point

So what is this app functional for?


  Are you sure? yes | no

Stefan May wrote 04/23/2018 at 05:16 point

Would you like to share the algorithm used?

  Are you sure? yes | no

Raphael Schaaf wrote 04/23/2018 at 06:54 point

Hi, I can do that, probably in a log sometime this week...

  Are you sure? yes | no

crowe.gabriel wrote 04/22/2018 at 20:37 point

https://imgur.com/a/kY50fKE

I've compiled this for linux, using the YYC for greater speed and it runs, BUT space does not bring up the dialog. It wont work because this:

https://docs.yoyogames.com/source/dadiospice/002_reference/file%20handling/file%20system/get_open_filename.html

and it says this about it:

"NOTE: This function is only valid on the Windows and macOS targets"

You might need to revisit this for linux compatibility, because this is a blocker for linux people.

  Are you sure? yes | no

crowe.gabriel wrote 04/22/2018 at 20:52 point

I faked it by commenting this line and and linking straight to the  file

//f = get_open_filename("image file|*.png;*.jpg;*.jpeg", "")
f = working_directory + 'template.jpg'

https://imgur.com/a/xtgSeU9

Which you can replace in the assets folder 'template.jpg' gets loaded when you tap space, instead.

I will have more time to fiddle with this (and provide linux executables) in a couple days.

  Are you sure? yes | no

crowe.gabriel wrote 04/22/2018 at 21:38 point

Found another issue: the same technique is used to save the file upon pressing S. This wont work on linux either, unfortunately.
Perhaps upload it like this?

https://github.com/ClockBotGames/Game-Maker-Pastebin

  Are you sure? yes | no

Raphael Schaaf wrote 04/23/2018 at 06:48 point

Oh, I didn't know get_open_file() was windows only...

Let me know if I can help you with this :)

  Are you sure? yes | no

AlanGreen wrote 04/21/2018 at 16:22 point

Hi, Awesome project! But I have problem with the step exporting generated image. Instead of a jpg file is saved after pressing S but a .ini file. What should I do? Thanks!

  Are you sure? yes | no

Raphael Schaaf wrote 04/23/2018 at 13:51 point

That's what the software is supposed to do...

  Are you sure? yes | no

sani.nassif wrote 04/18/2018 at 17:31 point

Any chance of getting a Mac or Linux version of this algorithm?

  Are you sure? yes | no

Raphael Schaaf wrote 04/18/2018 at 18:46 point

I wrote this program in GameMaker Studio, and there seems to be an export function for Ubuntu and Mac. I can give it a try...

  Are you sure? yes | no

Raphael Schaaf wrote 04/18/2018 at 18:57 point

No, sorry, I just checked and I don't have the necessary licences to export for Linux and Mac...

I uploaded the source code to the Google drive, so if anybody has the necessary GameMaker Studio licences they could export the program for me.

  Are you sure? yes | no

sani.nassif wrote 04/18/2018 at 19:16 point

I hope someone out there can help. Kudos on a nice project!

  Are you sure? yes | no

Leonard wrote 04/19/2018 at 23:21 point

Are you using the original GameMaker Studio? If so I have the Mac License.

  Are you sure? yes | no

Raphael Schaaf wrote 04/20/2018 at 14:17 point

Yes I am, GameMaker Studio 1 or whatever you wanna call it :)

  Are you sure? yes | no

crowe.gabriel wrote 04/22/2018 at 20:58 point

I have found some issues and i'm building one, see comments above.

  Are you sure? yes | no

Raphael Schaaf wrote 05/03/2018 at 14:25 point

Have you tried to run it with wine?

  Are you sure? yes | no

Dr. Cockroach wrote 04/17/2018 at 12:53 point

having some problems but most likely my Win7Starter. When data is saved, where is it stored. The Instructor crashed my whole system the first time but loaded on the second try. I really want to get this working as it is neat as heck :-)

  Are you sure? yes | no

Raphael Schaaf wrote 04/17/2018 at 14:42 point

Oh, that doesn't sound very good...

I tested it on a couple of different PCs and had no problems...

After you run an image through the generator you hit S and can choose the location where you want to save the data.

If you have problems with the generator I recommend reducing the number of lines, hooks and the radius to smaller numbers (~50), just to see if it works at all.

The higher those numbers are, the longer it takes to calculate.

  Are you sure? yes | no

Dr. Cockroach wrote 04/17/2018 at 23:34 point

Thanks Raphael for the input. I will try again later this evening :-)

  Are you sure? yes | no

Dr. Cockroach wrote 04/18/2018 at 08:35 point

Here is the actual issue ( I think ). The Instruction program is working as your Test INI file works well... However when a file is loaded into the Generator then there is no action when selecting the Save option. I have reduced all the variables and the program just continues to cycle through the Fps line in the upper left.

  Are you sure? yes | no

steve wrote 04/17/2018 at 08:44 point

trying this out myself, thanks for this! the instructor will be fantastic to use to create my own IRL

  Are you sure? yes | no

Raphael Schaaf wrote 04/17/2018 at 11:19 point

Cool, please send me a picture when you're done :)

I have yet to make one myself...

  Are you sure? yes | no

Dr. Cockroach wrote 04/13/2018 at 16:40 point

Whoa is right, This is really something to try :-)

  Are you sure? yes | no

Mike Szczys wrote 04/13/2018 at 16:33 point

Whoa! I love this. That string art was fascinating when we covered in on Hackaday a couple of years back. It's really cool that you implemented an algorithm for this and the sample images look fantastic! Well done.

  Are you sure? yes | no

Raphael Schaaf wrote 04/17/2018 at 11:18 point

Thanks for the compliments :)

The base image used really makes or brakes the end result.

I tried a bunch of variants for the algorithm, but surprisingly the results mostly looked the same...

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates