Digitising a line

Moderator: Kathy_9

Post Reply
terrypin
Posts: 470
Joined: Tue Jun 29, 2010 9:51 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Z170 Pro 4
processor: Intel Core i7 6700K 4.0GHz
ram: 32 GB
Video Card: None - uses built-in graphics
sound_card: HD onboard sound card
Hard_Drive_Capacity: 4.256 TB
Monitor/Display Make & Model: iLyama Prolite E2403WS 24" 1920x1200
Corel programs: Paint Shop Pro 8; Paint Shop Pro 2018
Location: East Grinstead UK

Digitising a line

Post by terrypin »

How difficult would it be for one of the script experts to develop a script to achieve the following please? I was going to say 'help me develop', but I fear my contribution would be small! I think I could do it with a macro using Macro Express Pro, but I know from experience that its performance would be glacially slow.

The target is a BMP file containing a solid line typically hand drawn and 10-20 px wide, of a single colour. On a background of another single colour. Looking like this:
Image

The mouse cursor would initially be placed manually a few pixels within the line near its start. The script would capture the mouse coordinates relative to the window in the two array variables X(1) and Y(1). It would then step along the line in small intervals (user settable, say 2px), storing the coords in X(2),Y(2) etc, remaining within 1-2 pixels of the line's centre, until reaching the end at X(n), Y(n).

A second part of the script, started by the user, would then be able to use each mouse position from the stored array to move a brush (such as the Eraser) along the line at a user-settable speed.

My practical objective is to record a video during that second stage while revealing a route or path of some sort.

With many such lines that get close at various points and/or have sharp turns, I've found this extremely hard to do manually.

Terry
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
LeviFiction
Advisor
Posts: 5986
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: Digitising a line

Post by LeviFiction »

Have you considered an animation program like Synfig? It would use vectors and masks that can be timed out on a timeline? You wouldn't have to live record the screen, you would just export the animation as a video. I haven't personally used synfig so I don't know how easy it would be to use that specifically. In moho studio, not free, I could do it pretty easily with the reveal line tool.

Technically I have an idea on how this could be done. I have a script that can take a selection and use a program called PoTrace to get a vector path But it would create a shape not a single line. So that would have to be edited after it was made but should be relatively easy to do. You could then use the VectorPaint script with a small edit to slowly move an eraser or paint brush along the line. No need to record mouse x,y positions to a file and read them back slowly.
terrypin
Posts: 470
Joined: Tue Jun 29, 2010 9:51 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Z170 Pro 4
processor: Intel Core i7 6700K 4.0GHz
ram: 32 GB
Video Card: None - uses built-in graphics
sound_card: HD onboard sound card
Hard_Drive_Capacity: 4.256 TB
Monitor/Display Make & Model: iLyama Prolite E2403WS 24" 1920x1200
Corel programs: Paint Shop Pro 8; Paint Shop Pro 2018
Location: East Grinstead UK

Re: Digitising a line

Post by terrypin »

Thanks Levi, I’ll look into Synfig in the morning.

Re PoTrace I can’t quite visualise what you mean about shape creation?

Terry
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
LeviFiction
Advisor
Posts: 5986
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: Digitising a line

Post by LeviFiction »

It makes a vector out of a raster selection. So it creates a vector shape, essentially that thick line would be a long vector blob with points on both sides of the line. To turn it into a single vector path you'd have to delete half of the points after it was done so that only the vector stroke was used. You could also just manually create your own vector path, ignoring the potrace option altogether. Then the only thing would be editing the VectorPaint script to move slowly over a given period of time. While the script was running you wouldn't be able to use PSP though.
terrypin
Posts: 470
Joined: Tue Jun 29, 2010 9:51 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Z170 Pro 4
processor: Intel Core i7 6700K 4.0GHz
ram: 32 GB
Video Card: None - uses built-in graphics
sound_card: HD onboard sound card
Hard_Drive_Capacity: 4.256 TB
Monitor/Display Make & Model: iLyama Prolite E2403WS 24" 1920x1200
Corel programs: Paint Shop Pro 8; Paint Shop Pro 2018
Location: East Grinstead UK

Re: Digitising a line

Post by terrypin »

Installed Synfig, watched a few tutorials and tried it for an hour. But too steep a learning curve. I'm not into 'animation' in its usual broader sense; just want to draw curved lines on maps!

Looked briefly at PoTrace and Moho too, but same reaction. Sledgehammers for rather a small nut. :wink:
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
LeviFiction
Advisor
Posts: 5986
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: Digitising a line

Post by LeviFiction »

Moho is technically the easiest of all options, while as a software it's intense. The single method I'm talking about, making a line and then erasing it, is really easy. It's literally a built in option called Stroke Exposure all ready to go without much thought. You wouldn't have to learn the whole software. But it's not a free software.

I did this in less than 5 minutes and that included tracing the line in your image with the point tool (pen tool in PSP) -



And you're not supposed to learn PoTrace, PoTrace doesn't export to a format PSP recognizes. I said I have a script that uses PoTrace to convert a selection into a vector for use with the VectorPaint script. So it's a two script solution. All you would do, if we got it to work, is select the path, then I have a script that will take that selection and turn it into a vector (we could skip this step if you wanted to just use the pen tool and make the vector manually but I digress) once we had the vector, we use an edited version of the VectorPaint script to move along the vector at a "set speed" as you record your video.
terrypin
Posts: 470
Joined: Tue Jun 29, 2010 9:51 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Z170 Pro 4
processor: Intel Core i7 6700K 4.0GHz
ram: 32 GB
Video Card: None - uses built-in graphics
sound_card: HD onboard sound card
Hard_Drive_Capacity: 4.256 TB
Monitor/Display Make & Model: iLyama Prolite E2403WS 24" 1920x1200
Corel programs: Paint Shop Pro 8; Paint Shop Pro 2018
Location: East Grinstead UK

Re: Digitising a line

Post by terrypin »

I guess PoTrace is aimed at programmers? Within its comprehensive documentation I could not find a single proper example. Even the page titled EXAMPLES just shows before and after images! Not one command line example. I got as far as showing the help, (which didn't give any examples), but my attempt to convert the file under discussion with the following CLI command failed, as you see. Must I make an empty PDF first, or what?

C:\Users\terry>"C:\Program Files\potrace-1.16.win64\potrace.exe" "C:\Users\terry\Dropbox\PSP8 (Sundry)\CurvedLineExampleZoomed.bmp" o "C:\Users\terry\Dropbox\PSP8 (Sundry)\CurvedLineExampleZoomed.pdf"
potrace: o: No such file or directory

Could you show me the command you used please?

EDIT: A few minutes later I discovered the missing '-'. The corrected line
"C:\Program Files\potrace-1.16.win64\potrace.exe" "C:\Users\terry\Dropbox\PSP8 (Sundry)\CurvedLineExampleZoomed.bmp" -o "C:\Users\terry\Dropbox\PSP8 (Sundry)\CurvedLineExampleZoomed.pdf"
executed, but gave error::

"Error opening document "C:\Users\terry\Dropboõ\PSP8
(Sundry)\CurvedLineEõampleZoomed.pdf":
Error [PDF Structure 40]: lnvalid file format
Note: the format of source is not PDF."
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
LeviFiction
Advisor
Posts: 5986
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: Digitising a line

Post by LeviFiction »

Again, you would not be using potrace directly. I have a script that takes a selection from PSP, puts it through potrace, then imports the SVG vector. There is zero need for you to do it manually if you wanted to use PoTrace. When I talk about you making the vector path manually I mean inside PSP with the pen tool.
terrypin
Posts: 470
Joined: Tue Jun 29, 2010 9:51 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Z170 Pro 4
processor: Intel Core i7 6700K 4.0GHz
ram: 32 GB
Video Card: None - uses built-in graphics
sound_card: HD onboard sound card
Hard_Drive_Capacity: 4.256 TB
Monitor/Display Make & Model: iLyama Prolite E2403WS 24" 1920x1200
Corel programs: Paint Shop Pro 8; Paint Shop Pro 2018
Location: East Grinstead UK

Re: Digitising a line

Post by terrypin »

OK thanks Levi, I misunderstood. (I did manage an EPS conversion a little later!)

But my starting point would always be a simple line drawn on a map, either by hand and photographed or in an image editor. That particular example was an online friend's image summarising his tour of the Gedi Ruins in Kenya. I extracted the track from his JPG and saved it as a BMP to get a single colour. Mainly to minimise the logic coding I anticipated by any script or macro hunting for the 'next point', but also to focus the discussion.

However, I've no idea how to convert that raster path to its vector equivalent. My attempts at using the Point-to-Point Bezier tool, for example, have never been successful. I've tried several tutorials. Is there one you or anyone else here can recommend please?
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
LeviFiction
Advisor
Posts: 5986
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: Digitising a line

Post by LeviFiction »

The pen tool is pretty simple. I've recorded an entire clarification video that shows what I'm thinking, the scripts I think we could use, and at the end I give a very quick demo of using the pen tool to manually trace the path. It doesn't teach the technique but it's pretty easy.

First the clarifying video


Now, once I knew you had trouble with the pen tool I recorded a second video that just demonstrates the use of the tool. It's very simple, it just takes a little work.

terrypin
Posts: 470
Joined: Tue Jun 29, 2010 9:51 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Z170 Pro 4
processor: Intel Core i7 6700K 4.0GHz
ram: 32 GB
Video Card: None - uses built-in graphics
sound_card: HD onboard sound card
Hard_Drive_Capacity: 4.256 TB
Monitor/Display Make & Model: iLyama Prolite E2403WS 24" 1920x1200
Corel programs: Paint Shop Pro 8; Paint Shop Pro 2018
Location: East Grinstead UK

Re: Digitising a line

Post by terrypin »

Thanks a lot Levi, really appreciate your work on this. I’ll have to view them in the morning when I get back to my PC because unfortunately for some reason neither of them will play on my iPad.
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
terrypin
Posts: 470
Joined: Tue Jun 29, 2010 9:51 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Z170 Pro 4
processor: Intel Core i7 6700K 4.0GHz
ram: 32 GB
Video Card: None - uses built-in graphics
sound_card: HD onboard sound card
Hard_Drive_Capacity: 4.256 TB
Monitor/Display Make & Model: iLyama Prolite E2403WS 24" 1920x1200
Corel programs: Paint Shop Pro 8; Paint Shop Pro 2018
Location: East Grinstead UK

Re: Digitising a line

Post by terrypin »

Impatience got the better of me so just taken quick look at your very helpful videos on my PC, than you. Will study properly tomorrow.

EDIT, Saturday 30 January 2021, 1625: If you saw it, ignore my previous request for a higher res screenshot. I must have been playing it incorrectly, because I can now read it perfectly well.
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
terrypin
Posts: 470
Joined: Tue Jun 29, 2010 9:51 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Z170 Pro 4
processor: Intel Core i7 6700K 4.0GHz
ram: 32 GB
Video Card: None - uses built-in graphics
sound_card: HD onboard sound card
Hard_Drive_Capacity: 4.256 TB
Monitor/Display Make & Model: iLyama Prolite E2403WS 24" 1920x1200
Corel programs: Paint Shop Pro 8; Paint Shop Pro 2018
Location: East Grinstead UK

Re: Digitising a line

Post by terrypin »

Pleased to report that I've mastered how to make a curved vector line, based on your tutorial. But I'm very slow!

Image

And there would still be several more steps before I get the finished animation I want.

This new vector pen skill will prove useful in various contexts in future, but I now think I’m probably making heavy weather of achieving my aim. So if I can stretch your patience a little further it might be useful if I provide more detail about that objective before pursuing this approach further.

I'll prepare that before I post again.
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
terrypin
Posts: 470
Joined: Tue Jun 29, 2010 9:51 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Asus Z170 Pro 4
processor: Intel Core i7 6700K 4.0GHz
ram: 32 GB
Video Card: None - uses built-in graphics
sound_card: HD onboard sound card
Hard_Drive_Capacity: 4.256 TB
Monitor/Display Make & Model: iLyama Prolite E2403WS 24" 1920x1200
Corel programs: Paint Shop Pro 8; Paint Shop Pro 2018
Location: East Grinstead UK

Re: Digitising a line

Post by terrypin »

Some of the background that I'd intended here we've now covered in the parallel thread
https://forum.corel.com/viewtopic.php?f ... 36#p385136

(Note that I make the majority of my track animations in an entirely different way, capitalising on GPS. I import a GPX into Google Earth and use its own animation functions.)

So it's a minority of cases like the one under discussion which require a reveal technique. And I do most of those in my video editor (Magix Movie Edit Pro Premium), not in PSP. But in either case it gets difficult when the lines are close, or cross or retrace. That's what prompted my original query.

But given the time it takes me to prepare a vector path, plus whatever steps are then needed (hopefully steps I could take without troubling you), I think I will focus on just improving and adapting what I already know.

For example a path like the one below could probably be handled reasonably easily by two reveals plus some simple editing in the video editor to remove unwanted fragments near the single join?

Image
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
Post Reply