Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. // ask user to select a folder
  2. dir = getDirectory("Select A folder");
  3. // get the list of files (& folders) in it
  4. fileList = getFileList(dir);
  5. // prepare a folder to output the images
  6. output_dir = dir + File.separator + " output" + File.separator ;
  7. File.makeDirectory(output_dir);
  8.  
  9.  
  10. //activate batch mode
  11. setBatchMode(true);
  12.  
  13. // LOOP to process the list of files
  14. for (i = 0; i < lengthOf(fileList); i++) {
  15. // define the "path"
  16. // by concatenation of dir and the i element of the array fileList
  17. current_imagePath = dir+fileList[i];
  18. // check that the currentFile is not a directory
  19. if (!File.isDirectory(current_imagePath)){
  20. // open the image and split
  21. open(current_imagePath);
  22. // get some info about the image
  23. getDimensions(width, height, channels, slices, frames);
  24. // if it's a multi channel image
  25. if (channels > 1) run("Split Channels");
  26.  
  27. // now we save all the generated images as tif in the output_dir
  28. ch_nbr = nImages ;
  29. for ( c = 1 ; c <= ch_nbr ; c++){
  30. selectImage(c);
  31. currentImage_name = getTitle();
  32. saveAs("tiff", output_dir+currentImage_name);
  33. }
  34. // make sure to close every images befores opening the next one
  35. run("Close All");
  36. }
  37. }
  38. setBatchMode(false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement