-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_rgb_values.ijm
71 lines (54 loc) · 1.3 KB
/
extract_rgb_values.ijm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#@File(label = "Input directory", style = "directory") input
#@File(label = "Output directory", style = "directory") output
processFolder(input);
function processFolder(input) {
list = getFileList(input);
list = Array.sort(list);
for (k=0; k < list.length; k++) {
print(list[k]);
processImage(list[k], output);
}
}
function processImage(file, output) {
print("Processing: " + input + File.separator + file);
open(file);
originalName = getTitle();
originalNameWithoutExt = replace( originalName , ".tif" , "");
Stack.getDimensions(width, height, channels, slices, frames);
makeRectangle(0, height * 0.25, width, height / 2);
run("Crop");
for (j=0; j<channels; j++) {
if (j==0) {
color = "r";
}
else if (j==1) {
color = "g";
}
else if (j==2) {
color = "b";
}
else {
color = "u";
}
run("Select All");
run("Plot Profile");
Plot.getValues(x, y);
if (j==0) {
for (i = 0; i < x.length; i++)
{
setResult("x", i, x[i]*1.5);
}
}
for (i = 0; i < y.length; i++) {
setResult(color, i, y[i]);
}
close();
run("Next Slice [>]");
}
profileSaveName = originalNameWithoutExt + ".csv";
savePath = output + File.separator + profileSaveName;
print("Saving: " + savePath);
saveAs("Measurements", savePath );
run("Clear Results");
close();
}