Img4Dat


Img4Dat
#1
Hello,
 
long time ago I started implementing a tool to convert images to LDraw compatible .dat files. The first name was Img2Dat; but during the time the ‘version’ increased. Here is only a short description.
 
You can download the tool here (sorry, but I have to write this: the application, can be downloaded as it is. I do not take charge for errors or any kind of damage to your system that is caused by this software.): Img4Dat.zip
It is a beta version – there are some issues I that need an improvement. But I think it is stable enough for playing. It is written in C# for the .NET Framework 3.5 (so Windows).
 
If you open the application, you can open a bitmap (currently only .bmp) – it will be shown in the left half of the GUI.

.png   Clipboard01.png (Size: 144.44 KB / Downloads: 857)
 
Now you can choose colors for the color quantization by right click on the source image (select the background color first). The result will be shown in the right half of the GUI.
It is the base for the path findings (around the areas with the same color). After choosing the colors it is possible to clean the result a little bit (and to remove the obsolete areas in the background). 

.png   Clipboard02.png (Size: 204.78 KB / Downloads: 857)
You can save the result image to rework it in a different tool or just for backup.
You can search for the paths now, by clicking the 'FindPaths' button. The result will be shown on top of the original image.
Again, a little bit of cleaning can be done (here undo is possible):
  • Select one point and create a circle (with the connected points); you can define the number of points in the circle.
  • Select more then two points. The points will be projected on the line between the first and the last selected point.
  • Select more then three points. The points will be projected on a circle. The first and the last point will not change. You have to select the points in the right order.
  • Select two points. They will become one at the cut of the connected lines.
  • Select more then two points. The distance between this points will be recalculated. Here you also have to select the points in the right order.
  • When you have selected one point, you can delete it with pressing d-key.
  • When you have selected two points, you cann add a point between them by pressing the a-key.

.png   Clipboard03.png (Size: 190.53 KB / Downloads: 854)
You can also add a ‘template’ where the image should be patterned for, and scale and adjust it (currently only torso and tile 2x2 round).

.png   Clipboard04.png (Size: 196.46 KB / Downloads: 853)
When the result is fine, the triangles can be created by clicking the 'CreateTriangles' button  – a .dat file with the name of the source image becomes created in the folder of the source image. The colors need to be adjusted to LDraw colors.

.png   Clipboard05.png (Size: 4.13 KB / Downloads: 841)
(One hint: The triangle generation will not work correct, when two lines cross after cleaning the paths or adding the template.)

I would be happy, if someone gives it a try.

Rolf
Reply
RE: Img4Dat
#2
Had a quick try on my laptop (not home currently) and so far I'm not very successfull... get a crash whan I try to generate triangles, or when I try to save bitmap. I'll try again when home!
Attached the bitmap I used.


Attached Files
.zip   leather2.zip (Size: 949.18 KB / Downloads: 7)
Reply
RE: Img4Dat
#3
(2019-02-27, 16:02)Philippe Hurbain Wrote: Had a quick try on my laptop (not home currently) and so far I'm not very successfull... get a crash whan I try to generate triangles, or when I try to save bitmap. I'll try again when home!
Attached the bitmap I used.

Ok, did you get an error message?

I was able to create the file (without path cleaning). But as you can see here, there is still some work to do... There are red colored triangles, that needs to be adjusted (and one wrong blue  Angry ). 


.png   Clipboard06.png (Size: 9.9 KB / Downloads: 815)

Rolf


Attached Files
.dat   leather2.dat (Size: 341.18 KB / Downloads: 1)
Reply
RE: Img4Dat
#4
(2019-02-27, 16:44)Rolf Osterthun Wrote: Ok, did you get an error message?

I was able to create the file (without path cleaning). But as you can see here, there is still some work to do... There are red colored triangles, that needs to be adjusted (and one wrong blue  Angry ).

Tried again on my main machine, same problem when I try to triangulate. Here is the error message:
Code:
Consultez la fin de ce message pour plus de détails sur l'appel du débogage
juste-à-temps (JIT) à la place de cette boîte de dialogue.

************** Texte de l'exception **************
System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.
  à Img4Dat.Triangulator.SimpleTriangulator.addPoint(Point p)
  à Img4Dat.Triangulator.SimpleTriangulator.Triangulate(Int32 width, Int32 height)
  à Img4Dat.MainForm.toolStripButtonCreateTriangles_Click(Object sender, EventArgs e)
  à System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
  à System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
  à System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
  à System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
  à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
  à System.Windows.Forms.Control.WndProc(Message& m)
  à System.Windows.Forms.ToolStrip.WndProc(Message& m)
  à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Assemblys chargés **************
