title: how can I modify the brightness&contrast automatically on my images with fiji macro?
body: <p>I try to write a very simple macro with Fiji in order to merge channels and enhance contrast automatically. </p>
  
  <pre><code>dir  = getDirectory("Select input directory"); out  = getDirectory("Select destination directory");
  files  = getFileList(dir);
  //foreach tiff couple files
  for (j=0; j&lt;lengthOf(dir);j+2) {
      channel1 = dir+files[j];
      channel2 = dir+files[j+1];
      open(channel1); 
      open(channel2);
      run("Enhance Contrast", "saturated=0.35"); // the same for the channel1
      run("Apply LUT", "stack"); // the same for the channel1
      run("Merge Channels...", "c1="+channel1+" c2="+channel2);
      run("Z Project...", "projection=[Sum Slices]");
      saveAs("Tiff", out+"merge"+files[j]);
      run("Close");
  }
  </code></pre>
  
  <p>With "enhance contrast", I don't know how I can use the button "auto" of the brightness&amp;contrast window in the macro. The channel 2 is stronger than the first.</p>
  
  <p>And with "apply LUT", an error occur when I have this line : "The display range must first be updated using Image>Adjust>Brightness/Contrast or threshold levels defined using Image>Adjust>Threshold." 
  I changed the threshold level and it still doesn't work...</p>
  
  <p>What could you suggest to me ?</p>