Created
October 13, 2014 13:41
-
-
Save mutterer/f3d24dbadac371c9ee90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fix funny LUT for LSM or CZI files opened with Bioformats | |
// parses the file metadata to work around a bioformat bug | |
// that assigns wrong channel colors. | |
var r,g,b; | |
title = getTitle(); | |
id=getImageID; | |
Stack.getDimensions(width, height, channels, slices, frames); | |
activeChannels = ""; | |
for (ch=1;ch<= channels;ch++) { | |
dic = getRealChannelColor(ch); | |
if ((useDic==0)&(dic==1)) activeChannels= activeChannels+"0"; | |
else activeChannels= activeChannels+"1"; | |
applyLUT(ch); | |
} | |
function applyLUT(c){ | |
reds=newArray(256); | |
greens=newArray(256); | |
blues=newArray(256); | |
for (index=0;index<256;index++){ | |
reds[index]=index*r/255; | |
greens[index]=index*g/255; | |
blues[index]=index*b/255; | |
} | |
Stack.setChannel(c); | |
setLut(reds,greens,blues); | |
} | |
function getRealChannelColor(channel){ | |
info=replace(getMetadata('info'),' ',''); | |
List.setList(info); | |
tag="Experiment|AcquisitionBlock|MultiTrackSetup|Track|Channel|Color|#"; | |
rgb = parseInt(substring(List.get(tag+ channel),3),16); | |
r = (rgb&0xff0000)>>16; | |
g =(rgb&0x00ff00)>>8; | |
b =(rgb&0x0000ff); | |
if ((r==g)&&(g==b)) return true; | |
else return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment