Last active
December 7, 2020 06:42
-
-
Save romainGuiet/d10fbb28913144bd6ea65ff75a9e6c9c to your computer and use it in GitHub Desktop.
A imagej macro to create the image from Figure 3, https://f1000research.com/articles/9-1380/v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oneOval = 1 ; | |
//size_Array = newArray(1,5,10,20,50,100); | |
size_Array = newArray(7,9,11,15,20,25,50); | |
int_Array = newArray(5,10,20,50,100,150,250); | |
Array.getStatistics(size_Array, size_Array_min, size_Array_max, size_Array_mean, size_Array_stdDev); | |
//print(size_Array_max); | |
step = 3*size_Array_max; | |
x_offSet = step/2; | |
y_offSet = step/2; | |
//create an image | |
w_imageSize = x_offSet+lengthOf(int_Array)*step ; | |
h_imageSize = y_offSet+lengthOf(size_Array)*step; | |
newImage("Untitled", "8-bit black", w_imageSize, h_imageSize, 1); | |
//Define Background and Noise | |
value_background = 2; | |
noise_background = 0.5 ; | |
run("Add...", "value="+value_background); | |
run("Add Specified Noise...", "standard="+noise_background); | |
//waitForUser; | |
y_current = y_offSet ; | |
for ( sizeIndex = 0 ; sizeIndex < lengthOf(size_Array); sizeIndex++) { | |
w = size_Array[sizeIndex]; | |
h = w ; | |
x_current = x_offSet + (size_Array_max/2)- w/2 ; | |
for ( intIndex = 0 ; intIndex < lengthOf(int_Array); intIndex++) { | |
//define gray level | |
c = int_Array[intIndex]; | |
//make the | |
if (oneOval) makeColoredOval(c,x_current,y_current,w,h); | |
else make3ColoredOval(c,x_current,y_current,w,h); | |
x_current = x_current+step; | |
} | |
y_current = y_current+step; | |
} | |
run("Fire"); | |
//run("glasbey_inverted"); | |
function makeColoredOval(c,x,y,w,h){ | |
makeOval(x, y, w, h); | |
//setForegroundColor(c, c, c); | |
//run("Fill"); | |
run("Add...", "value="+c); | |
Roi.setName(IJ.pad(x,5)+"-"+IJ.pad(y,5)+"-"+IJ.pad(c,5)+"-"+IJ.pad(w,5)); | |
roiManager("Add"); | |
run("Select None"); | |
} | |
function make3ColoredOval(c,x,y,w,h){ | |
makeColoredOval(c,x ,y ,w,h); | |
makeColoredOval(c,x-1.05*w ,y+0.25*w ,w,h); | |
makeColoredOval(c,x-0.25*w ,y+1.05*w ,w,h); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment