Skip to content

Instantly share code, notes, and snippets.

View kwolbachia's full-sized avatar

Kevin Terretaz kwolbachia

  • CRBM - CNRS
  • Montpellier
View GitHub Profile
@kwolbachia
kwolbachia / RGBroll.ijm
Created April 26, 2022 18:04
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);
@kwolbachia
kwolbachia / inverted_overlay.ijm
Created December 15, 2021 12:43
imagej macro script to invert an image and keep the original colors
// Kevin Terretaz @kWolbachia
// highly inspired by Jerome Mutterer script : https://forum.image.sc/t/invert-rgb-image-without-changing-colors/33571/8
macro "inverted overlay" {
setBatchMode(1);
title = getTitle();
rgbSnapshot();
run("Invert");
run("HSB Stack");
run("Macro...", "code=v=(v+128)%256 slice");
run("RGB Color");
0000 0101 0202 0303 0404 0505 0606 0707
0808 0909 0a0a 0b0b 0c0c 0d0d 0e0f 0f10
1011 1112 1313 1414 1516 1617 1718 1919
1a1b 1b1c 1d1d 1e1f 1f20 2121 2223 2324
2526 2627 2828 292a 2b2b 2c2d 2d2e 2f30
3031 3233 3334 3536 3637 3839 393a 3b3c
3d3d 3e3f 4041 4142 4344 4546 4647 4849
4a4b 4c4d 4d4e 4f50 5152 5354 5556 5758
595a 5b5c 5d5e 5f60 6162 6364 6566 6768
6a6b 6c6d 6e6f 7071 7274 7576 7778 797a
@kwolbachia
kwolbachia / new_LUT_from_selection.ijm
Last active November 10, 2021 17:04
generates a full LUT from part of an existing one. Offrande au grand manitou des LUTs!
// Kevin Terretaz @kwolbachia 10.11.21
// open the LUT you want to transform as a 256x32 8bit image
// run the macro
run("Select All");
waitForUser("adjust the selection to crop");
setBatchMode(1);
run("Duplicate...","duplicate");
run("RGB Color");
run("Scale...",
"x=- y=- width=256 height=65 interpolation=Bicubic average create");
@kwolbachia
kwolbachia / gamma_LUT.groovy
Created November 9, 2021 17:04
gamma adjustment on LUTs with cursor
//Kevin Terretaz 061021
import ij.*
import ij.gui.*
import ij.process.*
import java.awt.image.*
// gammaLUT avec curseur
//possible pour les hyperstacks d'ajuster autant de curseurs que de channels en même temps?
imp = IJ.getImage()
luts = new LUT[0]
// yet another multichannel profile plotter
// with smart lookuptables
// modified and simplified to my tastes + "better" LUT detection
macro "Multiplot" {
id=getImageID();
getDimensions(width, height, channels, slices, frames);
if (selectionType()==-1) exit;
Stack.getPosition(Channel, slice, frame);
getPixelSize(unit, pixelWidth, pixelHeight);
@kwolbachia
kwolbachia / Splitview.ijm
Last active April 15, 2021 18:26
imageJ Fiji Splitview macro
/*----------------------------------------------------------------------------------------------------------------------
For multichannel visualization, 5 channel max
This macro will generate a montage of composite and splited channels in one RGB Image
You can still navigate through slices or frames.
Note : the Splitview image size can be heavy on big hyperstacks due to RGB conversion
Advice : draw a selection before running Spliview, the produced montage will be croped
The new version can ask tu user channel labels and add it in the Splitview with color corresponding to each LUTs.
----------------------------------------------------------------------------------------------------------------------*/
var ChLabels = newArray("GFP","RFP","fRFP","DAPI","Brightfield");
var fontS = 30;
@kwolbachia
kwolbachia / gammaLUT.ijm
Last active April 15, 2021 18:27
imageJ Fiji Gamma LUTs macro
/*
15/04/21 K Terretaz @kWolbachia
visual gamma correction applied on active LUT or all channel LUTs, no modification of pixels data
VERY much inspired by https://github.com/ndefrancesco/macro-frenzy/blob/master/color/gammify_LUT.ijm for its simplicity
and https://imagej.nih.gov/ij/macros/Gamma_LUT.txt for non linear LUTs compatibility
*/
macro "gammaLUT on all channels" {
setGammaLUTAllch(getNumber("gamma",0.7));
}