Exemple #1
0
def make_tiled_imp(imp):
    """generate a ImageProcessor that is the input tiled 3 time horizontally"""
    ip = imp.getProcessor()
    stack = ImageStack(imp.getWidth(), imp.getHeight())
    for idx in range(3):
        stack.addSlice(ip)
    temp_imp = ImagePlus("temp", stack)
    tile_imp = MontageMaker().makeMontage2(temp_imp, 3, 1, 1, 1, 3, 1, 0,
                                           False)
    temp_imp.close()
    return tile_imp
 def make_montage(self, xy="", montage_name=""):
     if self.channels_to_montage == None:
         channels_to_montage = self.channel_names
     else:
         channels_to_montage = self.channels_to_montage
     w = self.cropped_imps[self.channel_names[0]].width
     h = self.cropped_imps[self.channel_names[0]].height
     new_stack = ImageStack(w, h)
     # print self.cropped_imps.keys()
     for channel in channels_to_montage:
         img = self.cropped_imps[channel].getProcessor()
         new_stack.addSlice(img)
     tomontage = ImagePlus("to montage", new_stack)
     montager = MontageMaker()
     self.montage = montager.makeMontage2(
         tomontage, len(channels_to_montage), 1, 1, 1, len(channels_to_montage), 1, 0, 0
     )
     directory = self.outdir
     file_name = self.name
     save_as = os.path.join(directory, "%s_%s_montage.tif" % (file_name, xy))
     IJ.save(self.montage, save_as)
Exemple #3
0
    def _channelmontage(_imp):  
        """Makes a montage of a single channel ImagePlus object.

        Args:
            _imp (ImagePlus): A single channel ImagePlus object.

        Returns:
            ImagePlus: A montage of the one input channel.
        """        
        dims = _imp.getDimensions() # width, height, nChannels, nSlices, nFrames
        frames = listProduct(dims[2:])
        if frames > gridsize: frames = gridsize
        _montage = MontageMaker().makeMontage2(_imp, hsize, vsize, 1.00, 1, frames, increment, 0, True)
        return _montage
def plotRotation(roi_number, result_path, t, x, y, rotation_speed):
    # plot t-x, t-y, x-y, t-rotation_speed and save plot+roi_number.bmp
    txplot = Plot('x-t plot','time (s)', 'x (pixel)', t, x)
    typlot = Plot('y-t plot','time (s)', 'y (pixel)', t, y)
    xyplot = Plot('x-y plot', 'x (pixel)', 'y (pixel)', x, y)
    tspeedplot = Plot('Rotation speed-t plot','time (s)', 'Rotaion Speed (Hz)', t, rotation_speed)

    graphW = 1000
    graphH = 500
    txplot.setFrameSize(graphW, graphH)
    typlot.setFrameSize(graphW, graphH)
    xyplot.setFrameSize(graphW, graphH)
    tspeedplot.setFrameSize(graphW, graphH)

    #make plots as stack image
    tximp = txplot.getImagePlus()
    xyimp = xyplot.getImagePlus()
    tyimp = typlot.getImagePlus()
    tsimp = tspeedplot.getImagePlus()

    pstack = ImageStack(tximp.width,tximp.height)
    pstack.addSlice(tximp.getProcessor())
    pstack.addSlice(tyimp.getProcessor())
    pstack.addSlice(xyimp.getProcessor())
    pstack.addSlice(tsimp.getProcessor())
    pstackimp = ImagePlus('plots', pstack)

    pstackM = MontageMaker().makeMontage2(pstackimp, 2, 2, 2, 1, 4, 1, 0, False)
    #pstackM.show()
    IJ.saveAs(pstackM, 'BMP', os.path.join(result_path,'Plot' + str(roi_number) + '.bmp'))

    tximp.close()
    xyimp.close()
    tyimp.close()
    tsimp.close()
    pstackM.close()
# testMontageMaker
from ij import IJ, WindowManager, ImageStack, ImagePlus
from ij.io import FileInfo
from ij.plugin import MontageMaker
import jmFijiGen as jmg

IJ.run("Lena (68K)")
lena = IJ.getImage()

lI = [lena, lena, lena]

stack = jmg.makeStackFromListRGB(lI)
mont = MontageMaker()
# starts with a stack (stack) and returns an imp to the montage
# makeMontage2(ImagePlus imp, int columns, int rows, double scale, int first, int last, int inc, int borderWidth, boolean labels) 
imp = mont.makeMontage2(stack, 3, 1, 1.0, 1, 3, 1, 0, False)
imp.show()
Exemple #6
0
	def __fmosa(self) :
		mm = MontageMaker()
		imp = mm.makeMontage2(self.__impRes, 1, self.__impRes.getStackSize(), 1, 1, self.__impRes.getStackSize(), 1, 0, False)
		imp.setTitle("MONTAGE"+self.__name)
		imp.show()
		if self.__fire : IJ.run(imp, "Fire", "")
# # print 'fitGoodness', cv.getFitGoodness()
# # print 'formula', cv.getFormula()
# # fit_params = cv.getParams()
# # print 'fit_params', fit_params

# print all_pc
# print 'mean_cc', sum(all_pc)/len(all_pc)

# Create the 2D visualization of the fit plots
stack_w, stack_h = plot_images[0].getWidth(), plot_images[0].getHeight()
stack_plot = ImageStack(stack_w, stack_h)

# add all the plots in a stack
for id, plot_image in enumerate(plot_images):
    for i in range(HEXAGON_SPACINGS[id]):
        stack_plot.addSlice(
            'plot_' + str(id).zfill(2),
            ImagePlus('empty', ColorProcessor(stack_w,
                                              stack_h)).getProcessor())
    stack_plot.addSlice('plot_' + str(id).zfill(2), plot_image.getProcessor())

imp = ImagePlus('Plot_stack', stack_plot)

montageMaker = MontageMaker()
montage = montageMaker.makeMontage2(imp, 17, 9, 1, 1, imp.getNSlices(), 1, 3,
                                    False)

IJ.save(montage, fit_montage_path)

montage.show()
IJ.log('Done')