mscorlib
   Version de l'assembly : 2.0.0.0
   Version Win32 : 2.0.50727.5420 (Win7SP1.050727-5400)
   CodeBase : file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
Img4Dat
   Version de l'assembly : 1.0.6997.21469
   Version Win32 : 1.0.*
   CodeBase : file:///D:/Mes%20documents/Mod%E9lisation%20LDraw/Pi%E8ces%20en%20cours/Img4Dat.exe
----------------------------------------
System.Windows.Forms
   Version de l'assembly : 2.0.0.0
   Version Win32 : 2.0.50727.5420 (Win7SP1.050727-5400)
   CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
   Version de l'assembly : 2.0.0.0
   Version Win32 : 2.0.50727.5420 (Win7SP1.050727-5400)
   CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
   Version de l'assembly : 2.0.0.0
   Version Win32 : 2.0.50727.5420 (Win7SP1.050727-5400)
   CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Core
   Version de l'assembly : 3.5.0.0
   Version Win32 : 3.5.30729.5420 built by: Win7SP1
   CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
mscorlib.resources
   Version de l'assembly : 2.0.0.0
   Version Win32 : 2.0.50727.5420 (Win7SP1.050727-5400)
   CodeBase : file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
System.Windows.Forms.resources
   Version de l'assembly : 2.0.0.0
   Version Win32 : 2.0.50727.4927 (NetFXspW7.050727-4900)
   CodeBase : file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_fr_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------

And the questions/wishes...
- how do I fit the image to the template?
- I can delete one single vertex from a path. I wish I could select several with a marquee and delete them all.
Reply
RE: Img4Dat
#5
(2019-03-03, 9:17)Philippe Hurbain Wrote: And the questions/wishes...
- how do I fit the image to the template?
- I can delete one single vertex from a path. I wish I could select several with a marquee and delete them all.

Hello Philo,

you have to fit the template to the image. By using the 4 NumerUpDown fields in the left bottom area, you can scale and move the template. It works the easiest if you select the field and use the mouse wheel.

And I think that this is also the reason for the exception. You added a template, but did not move it, so that there are negative values in the 'template path'. Currently the application can not handle such situations. I will catch them in the next version.
So now, you either can move and scale the template or you can create the triangles without a template (but then the size will not match the needed one). Does this help?

I will try to add the 'multi-delete'.

Rolf
Reply
RE: Img4Dat
#6
Hello,

there is a new version available now (same location). In that, you can also delete 'multi-selects' by pressing 'd'.

Rolf
Reply
RE: Img4Dat
#7
(2019-03-04, 21:36)Rolf Osterthun Wrote: Hello,

there is a new version available now (same location). In that, you can also delete 'multi-selects' by pressing 'd'.
Thanks Rolf, I was able to adjust template, and multi-delete works fine. But I still get an instant crash when I try to triangulate (with or without template Sad)
Reply
RE: Img4Dat
#8
(2019-03-05, 9:07)Philippe Hurbain Wrote: Thanks Rolf, I was able to adjust template, and multi-delete works fine. But I still get an instant crash when I try to triangulate (with or without template Sad)


Hello Philo,

thank you for testing and reporting. I am really sorry, that it is not working on your side. I uploaded a new version. This time a few debug messages were added (via log4net). That means the application will create a log.txt file where you can see, what it is doing – and where it is stopping.

A few posts up you wrote, that you were also not able to save the bitmap. Could it be that the application is not allowed to create files on your system?

Rolf
Reply
RE: Img4Dat
#9
(2019-03-05, 10:57)Rolf Osterthun Wrote: thank you for testing and reporting. I am really sorry, that it is not working on your side.
So am I Wink

Quote:I uploaded a new version. This time a few debug messages were added (via log4net). That means the application will create a log.txt file where you can see, what it is doing – and where it is stopping.
Attached two log files (with different source images). About the same result (and crash in both cases).
Quote:A few posts up you wrote, that you were also not able to save the bitmap. Could it be that the application is not allowed to create files on your system?
That was on my laptop (and there I only tried once, maybe I goofed). Here it works fine, as you see in a log file (I used the continue possibility after triangulation crash).


Attached Files
.txt   log.txt (Size: 2.29 KB / Downloads: 2)
.txt   log2.txt (Size: 1.79 KB / Downloads: 2)
Reply
RE: Img4Dat
#10
(2019-03-05, 11:55)Philippe Hurbain Wrote: So am I Wink

Attached two log files (with different source images). About the same result (and crash in both cases).
That was on my laptop (and there I only tried once, maybe I goofed). Here it works fine, as you see in a log file (I used the continue possibility after triangulation crash).

Thanks again.

In both cases the application tried to add a point directly on the edge of the image (x coordinate = 0). This is something I did not expect / did not test deep enough. I expected that the pattern is always surrounded by the back color (at least after cleaning the quantized image).
A new version is uploaded that should be able to handle these situations.

I hope it works now.

Rolf
Reply
RE: Img4Dat
#11
(2019-03-05, 12:49)Rolf Osterthun Wrote: I hope it works now.
Good news! It does work Wink
And I know what I did to crash at bitmap save: I tried to overwrite currently opened bitmap with edited one...

More after I make some more tests...
Reply
RE: Img4Dat
#12
(2019-03-05, 13:40)Philippe Hurbain Wrote: More after I make some more tests...
http://www.ldraw.org/cgi-bin/ptdetail.cg...973p9e.dat
Is it necessary to say more? Wink

More seriously... I found the cleanup time to be somewhat painful (eg. I missed a "merge points to average" function). So I used another method: first recreate a clean image with a vector drawing program (here Corel Draw X5), exported as bmp, processed with Img4Dat. Almost done... just had to change colors to proper LDraw ones, correct a colinear triangle, place the torso faces at the right place.

Great stuff!
Reply
RE: Img4Dat
#13
...and another one...
http://www.ldraw.org/cgi-bin/ptdetail.cg...973p5e.dat
I already had the vector image, so it was a snap!

One thing I'd like: be able to unzoom more than 1x (if the image is big, I can't unzoom enough to see it completely and adjust template)
Reply
RE: Img4Dat
#14
(2019-03-05, 15:54)Philippe Hurbain Wrote: http://www.ldraw.org/cgi-bin/ptdetail.cg...973p9e.dat
Is it necessary to say more? Wink

More seriously... I found the cleanup time to be somewhat painful (eg. I missed a "merge points to average" function). So I used another method: first recreate a clean image with a vector drawing program (here Corel Draw X5), exported as bmp, processed with Img4Dat. Almost done... just had to change colors to proper LDraw ones, correct a colinear triangle, place the torso faces at the right place.

Great stuff!

Hey,

looks good. Can you share the exported bmp with me? I would like to reproduce the colinear triangle.
Did you try to replace the circles (select one point in a standalone circle and push createCircle)?

