def do_projection(self, channel, proj_type=None): proj = ZProjector() ## create projection class if proj_type is None: if self.do_z[channel] == "MAX": proj.setMethod(ZProjector.MAX_METHOD) elif self.do_z[channel] == "AVG": proj.setMethod(ZProjector.AVG_METHOD) else: print "Dont know how to project this way" print "Just using a single slice for images!!" return None else: if proj_type == "MAX": proj.setMethod(ZProjector.MAX_METHOD) elif proj_type == "AVG": proj.setMethod(ZProjector.AVG_METHOD) else: print "Dont know how to project this way" print "Just using a single slice for images!!" return None proj.setImage(self.stack_imps[channel]) proj.doProjection() projection = proj.getProjection() conv = ImageConverter(projection) conv.convertToGray16() conv.setDoScaling(False) self.projections[channel] = projection self.projections_done[channel] = self.do_z[channel]
def convert(filepath, targetFolder): imp = IJ.openImage(filepath) if imp.getType() == ImagePlus.GRAY32: ic = ImageConverter(imp) ic.setDoScaling(False) ic.convertToGray16() filename = os.path.basename(filepath) writeZip(imp, os.path.join(targetFolder, filename), title=filename) else: syncPrint("Not a 32-bit image: " + filename)
from loci.plugins import BF from loci.plugins.in import ImporterOptions import os,sys path = '/Users/justin/UTS/Research/microscopy/' filetab = '%s/ijfiles' %path for l in open(filetab): f = l.strip().split() out = f[0] ch1 = '%s/%s' %(path,f[1]) ch2 = '%s/%s' %(path,f[2]) print('%s: opening %s and %s' %(out,ch1,ch2)) ch1 = ij.IJ.openImage(ch1) conv = ImageConverter(ch1) conv.convertToGray16() # ch1.show() ch2 = ij.IJ.openImage(ch2) conv = ImageConverter(ch2) conv.convertToGray16() # ch2.show() # ch1.close() # ch2.close() mrg = RGBStackMerge.mergeChannels([ch1, ch2], False) # mrg.show() mrgf = '%s/%s.merged.tiff' %(path,out) ij.IJ.saveAs(mrg,"Tiff",mrgf) mrg.close() opts = ImporterOptions() opts.setId(mrgf) opts.setColorMode(ImporterOptions.COLOR_MODE_COMPOSITE)