5:57 PM
Dear Anis, thank you for our email! I think a tool that can convert an image to TikZ is an interesting thing, but it is probably better to be programmed in a language other than TeX. The first question is: What should the input be? There is already a tool built into Inkscape that can convert any vector graphic to TikZ code. Of course, it won't make use of shapes or complicated things, but just use paths, but still, the output is very good.
As for raster graphics (JPG, PNG etc.), you will need to trace the pixels to become vectors. And also for this there is a way built into Inkscape: inkscape.org/doc/tutorials/tracing-pixelart/… ... So, maybe the tool you (or we or others) are looking for is already existing
This is the tool for Inkscape to export TikZ/PGF paths: xyz2tex.github.io/svg2tikz
I think, however, most people on this site are not really looking for a way to trace bitmaps and convert paths to TikZ, but they want to recreate "semantical graphics". With this, I mean things that are represented in TikZ by nodes and edges that are connected in a sensible way. The problem here is that these semantical information is lost once such a diagram is printed or converted into a PDF.
Let me explain with an example: In TikZ, you can create two nodes and connect them with a line. When you produce a PDF, the node and the line are just printed as paths starting from some coordinate. So, it is not directly clear that the line is attached to the rectangle that represents the node and it is equally unclear that this rectangle even represents a node.
Now, if you want to reconstruct the logic of the TikZ graphic, how should you start? Where should you get this non-existing information from? But you would need this information to build such a "semantical graphic" that you can edit and extend maybe (e.g. adding more nodes)
Sorry for maybe mis-using this chat for writing so much! I initially only wanted to drop a few lines, but then I thought more and more about this =D
 
Hello Jasper. This is how the thought process works xD. Thank you for your answer. Yes that was my understanding of the problematic. I come from a Computer Vision-related background where the task if often to identify an object from an image, usually a raster.
Tool to detect shapes are well known in the state of the art. Some are IA-based and others are more traditional. The complexity rises after shape/feature extraction.
 
6:14 PM
Well, one could of course say: there is a shape (a circle or whatever) and more or less in the center of it, there is some text. So, hey: this could be a node! And then, there is a line starting from this node to some other shape that could also be a node ...
 
Logical/hierarchical relationships are a quite more complex. Geogebra uses absolute positioning for nodes for eg.
 
Yes, I can think of such an approach with rectangles or circles. It gets very difficult with shapes such as ... cloud callout
 
I believe the first version of TikzParser would implement an absolute positioning system and very few of Tikz libraries. Then later, it may include the necessary topological description to contain the semantic layers needed for that complexity.
 
I think, the user would have to have way to interact with the tool: "I want this to be a node, positioned relative to this node ..." The tool might not be able to interpret all this correctly
 
well, some models can perform what we call "template matching". From an existing template, we infer the existing of such a shape in the image.
ok, you are seeing a co-design for Tikz with an interface to change the Tikz code and the image at the same time?
like Tikzedt (pls refer to the email I sent)
 
6:18 PM
shapes in tikz are actually stored as paths as well. so they are accessible and one could probably do matching
 
ok, this is interesting for me. Can you dive into more detail about how tikz actually stores these paths? do you have a reference I could read?
 
@anis I a way, yes. I think, no tool will ever be able to interpret every possible image correctly. But, maybe it is possible to let the tool work, output the result to the user and give him/her the possibility to change the interpretation a bit. This way, if this is AI-driven, the AI could even learn and become better
@anis Well, it is all PGFis TeX code ... wait I look into an example that is easy to unterstand ...
this PGF code tree is really complicated. but here it comes: github.com/pgf-tikz/pgf/blob/master/tex/generic/pgf/libraries/…
The first shape is circle which essentially only draws an ellipse
a shape defines a lot of things, the shape that is drawn, but also the anchors and much more. relevant for matching is (probably) just the stuff around \backgroundpath
... which comes at the very end of the defintion
And for circle it is really just \pgfpathellipse{\centerpoint}{...}{...} which is the PGF representation of a circle path (similar to SVG: defined by a center coordinate and two vectors defining the two radii)
 
This is fascinating as I have never seen the layer underneath Tikz/Latex. I now realise that I don't need/want to dive this deep. Low-level tikz code isn't the target of this work. I may stick around with "\node [drawn circle, ..] {text};"
 
Yes, this is what you should use as user. But if you want to create your custom shapes (to be used with an option such as myshape), then you need to do these things. TikZ is the "frontendlayer" which is based on PGF.
 
I will work on some rudimentary solution that does a fairly basic code generation. I also noted your idea about co-design to have an assistive tool when drawing tikz.
 
6:28 PM
PGF can already do lots of things and you can theoretically draw everything with just PGF. TikZ is meant to help the user to draw in a more semantical way
 
@JasperHabicht you are right, in-fine, you can can define any shape to represent a set of points and then generate the Tikz code from PGF.
 
@JasperHabicht yes, but that is where the most interesting part is. Tool that can draw are numerous. Tools that are as powerful and semantically charged as Tikz are.. well there is only Tikz AFAIK.
if this project reaches any maturity, I am expecting "draw for me" questions to drop in Tex exchange xD
 
Yes, I think so too. It is a great tool exactly because it is so semantic
Haha, I hope so
 
I thank you for this exchange.
 
6:31 PM
Next would be a tool to solve all these "my table has 1000 columns and 20000 rows, how can I fit it on one page without reducing the font size" questions =P
 
lmao, one day sure
 
You're welcome! I am not the total expert on TikZ, but I am happy to help as far as I can!
 
I wanted to ask you if you would be interested in being one of the early test users, if I can achieve this.
 
Sure, this would be cool!
If you put your project on GitHub, you can add me there (github.com/jasperhabicht)
 
I am already following you (github.com/anisghaoui). Yes, the project will be on github. I plan to release the website (I got someone working on that part).
IIRC we are both PhDs in very different fields. WE both know that research is long and tedious.
 
6:35 PM
@anis You are right! Now that you say it, I remember that you follow me =D
@anis Oh yes, it is
 
I have been thinking about this project for more than a year. I was frustrated while writing my thesis last year.
 
But my PhD has really nothing to do with computer science at all
 
Next time I am messaging you, I hope to have something to show you.
Auf Wiedersehen
 
@anis Maybe you can add more people to this project. I fear I am not of much help with programming ...
 
No worries. I have finally found the will to do some. we will see.
 
6:39 PM
بالسلامه
(I hope that this is at least somewhere close to understandable)
 
yes, it is. A formal Arabic way to say goodbye.
actually, you would prefer this for formal Arabic. مع السلامة.
and funny enough what you wrote is a more Algerian way to say it.
see you!
 
@anis =D Bye!