Thanks
Rolf
Reply
RE: Img4Dat
#15
(2019-03-05, 19:13)Rolf Osterthun Wrote: looks good. Can you share the exported bmp with me? I would like to reproduce the colinear triangle.
Here attached... happens with a torso template, scaled 20x20. This is somewhat expected, considering the number of triangles to squeeze at the bottom of torso. Other than adding another vertex in the middle of base, solution is to made a minor tweak to the pattern (that's what I did).
Quote:Did you try to replace the circles (select one point in a standalone circle and push createCircle)?
I did. But the result was already pretty good, I figured it was not worth the work...

Otherwise...
- if the template goes outside the image, there is a crash.
- I would have expected the pattern to be cropped along the lines of template?


Attached Files
.zip   leather5.zip (Size: 46.16 KB / Downloads: 3)
Reply
RE: Img4Dat
#16
Really impressed by Img4dat... I made this one http://www.ldraw.org/cgi-bin/ptdetail.cg...973p5f.dat that would have been a nightmare to do "by hand". This one was made directly from images captured from this video https://youtu.be/UxzW2u_0m-g?t=96, just with enhanced contrast and stuff outside torso trimmed with image editor.


Attached Files
.zip   knit2.zip (Size: 469.82 KB / Downloads: 4)
Reply
RE: Img4Dat
#17
(2019-03-06, 12:41)Philippe Hurbain Wrote: I did. But the result was already pretty good, I figured it was not worth the work...
Here I am always struggling – how good / detailed does the pattern has to be.

(2019-03-06, 12:41)Philippe Hurbain Wrote: Otherwise...
- if the template goes outside the image, there is a crash.
- I would have expected the pattern to be cropped along the lines of template?
The triangle generation will not work correct, when two lines cross after cleaning the paths or adding the template. This includes the edges of the image. There are a lot of improvements that can be done... I started experimenting with a merge function (like you suggested) and storing the edited paths should become possible.

In the meantime, I used the tool myself to create also a patterned torso: Brainiac

Rolf
Reply
RE: Img4Dat
#18
(2019-03-05, 19:13)Rolf Osterthun Wrote: Did you try to replace the circles (select one point in a standalone circle and push createCircle)?
Played a bit more with that... I think it would be better if the points were evenly distributed by this tool.
Loosely related:
- it would be nice to be able to select a full path (click on a point then extend selection to the whole path). Eg. to select one of concentric circles to apply createCircle
- With a full path selected as above, I'd like to be able to decrease the number of points (the points that cause smallest angle change beeing deleted first)
Reply
RE: Img4Dat
#19
(2019-03-09, 8:27)Philippe Hurbain Wrote: Played a bit more with that... I think it would be better if the points were evenly distributed by this tool.
Loosely related:
- it would be nice to be able to select a full path (click on a point then extend selection to the whole path). Eg. to select one of concentric circles to apply createCircle
- With a full path selected as above, I'd like to be able to decrease the number of points (the points that cause smallest angle change beeing deleted first)

Currently you have the following possibilities:
Select one point in a standalone circle (this means there is no point with more than two connected edges in the circle; pic 1).

.png   Circle1.PNG (Size: 27.94 KB / Downloads: 681)

If you now use the CreateCircle Button, the application will replace the standalone circle with a better circle – same angle between all points (pic 2).
When you change the value in the text field next to the CreateCircle button and use the button then, the number of points in the circle can be changed (e.g. 16 or 6; pic 3 and 4).

When there is a not closed circle, you have to select all points you would like to optimize in the right order (pic5).

.png   Circle2.PNG (Size: 22.25 KB / Downloads: 680)

Then you could either make the angle the same between the points by using the CreateCircle button (pic 6) or you can project them on the circle with the PutPointsOnCircle button (pic 7).
In the second option the angles did not change, but they all have the same distance to a center point now. In both cases the first and the last point will not change its position.
The second option is better for a situation like here:

.png   Circle3.PNG (Size: 27.64 KB / Downloads: 680)

I hope this helps and your situations are covered?

Rolf
Reply
RE: Img4Dat
#20
(2019-03-09, 14:07)Rolf Osterthun Wrote: If you now use the CreateCircle Button, the application will replace the standalone circle with a better circle – same angle between all points (pic 2).
When you change the value in the text field next to the CreateCircle button and use the button then, the number of points in the circle can be changed (e.g. 16 or 6; pic 3 and 4).
Ah, I missed that! thanks!
Reply
RE: Img4Dat
#21
(2019-02-26, 23:11)Rolf Osterthun Wrote: You can also add a ‘template’ where the image should be patterned for, and scale and adjust it (currently only torso and tile 2x2 round).
Hi Rolf,
Just noticed a little bug in torso template: top corner vertices are at x=+/-14.35, should be 14.345 to fit torso structure.
Stupid me... not a template bug but agressive rounding on my side!!!
Reply
RE: Img4Dat
#22
Hey,

A new version is uploaded: Img4Dat.zip
You can use your own templates now. Create a LDraw shape in x-y-plane (z-coordinates will be ignored) that only is made from triangles that are BFCd counter clock wise). E.g. Minifig Torso:
Code:
3 16 -19 32 -10 19 32 -10 19 29 -10
3 16 19 29 -10 -19 29 -10 -19 32 -10
3 16 14.345 2 -10 -14.345 2 -10 -19 29 -10
3 16 -19 29 -10 19 29 -10 14.345 2 -10
3 16 12 0 -10 -12 0 -10 -14.345 2 -10
3 16 -14.345 2 -10 14.345 2 -10 12 0 -10

The result should also be ok now, when the template is bigger than the image.
It is possible to merge selected points.
It is possible to define the color codes for the resulting triangles.

.png   ColorDef.png (Size: 2.4 KB / Downloads: 620)

Rolf
Reply
RE: Img4Dat
#23
Awesome! Made just a quick test, like it so far!

Quote:The result should also be ok now, when the template is bigger than the image.
I guess you mean the opposite (pathes that go outside template and are clipped on template boundaries)

With this feature, it's now almost easy to create a 3D pattern, by creating two opposite checkerboard templates, create both triangulations and merge them, then cleanup (some triangles next to seams don't receive the right color) and make the projection. Two little things that would help a lot for that:
- when loading a new template, keep scale and position of previous one.
- Offer the possibility to name the output file to avoid unwanted overwrite.

Quote:It is possible to define the color codes for the resulting triangles.
Took me a while to find how: just key in ldraw color code in the color swatch boxes!
Reply
RE: Img4Dat
#24
(2019-03-06, 12:41)Philippe Hurbain Wrote: Otherwise...
- if the template goes outside the image, there is a crash.
- I would have expected the pattern to be cropped along the lines of template?

(2019-03-22, 8:54)Philippe Hurbain Wrote: I guess you mean the opposite (pathes that go outside template and are clipped on template boundaries)
No, I meant that the template can become bigger now than the image. In the last version this guided to a crash. But you are partly right: the other function is also implemented very rudimentary. There are still some issues, so I did not mention it as new feature. E.g. when a pattern point is exactly at a template point, or when a path-edge is going completely through the pattern, or … some special cases. Most of the time the result will only contain a few wrong colored triangles, but sometimes it also contains wrong triangles.

(2019-03-22, 8:54)Philippe Hurbain Wrote: With this feature, it's now almost easy to create a 3D pattern, by creating two opposite checkerboard templates, create both triangulations and merge them, then cleanup (some triangles next to seams don't receive the right color) and make the projection. Two little things that would help a lot for that:
- when loading a new template, keep scale and position of previous one.
- Offer the possibility to name the output file to avoid unwanted overwrite.
In a future version, it should be possible to define ‘hard’ edges in the template. These will split the result into smaller areas. I think the creation of 3d patterns will be a little bit more comfortable then. But to name the output file would be a good improvement in any case.

(2019-03-22, 8:54)Philippe Hurbain Wrote: Took me a while to find how: just key in ldraw color code in the color swatch boxes!
Sorry, bad description from my side.

Rolf
Reply
RE: Img4Dat
#25
(2019-03-22, 10:17)Rolf Osterthun Wrote: In a future version, it should be possible to define ‘hard’ edges in the template. These will split the result into smaller areas
Eager to see that Wink
Reply
RE: Img4Dat
#26
I made this head using checkerboard method (actually a 3 colors checkerboard!). It works fine, but requires too much cleaning to be cost effective compared to manual pattern creation...
http://www.ldraw.org/cgi-bin/ptdetail.cg...206p02.dat
Reply
RE: Img4Dat
#27
Three little gripes...
- Since templates are essentially LDraw parts files, it's annoying (mildly) to have a txt extension. I'd prefer a .dat extension, allowing to use standard parts editors without having to override extension.
- the displacement of template seems clipped to 1000, wich prevents to use large images.
- Img4Dat doesn't unlock a loaded image file, even if you load another image. You have to quit Img4Dat to unlock it.
Reply
RE: Img4Dat
#28
(2019-03-24, 15:32)Philippe Hurbain Wrote: Three little gripes...
- Since templates are essentially LDraw parts files, it's annoying (mildly) to have a txt extension. I'd prefer a .dat extension, allowing to use standard parts editors without having to override extension.
- the displacement of template seems clipped to 1000, wich prevents to use large images.
- Img4Dat doesn't unlock a loaded image file, even if you load another image. You have to quit Img4Dat to unlock it.

Hey,

all three points should be changed/fixed in this new version.

Rolf
Reply
RE: Img4Dat
#29
(2019-03-28, 21:25)Rolf Osterthun Wrote: Hey,

all three points should be changed/fixed in this new version.

Rolf

Thanks Rolf, I'll test it ASAP!
Reply
RE: Img4Dat
#30
(2019-03-28, 21:25)Rolf Osterthun Wrote: Hey,

all three points should be changed/fixed in this new version.

Rolf

When i want to open a template, I got this error:
Any idea?
   
If nothing goes right, go left.
Reply
RE: Img4Dat
#31
(2019-04-06, 19:01)Johann Eisner Wrote: When i want to open a template, I got this error:
Any idea?

Hey,

when you open a template, the tool tries to center it on the image that should be converted. But I think you did not open an image - so it is not possible to center the tempalte. I should catch that exception.

