Skip to content

Instantly share code, notes, and snippets.

@mutterer
mutterer / 26px_Image_to_Tool_Icon.ijm
Last active January 17, 2021 15:25
Convert 26x26 Image to Tool Icon
// This macro converts a 26x26 8-bit image to a tool macro icon
// string. Ideally, the image should have no more than 16 colors.
// Includes seven examples that, with the exception of the
// "Lena Tool", were created by converting website favicons
// (http://en.wikipedia.org/wiki/Favicon).
// v1.0 : 4 April 2006
// v1.1 : 17 January 2021 : works with 26x26px images.
macro "Convert 26x26 Image to Tool Icon..." {
requires("1.35r");
@mutterer
mutterer / bouncingLine_Tool.ijm
Last active January 17, 2021 17:07
A demo of how tool icons can be animated.
// this example uses the Toolbar.setIcon(toolName,icon) method
// This example action tool uses the Toolbar.setIcon() method,
// added in v1.53h, to dynamically update its icon.
// uses extended hex icon coordinates
var icons = newArray( "Ca30N44V00nn","C037N44F00nn");
var colors = newArray( "Cf00","C0f0","C00f","Cf0f");
var xs = newArray(4);
var ys = newArray(4);
var xbs = newArray(4);
@mutterer
mutterer / straighten_animation_v1(20210115).ijm
Created January 15, 2021 15:57 — forked from ekatrukha/straighten_animation_v2(20210128).ijm
ImageJ macro for illustration of "Straighten" ROI function
// Providing an image and polyline, macro illustrates
// (creates a stack with animation)
// "Straighten" ROI function of ImageJ
// 2021.01.15 Eugene Katrukha / katpyxa at gmail dot com
if (nImages<1)
{
exit("This macro needs an input image. Open something");
}
if(selectionType()!=6)
@mutterer
mutterer / HSB_hyperstack_to_RGB_Stack.ijm
Created January 7, 2021 10:57
HSB_hyperstack_to_RGB_Stack.ijm
id=getImageID;
Stack.getDimensions(width, height, channels, slices, frames);
for(i=1; i<=slices; i++) {
selectImage(id);
Stack.setSlice(i)
run("Duplicate...", "duplicate slices=&i-&i");
run("Set Label...", "label=Hue");
run("RGB Color","");
run("Set Label...", "label=");
}
@mutterer
mutterer / ROI_interpolation.ijm
Last active January 3, 2021 11:12
This ImageJ macro creates an animation by interpolating ROI coordinates
// This macro creates an animation by interpolating ROI coordinates
// and drawing each step and fading and blurring the image.
// The active ROI is hidden if batch mode is true.
run("Fresh Start");
newImage("2021", "8-bit black", 256, 256, 1);
run("Fire");
setBatchMode(true); // hide ROIs on active image, requires 1.53h21
@mutterer
mutterer / 2021LUTs_short.ijm
Created December 21, 2020 21:39
A 2021 colourful script
// colours of 2021
call("ij.gui.ImageWindow.centerNextImage");
newImage("2020 LUTs demo", "8-bit black", 512, 256, 1);
r=10;
setForegroundColor(255,255,255);
luts = getList("LUTs");
lut=0;
makeLine(78,90,97,61,134,63,149,91,76,174,66,157,139,180,170,160);
run("Fit Spline");
@mutterer
mutterer / setup_screen_for_recording.js
Last active November 18, 2020 22:54
setup_screen_for_recording.js
// suggested by @noodlyscientist Liat Adler
// this script nicely organizes windows for screen recording
// save this script in the plugins folder
IJ.run("Fresh Start","");
IJ.getInstance().setLocation(0,0);
IJ.run("Macro","");
b=GUI.getScreenBounds()
x=b.width/2; y=b.height/2;
f=WindowManager.getFrame("Macro.ijm")
@mutterer
mutterer / Measuring_with_or_without_holes.ijm
Created November 18, 2020 09:42
Measuring objects with or without holes
run("Fresh Start"); run("Blobs (25K)");
selectWindow('blobs.gif');setLocation(0, 100);
setThreshold(192, 255);
makeRectangle(56, 132, 68, 61);
run("To Selection");
doWand(80, 175);
run("Set Measurements...", "area redirect=None decimal=3");
run("Measure");
print(Table.get('Area',Table.size-1),'Measure, no options');
run("Set Measurements...", "area limit redirect=None decimal=3");
@mutterer
mutterer / import_ab1_sequence_csv_from_cutepeaks.ijm
Last active December 7, 2020 14:28
import_ab1_sequence_csv_from_cutepeaks.ijm
// cutepeaks exports ab1 files as tab delimited csv
// this macro replaces tabs with commas
// reopens peaks file
// and builds a nucleotide plot
// v 1.0 : 20201109
// 1.1 : 20201207 handles csv files with different columns ordering
s=File.openAsString("");
name = File.name;
s=s.replace('\t',',');
// this is what it takes to make a red/geen image
// colorblind friendly
run("Make Composite");
setSlice(1);
run("Magenta");
setSlice(2);
run("Green");
// optional: remove blue channel completely
// (some jpgs have residual blue channel which decrease contrast)