Skip to content

Instantly share code, notes, and snippets.

@kwolbachia
Last active November 10, 2021 17:04
Show Gist options
  • Save kwolbachia/0060272e477165ac34d7c0787f8a5860 to your computer and use it in GitHub Desktop.
Save kwolbachia/0060272e477165ac34d7c0787f8a5860 to your computer and use it in GitHub Desktop.
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");
R = newArray(1); G = newArray(1); B = newArray(1);
for (i = 0; i < 256; i++) {
c = getPixel(i, 2);
R[i] = (c>>16)&0xff; G[i] = (c>>8)&0xff; B[i] = c&0xff;
}
newImage("new LUT", "8-bit ramp", 256, 32, 1);
setLut(R, G, B);
setBatchMode(0);
@kwolbachia
Copy link
Author

kwolbachia commented Nov 10, 2021

open in ImageJ.JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment