Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 85 lines (68 sloc) 3.083 kB
''' - functions to interact with the ImageJ window manager
# CellProfiler is distributed under the GNU General Public License.
# See the accompanying file LICENSE for details.
# Copyright (c) 2003-2009 Massachusetts Institute of Technology
# Copyright (c) 2009-2012 Broad Institute
# Please see the AUTHORS file for credits.
# Website:
__version__ = "$Revision$"
import cellprofiler.utilities.jutil as J
from imagej.imageplus import get_imageplus_wrapper
def get_current_image():
'''Get the WindowManager's current image
returns a wrapped ImagePlus object
imageplus_obj = J.static_call('ij/WindowManager','getCurrentImage',
return get_imageplus_wrapper(imageplus_obj)
def get_id_list():
'''Get the list of IDs of open images'''
jid_list = J.static_call('ij/WindowManager', 'getIDList', '()[I')
return J.get_env().get_int_array_elements(jid_list)
def get_image_by_id(imagej_id):
'''Get an ImagePlus object by its ID'''
return get_imageplus_wrapper(J.static_call(
'ij/WindowManager', 'getImage', '(I)Lij/ImagePlus;', imagej_id))
def get_image_by_name(title):
'''Get the ImagePlus object whose title (in the window) matches "title"'''
return get_imageplus_wrapper(J.static_call(
'ij/WindowManager', 'getImage', '(Ljava/lang/String;)Lij/ImagePlus;',
def get_temp_current_image():
'''Get the temporary ImagePlus object for the current thread'''
return get_imageplus_wrapper(J.static_call(
'ij/WindowManager', 'getTempCurrentImage','()Lij/ImagePlus;'))
def make_unique_name(proposed_name):
'''Create a unique title name for an imageplus object'''
return J.static_call('ij/WindowManager', 'makeUniqueName',
def set_temp_current_image(imagej_obj):
'''Set the temporary current image for this thread'''
J.static_call('ij/WindowManager', 'setTempCurrentImage',
'(Lij/ImagePlus;)V', imagej_obj.o)
def set_current_image(imagej_obj):
'''Set the currently active window'''
image_window = imagej_obj.getWindow()
J.static_call('ij/WindowManager', 'setCurrentWindow',
'(Lij/gui/ImageWindow;)V', image_window)
def close_all_windows():
'''Close all ImageJ windows
Hide the ImageJ windows so that they don't go through the Save dialog,
then call the Window Manager's closeAllWindows to get the rest.
jimage_list = J.static_call('ij/WindowManager', 'getIDList', '()[I')
if jimage_list is None:
image_list = J.get_env().get_int_array_elements(jimage_list)
for image_id in image_list:
ip = J.static_call('ij/WindowManager', 'getImage',
'(I)Lij/ImagePlus;', image_id)
ip = get_imageplus_wrapper(ip)
J.static_call('ij/WindowManager', 'closeAllWindows', '()Z')
Jump to Line
Something went wrong with that request. Please try again.