Custom Voronoi/ heat-map based on score

Hi all,

I have spreadsheet with a few thousands of rows of XY coordinates and a score. I would like to create a sort of Voronoi diagram or heat-map with colours based on the score and using the coordinates indicated.

Below an example of table:

X Y Score
-1.405 1.7813 1
0.3888 1.7656 2
-0.4946 1.7769 3

I have no idea how to do it. Could anyone suggest how it would be possible to make it ?

Thank you very much

You would have to import your x y coordinates as point ROIs.
Then use https://imagej.net/Delaunay_Voronoi

Thank you @markkitt,

I still don’t know how to apply the “score” to the voronoi. Any suggestions ?

Thanks

So I have the following but I’d like to fill the rectangle I draw with a greyscale value indicated by the ‘‘iLabel’’ variable. But I don’t know which function to use… Any suggestions ?

file = File.openDialog("Select the text file to read");
allText = File.openAsString(file);
text = split(allText, "\n");
hdr = split(text[0]);

//these are the column indices
iX = 0;
iY = 1;
iLabel = 2;

setForegroundColor(0,0,0);

newImage("Untitled", "8-bit black", 1000, 1000, 1);

for (i = 1; i < (text.length); i++){
   line = split(text[i]);
   makeRectangle(line[iX], line[iY], 1, 1);
   run("Fill", "slice"); //  Here I'd like to fill with a greyscale value indicated by the ''iLabel'' variable 
  
}
print("finish");

Macro adapted from here: http://imagej.1557.x6.nabble.com/Import-XY-from-text-file-to-point-selections-td3692339.html

Thanks

Hi,

Here’s how I ended up doing it in case someone in the future needs it.

// begin macro
file = File.openDialog("Select the text file to read");
allText = File.openAsString(file);
text = split(allText, "\n");
hdr = split(text[0]);

//these are the column indices
iX = 0;
iY = 1;
iLabel = 2;

newImage("Untitled", "RGB black", 5010, 5010, 1);
for (i = 1; i < (text.length); i++){
	//for (i = 1; i < 1000; i++){
   line = split(text[i]);
   makeRectangle(line[iX], line[iY], 10, 10);
   setForegroundColor(line[iLabel]+1,line[iLabel]+1,line[iLabel]+1);
   run("Fill", "slice");
}
run("8-bit");
print("finish");

Although I’m pretty sure there are better ways of doing it.

2 Likes

Herbie [1] sent me the attached ImageJ-macro “voronoi.ijm” to forward to you in case you still need it. (Sample data “Results.txt” is included with the ZIP-archive.)

Archiv.zip (1.2 KB)

[1] https://www.mcn.uni-muenchen.de/members/associate/gluender/index.html

1 Like