Copy link to clipboard
Copied
Hi Community,
I am working on my research where my advisor shared some images that have small holes in them and he counted them using Photoshop's count feature. I would like to export the data into a text/csv file with pixel location information or as an image file with the dots only (I do not need the numbers). Can anyone help me with what I should do? I found a script that transfers individual points into layers, however, I have around 10000 dots in each image and I do not think converting them into individual layers is a good idea.
Thank you so much for your help in advance. I really appreciate it.
#target photoshop
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), k = s2t('countClass'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var p = executeActionGet(r);
if (p.hasKey(k)) {
var counter = p.getList(k),
n = (new File).saveDlg('Save file', '*.csv');
if (n) {
if (n.open('w', 'TEXT')) {
n.write('x;y\n')
for (var i = 0; i < counter.count; i++) {
var c = counter.getObject
...
Change last 3 lines in my code from How to read position of all count items in document to:
fle = File('~/desktop/.csv'), csv = ''; for(i = 0; i < count; i++)
csv += [xy(i, 'x'), xy(i, 'y')] + (i - count + 1 ? '\n' : '')
fle.open('w'), fle.write(csv), fle.close()
Copy link to clipboard
Copied
What do you mean by small holes? Are these dots filled with a uniform background color? Transparent?
Copy link to clipboard
Copied
Here is a sample image. These yellow dots are actually holes in the tissue. They are labelled and counted using Photoshop's count feature. Right now I have this in Photoshop.
I need to export the markers (either as an image or pixel locations), without the numbers. Please let me know if you need anymore information.
Copy link to clipboard
Copied
#target photoshop
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), k = s2t('countClass'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var p = executeActionGet(r);
if (p.hasKey(k)) {
var counter = p.getList(k),
n = (new File).saveDlg('Save file', '*.csv');
if (n) {
if (n.open('w', 'TEXT')) {
n.write('x;y\n')
for (var i = 0; i < counter.count; i++) {
var c = counter.getObjectValue(i)
n.write(c.getDouble(s2t('x')) + ';' + c.getDouble(s2t('y')) + '\n')
}
n.close()
}
}
}
Copy link to clipboard
Copied
This worked perfectly. Thank you so much!!!!
Copy link to clipboard
Copied
Change last 3 lines in my code from How to read position of all count items in document to:
fle = File('~/desktop/.csv'), csv = ''; for(i = 0; i < count; i++)
csv += [xy(i, 'x'), xy(i, 'y')] + (i - count + 1 ? '\n' : '')
fle.open('w'), fle.write(csv), fle.close()