Rolf
Reply
RE: Img4Dat
#32
(2019-04-06, 21:09)Rolf Osterthun Wrote: Hey,

when you open a template, the tool tries to center it on the image that should be converted. But I think you did not open an image - so it is not possible to center the tempalte. I should catch that exception.

Rolf

Hello Rolf
That's the solution to the problem.
I am used to it from the LDPC, first the template and then the picture to open.

Johann
If nothing goes right, go left.
Reply
RE: Img4Dat
#33
Rolf, I have to admit I was only lurking over this thread here and looking for Philo's experiements.

After seeing the result of the post-it, i decided to try it for myself.

I scanned a torso, enhanced the contrast and did a posterize in GIMP.

Imported it into Img4Dat, just did minor brush up, et voila:

Wow! Done in less than 10 minutes...

(minor correction needed at the bottom)

   
Reply
RE: Img4Dat
#34
Rolf, after using it and playing around more I do have some more requests/suggestions:
  • Switch to block the Right Mouse Button to select colours in Left Window
    I am used to navigate around, respectively move something while pressing the RMB. (e.g. LDView) That had me select colors I did not want...
  • Right Window resets when the Colour is changed or Tool is changed
    When I switch colours to fill areas or switch from "fill" to "draw" the right window resets to "top left", one needs to find the rgiht location again :-)
  • Draw Tool should also work when LMB is pressed
    Right now I can only set individual dots. It would be great if the tool could keep painting dots when I move the mouse, or even better draw a simple line when selecting two areas in the left window. That makes prepping the picture easier.
  • Remove a colour from the Right Window by (right) Clicking on the Palette
    I can remove a color from the Right Window only if I right click in an area of this color. That can be difficult. It would be easier to remove it by right clicking on the color icon within the palette. (e.g. if a color is accidently selected)
  • A one Step Undo
    :-)
  • Save Bitmap does not use the specified Path
    It always saves into the Img4Dat directory
that'S if for the moment! Thansk for this tool!
Reply
RE: Img4Dat
#35
Hello Gerald,

the torso looks really good. I am happy to see that you are experimenting with the tool. From my point of view the postproduction is not good enough yet. For chaotic patters it is good, but for well-arranged curves and lines it is not.

(2019-06-26, 20:55)Gerald Lasser Wrote: Rolf, after using it and playing around more I do have some more requests/suggestions:
  • Switch to block the Right Mouse Button to select colours in Left Window
    I am used to navigate around, respectively move something while pressing the RMB. (e.g. LDView) That had me select colors I did not want...
  • Remove a colour from the Right Window by (right) Clicking on the Palette
    I can remove a color from the Right Window only if I right click in an area of this color. That can be difficult. It would be easier to remove it by right clicking on the color icon within the palette. (e.g. if a color is accidently selected)


.png   CheckBoxFixed.PNG (Size: 3.92 KB / Downloads: 469)
Even when it is not usefull from my point of view, I added a checkbox where you can set the colors as fixed. When the colors are not fixed a right click on a color button should also remove the color from the quantization now.

(2019-06-26, 20:55)Gerald Lasser Wrote:
  • Right Window resets when the Colour is changed or Tool is changed
    When I switch colours to fill areas or switch from "fill" to "draw" the right window resets to "top left", one needs to find the rgiht location again :-)
  • Save Bitmap does not use the specified Path
    It always saves into the Img4Dat directory
These should be fixed.

(2019-06-26, 20:55)Gerald Lasser Wrote:
  • Draw Tool should also work when LMB is pressed
    Right now I can only set individual dots. It would be great if the tool could keep painting dots when I move the mouse, or even better draw a simple line when selecting two areas in the left window. That makes prepping the picture easier.
For small pictures it is working, but for larger pictures it is to slow. Maybe I will find a way to speed this up in a later version. Currently my workflow looks like this: Use img4dat for quantization. Save the bitmap. Use Paint for color corrections. Reopen in img4dat and search the paths...

(2019-06-26, 20:55)Gerald Lasser Wrote:
  • A one Step Undo
    :-)
Yeah - that would be nice. Later...

In the new version there are also minor additions:
  • Circles and circle segments can now be replaced.
  • When you select two points and use the s-key, the tool tries to select the shortest path between these two points. Then you can use merge (m), delete (d) or createCircleSegment ©.
  • It should be possible now to define hard edges in the template by using line type 2 in the template file (the hard edge needs to be on an edge of a triangle)

A lot of refactoring was done - I hope it still works.

Rolf
Reply
RE: Img4Dat
#36
Thanks a lot Rolf for the quick adaptations! Tried it already and like the "Fix it" Button!

:-)
Reply
RE: Img4Dat
#37
Hey,

there was a bug in the triangulation. I uploaded a new version.

Rolf
Reply
RE: Img4Dat
#38
I finally gave it a try to produce the following part:
https://www.ldraw.org/cgi-bin/ptdetail.c...079px0.dat

I must tell this is a great tool because without it that part would have been a nightmare to create. It was done very fast I only had to rescale it with LDPE because there was no template for 2 X 4 Tile and then do some cleaning and that's all.

Here are some suggestions for improvement:
- Would be great to directly select the final ldraw color
- A way to cancel color selection or at least remove one applied color
- Support of png format (nice to have as converting to bmp is very easy)

That's all I think for now.

Thanks a lot for that great tool!
Reply
RE: Img4Dat
#39
(2019-07-28, 12:03)Vincent Messenet Wrote: I finally gave it a try to produce the following part:
https://www.ldraw.org/cgi-bin/ptdetail.c...079px0.dat

I must tell this is a great tool because without it that part would have been a nightmare to create. It was done very fast I only had to rescale it with LDPE because there was no template for 2 X 4 Tile and then do some cleaning and that's all.


This is true the tool is really beautiful for such kind of part. I played aslo with this pattern!





(2019-07-28, 12:03)Vincent Messenet Wrote: Here are some suggestions for improvement:
- Would be great to directly select the final ldraw color
- A way to cancel color selection or at least remove one applied color
- Support of png format (nice to have as converting to bmp is very easy)

Two of your request Rolf realized already:
  • You can select the final LDarw Color by clicking into the color box and enter the desired number remove it first with backspace.
    (But I would recommend to do this at a later point in the process)
    [Image: attachment.php?aid=3789]

  • You can remove an accidentally selected color by right clicking into the color box
    NOTE: If the "Fixed" is ticket, then you cannot add/remove colors anymore, I had it requested, as I accidentally removed colors all the time...
PNG support, I agree :-)
Reply
RE: Img4Dat
#40
(2019-07-28, 12:03)Vincent Messenet Wrote: I finally gave it a try to produce the following part:
https://www.ldraw.org/cgi-bin/ptdetail.c...079px0.dat
Clearly the kind of part for which Img4Dat makes wonder...



Quote:I must tell this is a great tool because without it that part would have been a nightmare to create. It was done very fast I only had to rescale it with LDPE because there was no template for 2 X 4 Tile and then do some cleaning and that's all.
Note that it's not very difficult to create new templates like this one, look in templates subfolder.


Quote:- Would be great to directly select the final ldraw color
You may key in a LDraw color number in right pane palette. Of course a selection from a LDraw palette would be much more convenient Wink



Quote:- A way to cancel color selection or at least remove one applied color
Right click in color palette (the colors must not be fixed, see check box above palette)

Quote:- Support of png format (nice to have as converting to bmp is very easy)
jpg would be nice too, even though compression artifacts can be annoying, it's often the only available initial format...
Reply
RE: Img4Dat
#41
Thanks for the hints Philippe!  Smile

Just did another one very fast: https://www.ldraw.org/cgi-bin/ptdetail.c...179px0.dat
Reply
RE: Img4Dat
#42
Hi Rolf,

I made a bunch of new patterns using img4dat... it really makes wonders if you have good source images!

...And of course some new wishes Wink
- Possibility to have a more continuous zoom factor, and to control it using mouse wheel
- Possibility to save "projects" (template+template scale+template position). Useful if you have several similar patterns to do (low priority request!)
- Possibility to control resolution of pathes. Overall the tool has a good balance, but sometimes if falls a bit on the low-res side.
- ...and maybe some day team up with Nils to merge LDPC and Img4Dat? Big Grin
Reply
RE: Img4Dat
#43
(2019-12-04, 14:21)Philippe Hurbain Wrote: - ...and maybe some day team up with Nils to merge LDPC and Img4Dat? Big Grin

As an avid LDPC user, I think that's a very good idea.
If nothing goes right, go left.
Reply
RE: Img4Dat
#44
(2019-12-04, 14:21)Philippe Hurbain Wrote: ...and maybe some day team up with Nils to merge LDPC and Img4Dat? Big Grin

I am very aware of this requirement, but I estimate that the total effort will be around 200-250 hours of freetime work.

I also need a better understanding of the process and how to provide a solution which is actually easy to use.
Reply
RE: Img4Dat
#45
Hello Philo,

it is good to see that someone is using the tool.

At the beginning I was no friend of scaling the image by non-integer values; but since I changed the generation of the quantized images it is no longer an issue. But I can not tell you all the effects on such a change (fill, paint, …). In the latest version the zoom in- and decreases by 0.1. But it will still no go below 1. Using the mouse wheel should work.

To implement the ‘projects’ will take a little bit of time. I have to think about that. One possibility is to put the scale and position into the template files themselves. If you need different settings, you could create different templates.

It would be possible to increase the resolution of the path. But that would affect all paths. I can try to implement a slider, where you can set this value. Currently it is set to 1, what means that the max distance between interpolated path segment and found path (edges of the colored areas) needs to be less than 1.

A new version is uploaded.

You can use the mouse for zooming now. It is also possible to correct one paint failure (a one step undo via Control+U). There is a new button in the color area; it can be used to force a re-quantization in the selected area (like fill); I will post an example later. And I tried to add a function that replaces paths by Bezier curves (sometime the results are a little bit strange; configurabel parameters again...; undo is possible via Control+Z).

It is (and was) possible to open other kinds of images. In the Open Bitmap dialog you can select Filetype '*.*' and select other image files then.

More to come... when there is more freetime.

Rolf
Reply
RE: Img4Dat
#46
Quote:At the beginning I was no friend of scaling the image by non-integer values; but since I changed the generation of the quantized images it is no longer an issue. But I can not tell you all the effects on such a change (fill, paint, …). In the latest version the zoom in- and decreases by 0.1. But it will still no go below 1.
Thanks, works fine! (sorry for the extra work Wink )
Quote:Using the mouse wheel should work.
could it be possible to place zoom center on mouse cursor?
Quote:To implement the ‘projects’ will take a little bit of time. I have to think about that. One possibility is to put the scale and position into the template files themselves. If you need different settings, you could create different templates.
That would be great. It would be at least a good starting point, and could be calibrated for an average image (say 500x500)
Quote:It is (and was) possible to open other kinds of images.
Sorry I missed that. Maybe it shouldn't default to the outdated BMP format...

Quote:I will post an example later
Will be appreciated... remains a bit mysterious to me Wink


Quote:More to come... when there is more freetime.
Take your time! thanks for your hard work!
Reply
RE: Img4Dat
#47
(2019-12-11, 23:11)Rolf Osterthun Wrote: There is a new button in the color area; it can be used to force a re-quantization in the selected area (like fill); I will post an example later.
This is the new button:

.png   ReQuant00.PNG (Size: 1.12 KB / Downloads: 269)

Sometimes, when there are color gradients in an image, the color quantization can guide to something like this (blue areas between back and white area):
   

To solve these 'gaps' (4.), you can color them black (1.) or white (2.); or you can use the new button and click in the blue area. A re-quantization will be done without the color blue (3.).
   

That's it.

Rolf
Reply
RE: Img4Dat
#48
(2019-12-19, 17:24)Rolf Osterthun Wrote: Sometimes, when there are color gradients in an image, the color quantization can guide to something like this (blue areas between back and white area):
Ah, excellent! gradients can be a pain indeed, good to have a solution for that. I'll experiment!
Reply
RE: Img4Dat
#49
I've been working a bit with the program, and agree with those who say it's very handy, especially if you have an already-cleaned up source image.

A couple of suggestions, perhaps for options when exporting the triangle mesh:
  • Would be handy to be able to flip to the X/Z plane instead of X/Y (for tile parts that are patterned on the top surface, e.g.)
  • A rounding precision setting
Both are easy enough to do in LDDP, but would save one more step (and I'm guessing are fairly easy to implement—but I could be very wrong).

A lower-priority suggestion would be auto-sizing templates, at least if the source image is already in the correct proportions.
Reply
RE: Img4Dat
#50
Hi Rolf. I've been playing with Img4dat today. The functions you described in your initial post all seem to be working well for me (Win 10, 64bit) except i can't zoom in on the image/paths. I see the small +/- buttons in the top left but the don't seem to do anything. What am I missing? --cj


Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 2 Guest(s)