Mobile app version of vmapp.org
Login or Join
LarsenBagley460

: Coordinates of dots on screen Ok so I have a picture of a map with little dots for each city on the map, and I want to find the coordinates of each dot. The only way I've been able to

@LarsenBagley460

Posted in: #AdobePhotoshop #PhotoshopScripting

Ok so I have a picture of a map with little dots for each city on the map, and I want to find the coordinates of each dot. The only way I've been able to think of was using the "info" panel on photoshop and hovering the mouse over each dot then alt+tabbing on a text file and typing up the coordinates then returning to the dots, doing that over and over.

And that's pretty boring and time-consuming, so I was wondering if there was another way. I don't actually care if I have to erase the map and separate the points to do it, I just need the names of the cities and their coordinates in pixels.

Is there a non-boring way of doing this?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @LarsenBagley460

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kimberly620

Do this:


Select the black dots with Select → Color Range.... Pick any point on a dot and use a large fuzziness of say 103. Dont worry that the text gets selected we will deal with that next.
Shrink the selection by 3 pixels, choose Select → Modify → Contract..., contract by 3 points (in this image).
With the select tool active right click on canvas and chose Make Work Path, use a setting of 0.5
Run following script, choose a file name to put data into:

#target photoshop

main();

function main() {
var layers = app.activeDocument.pathItems[0];
var file = File.saveDialog('save marker info', 'markerinfo:*.txt');
file.open('w');
handleSubpaths(layers, file);
file.close();
}


function handleSubpaths(path, file){
var numLayers = path.subPathItems.length;
file.write("name, position x, position yn" );
for (var j = 0; j < numLayers; j++) {
var subpath = path.subPathItems[j];
var pos = average(subpath.pathPoints);
file.write(
"marker_"+ (j+1) +", " +
pos[0] + ", "+
pos[1] + "n"
);
}
}


function average(points){
ret = [0,0]
for (var i = 0; i < points.length; i++){
var p = points[i].anchor;
ret[0] += p[0]/points.length;
ret[1] += p[1]/points.length;
}
return ret;
}

Read the data from the text file, or use a spreadsheet. Excerpt form result:

name, position x, position y
marker_1, 388.75, 137.5
marker_2, 509.5, 180.25
marker_3, 792.25, 179.5
marker_4, 403.75, 183.5
....



Done. Anyway, if you can find a vector version of the image and use illustrator one could automatically scrape the names also.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme