Skip to content

Instantly share code, notes, and snippets.

@kwolbachia
Created April 26, 2022 18:04
Show Gist options
  • Save kwolbachia/4f515741c710e96b7921fa08f9ac25ff to your computer and use it in GitHub Desktop.
Save kwolbachia/4f515741c710e96b7921fa08f9ac25ff to your computer and use it in GitHub Desktop.
imagej macro to create an animation with Hue rotation on a rgb image
//heavily inspired by Jerome Mutterer at https://gist.github.com/mutterer/883b32fb4dd7d9bcbd9a1ee32f1a2fd9
//Thanks!
macro "RGBroll"{
hues=30;
setBatchMode(1);
run("Duplicate...","title=temp");
run("Size...", "width="+Image.width+" height="+Image.height+" depth="+hues+" constrain average interpolation=Bilinear");
run("HSB Stack");
Stack.getDimensions(width, height, channels, slices, frames);
Stack.setChannel(1);
for(i=1; i<=slices; i++) {
showProgress(i, hues);
Stack.setSlice(i);
run("Macro...", "code=v=(v+"+i*256/hues+")%256 slice");
}
run("RGB Color", "slices keep");
setOption("Changes", 0);
run("Animation Options...", "speed=15 start");
setBatchMode(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment