Skip to content
Snippets Groups Projects
Commit d9b5fd13 authored by Georgi Tushev's avatar Georgi Tushev :soccer:
Browse files

16bit converter

parent 05d699e5
No related branches found
No related tags found
No related merge requests found
......@@ -19,3 +19,5 @@ Grid/Collection Stiching version: 1.2
[issue](https://forum.image.sc/t/converting-16-bit-signed-tiffs-to-16-bit-unsigned/5847/3) signed vs unsigned 16 bit images
## Microscopy Image Stitching Tool (MIST)
[MIST](https://github.com/USNISTGOV/MIST/wiki/Install-Guide)
\ No newline at end of file
......@@ -50,40 +50,63 @@ function checkPathSeparator(path)
}
/* convert signed to unsigned 16bit
* scales between min and max value
* requires open stack
*/
function convertSignedToUnsigned16bit()
{
run("32-bit");
for (s = 1; s <= nSlices; s++) {
setSlice(s);
getStatistics(area, mean, pixelMin, pixelMax);
run("Subtract...", "value=" + pixelMin);
setMinAndMax(0, 65535);
}
run("16-bit");
for (s = 1; s <= nSlices; s++) {
setSlice(s);
getStatistics(area, mean, pixelMin, pixelMax);
setMinAndMax(pixelMin, pixelMax);
}
}
/* export each image from a stack
* prepends stack index to filename
* @param export path
*/
function exportStackToImages(path)
{
path = checkPathSeparator(path);
run("Stack to Images");
for (i = nImages; 0 < i; i--) {
fileName = getTitle();
fileTag = substring(fileName, 0, lastIndexOf(fileName, "-"));
fileOut = path + "S" + i + "_" + fileTag + ".tif";
saveAs("Tiff", fileOut);
close();
}
}
/* get all files from direcotry
* @param: output directory
* @param: list of files
*/
function preprocessStacks(path, files)
function preprocessStacks(path, files)
{
path = checkPathSeparator(path);
for(f = 0; f < files.length; f++) {
showProgress(f, files.length);
fileIn = files[f];
fileName = File.getName(fileIn);
fileTag = substring(fileName, 0, lastIndexOf(fileName, "."));
fileOut = path + fileName;
run("Bio-Formats Windowless Importer", "open="+fileIn);
getMinAndMax(min, max);
setMinAndMax(0, max - min);
print("min: " + min);
print("max: " + max);
getMinAndMax(min, max);
print("new min: " + min);
print("new max: " + max);
//run("Stack to Images");
//selectWindow(fileTag + "-0002");
//saveAs("Tiff", fileOut);
//close();
//closeImageByTitle(fileTag + "-0001");
break;
convertSignedToUnsigned16bit();
exportStackToImages(path);
//break;
}
}
macro "ScanImageStitching"
......@@ -99,7 +122,7 @@ macro "ScanImageStitching"
filesList = getFileListWithExtension(pathInput, ".tif");
// pre-process
setBatchMode(false);
setBatchMode(true);
preprocessStacks(pathTemp, filesList);
setBatchMode(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment