But i thought that this part of the code has already applied threshold.. no?
// =======================================================
var idThrs = charIDToTypeID( "Thrs" );
var desc33 = new ActionDescriptor();
var idLvl = charIDToTypeID( "Lvl " );
desc33.putInteger( idLvl, theIndex );
executeAction( idThrs, desc33, DialogModes.NO );
activeDocument.activeChannels = theArray;