-
Notifications
You must be signed in to change notification settings - Fork 10
/
UndoLUT.ijm
32 lines (28 loc) · 867 Bytes
/
UndoLUT.ijm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// from Pete Bankhead.
// Get reference to the original image
idOrig = getImageID();
// Prompt for LUT
luts = getList("LUTs");
Dialog.create("Undo LUT");
Dialog.addChoice("Choose LUT", luts);
Dialog.show();
lut = Dialog.getChoice();
// Create 1x256 image with LUT
newImage("Image-" + lut, "8-bit ramp", 256, 1, 1);
run(lut); // Assume that a default LUT is used...
run("RGB Color");
idLUT = getImageID();
// Loop through & change values in the original
// Take advantage of packed RGB representation
setBatchMode(true);
for (i = 0; i < 256; i++) {
selectImage(idLUT);
val = getPixel(i, 0);
print("Value: " + val);
selectImage(idOrig);
// Create a packed RGB version of the value we want in all 3 channels
changeValues(val, val, (i<<16)|(i<<8)|(i));
}
// Convert to 8-bit... all channels have same values, so should be ok
run("32-bit");
setBatchMode(false);