OK. Create a 5x5 pixel file. Create three transparent layers, two of which have an opacity of 20%, the third 100%. Draw on one layer a pixel with a brightness of 20, on the other 128, on the third 250. Merge the layers. Compare your histogram from the script with what the histogram panel shows. In general, I found an acceptable simple way of obtaining an accurate histogram of brightness. I combined the code from your script with mine. In CS6 use should use shift_selection_cs6() function. try { app.activeDocument.suspendHistory("Test", "test()") } catch(e) { alert(e); } function test() { function CLM(v1, v2, v3) { function cTT(v) {return charIDToTypeID(v)} (ref1 = new ActionReference()).putProperty(c = cTT('Chnl'), cTT('fsel')); eval('(ref2 = new ActionReference())' + (v = (v1 && v2) ? '.putEnumerated(c, cTT(v1), cTT(v2))' : '')) if (v3) ref2.putName(cTT(v ? 'Lyr ' : 'Chnl'), v3); (dsc = new ActionDescriptor()).putReference(cTT('null'), ref1) dsc.putReference(cTT('T '), ref2), executeAction(cTT('setd'), dsc, DialogModes.NO) } CLM('Chnl', 'Trsp') shift_selection_CC(100, 0); shift_selection_CC(100, 0); shift_selection_CC(0, 100); shift_selection_CC(0, 100); toggle_other_visible() hst = (aD = activeDocument).histogram, aD.selection.deselect() toggle_other_visible() xxx=0 for (var i in hst) xxx+=hst; alert(xxx+"\n\n"+hst) } function toggle_other_visible() { try { var desc = new ActionDescriptor(); var list = new ActionList(); var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) ); list.putReference( ref ); desc.putList( charIDToTypeID( "null" ), list ); desc.putBoolean( charIDToTypeID( "TglO" ), true ); executeAction( charIDToTypeID( "Shw " ), desc, DialogModes.NO ); } catch (e) { alert(e);} } function shift_selection_cs6(shift, contrast, dlg) { try { var desc = new ActionDescriptor(); desc.putUnitDouble( stringIDToTypeID( "refineEdgeBorderRadius" ), charIDToTypeID( "#Pxl" ), 0 ); desc.putUnitDouble( stringIDToTypeID( "refineEdgeBorderContrast" ), charIDToTypeID( "#Prc" ), contrast ); desc.putInteger( stringIDToTypeID( "refineEdgeSmooth" ), 0 ); desc.putUnitDouble( stringIDToTypeID( "refineEdgeFeatherRadius" ), charIDToTypeID( "#Pxl" ), 0 ); desc.putUnitDouble( stringIDToTypeID( "refineEdgeChoke" ), charIDToTypeID( "#Prc" ), shift ); desc.putBoolean( stringIDToTypeID( "refineEdgeAutoRadius" ), false ); desc.putBoolean( stringIDToTypeID( "refineEdgeDecontaminate" ), false ); desc.putEnumerated( stringIDToTypeID( "refineEdgeOutput" ), stringIDToTypeID( "refineEdgeOutput" ), stringIDToTypeID("refineEdgeOutputSelection") ); executeAction( stringIDToTypeID( "refineSelectionEdge" ), desc, (dlg == true)?DialogModes.ALL:DialogModes.NO ); } catch (e) { alert(e); } } function shift_selection_CC(shift, contrast, dlg) { try { var desc = new ActionDescriptor(); desc.putInteger( stringIDToTypeID( "smartBrushRadius" ), 0 ); desc.putInteger( stringIDToTypeID( "smartBrushSmooth" ), 0 ); desc.putUnitDouble( stringIDToTypeID( "smartBrushFeather" ), charIDToTypeID( "#Pxl" ), 0 ); desc.putUnitDouble( stringIDToTypeID( "smartBrushContrast" ), charIDToTypeID( "#Prc" ), contrast ); desc.putUnitDouble( stringIDToTypeID( "smartBrushShiftEdge" ), charIDToTypeID( "#Prc" ), shift ); desc.putBoolean( stringIDToTypeID( "sampleAllLayers" ), false ); desc.putBoolean( stringIDToTypeID( "smartBrushUseSmartRadius" ), false ); desc.putBoolean( stringIDToTypeID( "smartBrushDecontaminate" ), false ); desc.putEnumerated( stringIDToTypeID( "refineEdgeOutput" ), stringIDToTypeID( "refineEdgeOutput" ), stringIDToTypeID( "selectionOutputToSelection" ) ); executeAction( stringIDToTypeID( "smartBrushWorkspace" ), desc, (dlg == true)?DialogModes.ALL:DialogModes.NO ); } catch (e) { alert(e); } } Another example in pictures
... View more