How to achieve this map editing?

Moderator: Kathy_9

Post Reply
terrypin
Posts: 492
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

How to achieve this map editing?

Post by terrypin »

I suspect this will be a tough one, but here goes.

I frequently capture images like this from my map application.
https://dl.dropboxusercontent.com/u/401 ... rginal.bmp

(I've uploaded what I hope is a pixel accurate image as well as the smaller one embedded here, to allow faithful zoomed colours.)

Image

I'm trying to automate a procedure which will:
1. Remove the dotted lines.
2. Remove the numbers along both scales, but leave the outline curve and axis of the profile intact.

I eventually managed to record a script to do the first, using colour replacement, capitalising on the slightly different pixel colours resulting when I pasted my capture into IrfanView initially, before working in PSP8.

But that obviously doesn't work for the second requirement because the colours of the outline and the numbers are the same: black or close to it.

Manually it would be trivial: just select two rectangles, bottom and left, and delete, leaving the light yellow background. But doing that with a script is beyond me.
Q1: Can it be done and if so can someone get me started please?

Alternatively I turned to Macro Express Pro. I would be able to write a macro for this select and delete task (with difficulty) in just about any other application, by first determining the size and position of the window. I don't know about modern versions, but PSP8 frustratingly prevents my doing that because 'the window' is always treated as the whole PSP8 window. I've so far been unable to access any information programatically about an image window's position and size. Nor do images get displayed at a consistent position (say like flush in the top left corner), so that's no way around the navigation problem either.
Q2: Is there a script or any other clever hack that would get me the size and position please?

Meanwhile I've succeeded with a third option: removing all the dark colours then selecting all the green followed by Selection > Modify > Select Selection Borders and finally restoring an outline border. My first attempt looks like this and I may be able to fine tune it to make this a satisfactory approach.
Image

Still like to know answers above though!

--
Terry, East Grinstead, UK
Last edited by terrypin on Fri Sep 16, 2016 4:50 pm, edited 1 time in total.
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
LeviFiction
Advisor
Posts: 6831
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-2023
Location: USA

Re: How to achieve this map editing?

Post by LeviFiction »

The first and second are probably the easiest, you just have to record those. You can later copy and paste the instructions into a new script. The third step by get more complicated as you would have to be sure the selection was made always in the same place so that place must be guaranteed to always be green. If you can't guarantee that, then maybe a set of steps like:

1) Select All
2) Selections -> Modify -> Color Range (remove the green color from the selection)
3) Invert (to select only the green)
4) Selections -> Modify -> Select Selection borders
5) Fill with black or something.

As for the second part:

If you can calculate where to start and end the selection just by knowing the size of the image, this is then easily programmed into a script. Scripting has a command for creating rectangular selections quickly an easily. And you can grab the size of the image easily with these two variables.

App.TargetDocument.Width
App.TargetDocument.Height

Just make a few assumptions about the starting point always being at zero for left, and how ever many pixels tall the title bar is in the image from the top.

I don't actually have the commands API on this computer so I can't say what they are right off the top of my head.

So here's my recommendation. Record the entire process. This will give you the starting base commands. You can then edit the script to make it smarter by adding logic in between the commands and replacing parameters with variables that you create.
https://levifiction.wordpress.com/
terrypin
Posts: 492
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: How to achieve this map editing?

Post by terrypin »

LeviFiction wrote:The first and second are probably the easiest, you just have to record those.
Thanks, but 'first and second' what? If you mean my two requirements 1 and 2, then I've already achieved 1. So that just leaves 2, there are no others!
You can later copy and paste the instructions into a new script.
What instructions? What new script? I thought it was obvious, but please note that I'm not a programmer or scripter.
The third step...
Sorry if I'm being dense, but I don't follow. I didn't mention a third step!
by get more complicated as you would have to be sure the selection was made always in the same place
So you must be referring to my second step:
2. Remove the numbers along both scales, but leave the outline curve and axis of the profile intact.
...so that place must be guaranteed to always be green.
Green? the black numbers are on a yellow background.
If you can't guarantee that...
Well, no, I can't, as I don't know how to determine size and position (although I see your final comment about that), hence my post.
then maybe a set of steps like:
1) Select All
2) Selections -> Modify -> Color Range (remove the green color from the selection)
3) Invert (to select only the green)
4) Selections -> Modify -> Select Selection borders
5) Fill with black or something.
Was my method OK? It looks like your steps above will give a similar result?
As for the second part:
i.e. you're returning to my second requirement? Which you initially said could be recorded?
If you can calculate where to start and end the selection just by knowing the size of the image, this is then easily programmed into a script.
See above.
Scripting has a command for creating rectangular selections quickly an easily. And you can grab the size of the image easily with these two variables.

App.TargetDocument.Width
App.TargetDocument.Height

Just make a few assumptions about the starting point always being at zero for left, and how ever many pixels tall the title bar is in the image from the top.

I don't actually have the commands API on this computer so I can't say what they are right off the top of my head.

So here's my recommendation. Record the entire process. This will give you the starting base commands. You can then edit the script to make it smarter by adding logic in between the commands and replacing parameters with variables that you create.
Thanks, but I did try a lot of recording before I posted. My skill is way below the level I think you're assuming! :)

On a basic point: I have recorded two scripts as I mentioned. They are called Remove dots on yellow and Remove dots on green. Can I just paste one into the other in my text editor and re-save to get a combined script that will do both operations successively?

--
Terry, East Grinstead, UK
--
Terry, East Grinstead, UK
Using PSP 8 & PSP 2018 under Win 10
LeviFiction
Advisor
Posts: 6831
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-2023
Location: USA

Re: How to achieve this map editing?

Post by LeviFiction »

Technically you have three requirements. And I'm tired so I screwed up some of my wording. The first time I said "second" I meant third. Here are the three requirements as I see them.

1) Remove dots on Yellow and Green backgrounds

2) Remove numbers

3) Outline Green

Since you have scripts for the first one which you just recorded that's the easy one. And the third step is also easily recorded. Your original method for outlining the green was fine if you could guarantee the position clicked with the magic wand tool would always be within the green area. Because scripts use a position for the magic wand tool to compare against. If you can't then my steps get you the same result but are not reliant upon clicking in an exact location.

The second one is the hardest as it requires scripting logic to be added to the script.

Could you post your remove dots scripts to this post?

Also, I tried following your dropbox link and it came up with a 404 error.
https://levifiction.wordpress.com/
terrypin
Posts: 492
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: How to achieve this map editing?

Post by terrypin »

Thanks, understood.

First, sorry about the link. I've posted a new one here:
https://dl.dropboxusercontent.com/u/401 ... rginal.bmp

Secondly, your suggestion about inversion sparked experiment in a fresh direction and I've come up with a neat solution as follows:

Step 1: Using Colour Replacer, change greyish dotted lines with green, removing them from inside the green profile.

Step 2: Select the green with one click of the magic wand.

Step 3: Flash of inspiration! Expand it by 1 px, which therefore now includes the black ouline and x-axis but not the numbers.

Step 4: Invert it.

Step 5. Fill that with colour of choice, say lightish blue, which removes all the unwanted stuff.

https://dl.dropboxusercontent.com/u/401 ... Method.jpg

I've recorded that in two parts and am about to try combining them.

The only part that I'm unsure about are the clicking steps (single and double), as I don't know exactly where on the screen to do that, given my current uncertainty about the image's position and size. Maybe I can find a series of steps that will get it to a consistent position. Although the profile will vary, it can never occupy the extreme corners, so the final fill operation can be done there - once I know where that is!

--------------------

Although I'm happy with this solution, I'm still very interested to learn of any other methods. And more about the initial approach I contemplated, i.e. removing rectangles, although from my novice status that does seem more complicated. However I'm sure there will be occasions when selecting a rectangle will be essential, so I'd like to master it.

--------------------

Let me know if you still want to see one of my scripts. I've made and deleted a dozen or so and they're now in need of some housekeeping!



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