Created
June 20, 2017 20:40
-
-
Save nbr23/1f19d31c3e2fd81e258280a454cf0197 to your computer and use it in GitHub Desktop.
Image J Batch red green channel merge and invert (based of http://onlinelibrary.wiley.com/doi/10.1111/j.1365-2818.2007.01719.x/full )
This file contains hidden or 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
| .\ImageJ.exe -eval "macfile=File.openAsString('batch_rg_channels_merge.macro'); eval(macfile);" |
This file contains hidden or 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
| macro "Batch RG Channels Merge" { | |
| sourcedir=getDirectory("Select the source images directory"); | |
| resultdir=getDirectory("Select the result images directory"); | |
| flist=getFileList(sourcedir); | |
| File.makeDirectory(resultdir); | |
| for (i = 0; i < flist.length; i++){ | |
| open(sourcedir + '/' + flist[i]); | |
| fname = File.nameWithoutExtension; | |
| run('RGB Split'); | |
| close(); | |
| selectImage(1); | |
| run('Rename...', 'title=green'); | |
| selectImage(2); | |
| run('Rename...', 'title=red'); | |
| run('Image Calculator...', 'image1=[green] operation=AND image2=[red] create'); | |
| run('Invert'); | |
| run('Rename...', 'title=Result'); | |
| selectWindow('red'); | |
| run('Close'); | |
| selectWindow('green'); | |
| run('Close'); | |
| selectWindow('Result'); | |
| save(resultdir + '/' + fname + '_result.tiff'); | |
| run('Close'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment