Skip to content

Instantly share code, notes, and snippets.

@mutterer
mutterer / warhiants.ijm
Last active July 18, 2021 22:53
ImageJ macro that creates a montage with hue shifted image copies.
// emoji from https://emojipedia.org/
url="https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/whatsapp/273/face-with-medical-mask_1f637.png";
hues=8;
open(url);
setBatchMode(1);
run("Duplicate...","title=temp");
Color.setForeground("blue");floodFill(0, 0);
run("Size...", "width="+Image.width+" height="+Image.height+" depth="+hues+" constrain average interpolation=Bilinear");
run("HSB Stack");
Stack.getDimensions(width, height, channels, slices, frames);
@mutterer
mutterer / RGB_Histogram.ijm
Created July 15, 2021 15:03
An ImageJ macro that draws a RGB Histogram
setBatchMode(1);
if (bitDepth!=24) exit();
t=getTitle;
run("Duplicate...","title="+t);
run("Make Composite");
Stack.setChannel(1);
getHistogram(values, reds, 256);
Array.getStatistics(reds, rmin, rmax, mean, stdDev);
Stack.setChannel(2);
getHistogram(values, greens, 256);
var x=setup();
macro "Play Action Tool - C0f0H000ff800C000G000ff800" {
run("Boats");
run("Spectrum");
}
function setup() {
print ("Press play tool to run macro");
return 1;
@mutterer
mutterer / typewriter_.ijm
Created June 1, 2021 15:01
types and evals lines of IJ macro code
run("Fresh Start");
print ("\\Clear");
eval('script','WindowManager.getWindow("Log").getTextPanel().setFont(new Font("Monospaced",Font.PLAIN,18),true);');
print("");
s=split(File.openAsString("Macrodemo.ijm"),"\n");
for (i=0;i<s.length;i++){
for (c=0;c<s[i].length;c++) {
print ("\\Update"+i+2+": "+s[i].substring(0,c+1));
beep();
wait(random()*100);
@mutterer
mutterer / makeLut_.ijm
Created May 28, 2021 09:33
creates a linear lookup table between color a and color b
run("Boats");
makeLut("#009100","#ccff42");
function makeLut(a,b) {
a = Color.toArray(a);
b = Color.toArray(b);
reds=newArray(256);
greens=newArray(256);
blues=newArray(256);
for (i=0;i<reds.length;i++) {
@mutterer
mutterer / inkscape_figure_insert_calibration_bar.txt
Created April 14, 2021 21:47
inkscape_figure_insert_calibration_bar.txt
luts = getList("LUTs");
Dialog.create("Which LUT?");
Dialog.addChoice("LUT", luts);
Dialog.show();
lut=Dialog.getChoice();
run(lut);
@mutterer
mutterer / Better_Wand_Tool.ijm
Last active January 4, 2024 17:42
Better Wand Tool
macro "Better Wand Tool - C000T0f10BT7f10WTff10T" {
if (!isOpen("ROI Manager")) run("ROI Manager...");
smoothness= call('ij.Prefs.get','bwt.selectSmoothness',3);
getCursorLoc(x, y, z, flags);
id=getImageID;
setBatchMode(1);
run("Select None");
run("Duplicate...","title=a");
run("Gaussian Blur...", "radius="+smoothness);
id2=getImageID;
@mutterer
mutterer / MultiRoiMove_Tool.ijm
Created March 14, 2021 18:32
An ImageJ tool macro to move several ROIs
macro "MultiRoiMove Tool - C00cT0f16M" {
if (RoiManager.selected<2) exit();
indexes=split(call("ij.plugin.frame.RoiManager.getIndexesAsString"));
roiManager("Combine");
getCursorLoc(x, y, z, modifiers);
Roi.getBounds(x0, y0, width, height);
while(modifiers&16>0) {
getCursorLoc(x1, y1, z, modifiers);
Roi.move(x0+x1-x, y0+y1-y);
}
@mutterer
mutterer / open_with_lut.ijm
Created February 18, 2021 08:12
Applying LUTs when opening a file
// applying a defined LUTs sequence when opening a file.
// suggested by Debora Keller Olivier @olivier_debora
run("Action Bar","/plugins/ActionBar/open_with_lut.ijm");
exit();
<text><html><h2>Drop your image here</h2></html>
<line>
<button>
@mutterer
mutterer / Toggle_channels.ijm
Last active February 18, 2021 07:19
A macroset to toggle channel in composite images.
// suggested by Michael Nelson @IAMichaelNelson
// Senthil Arumugam @dopaminator suggested the jitter channel vizassist function
macro "toggle CH1 [F1]" {toggleChannel(1);}
macro "toggle CH2 [F2]" {toggleChannel(2);}
macro "toggle CH3 [F3]" {toggleChannel(3);}
macro "toggle CH4 [F4]" {toggleChannel(4);}
macro "toggle CH5 [F5]" {toggleChannel(5);}
macro "toggle CH6 [F6]" {toggleChannel(6);}
macro "toggle CH7 [F7]" {toggleChannel(7);}