mirror of
https://github.com/wassname/scikit-image.git
synced 2026-09-10 12:35:06 +08:00
Add tests for window manager.
This commit is contained in:
@@ -48,7 +48,7 @@ else:
|
||||
iw.show()
|
||||
|
||||
def gtk_show():
|
||||
if window_manager.has_images():
|
||||
if window_manager.has_windows():
|
||||
window_manager.register_callback(gtk.main_quit)
|
||||
gtk.main()
|
||||
else:
|
||||
|
||||
@@ -60,7 +60,7 @@ else:
|
||||
|
||||
def qt_show():
|
||||
global app
|
||||
if app and window_manager.has_images():
|
||||
if app and window_manager.has_windows():
|
||||
app.exec_()
|
||||
else:
|
||||
print 'No images to show. See `imshow`.'
|
||||
|
||||
@@ -42,7 +42,7 @@ class WindowManager(object):
|
||||
|
||||
def _release(self, kit):
|
||||
# releaseing the lock will lose all references to currently
|
||||
# track images and callback.
|
||||
# tracked images and the callback.
|
||||
# this function is private for reason!
|
||||
self._check_locked()
|
||||
if str(kit) == self._guikit:
|
||||
@@ -76,7 +76,7 @@ class WindowManager(object):
|
||||
self._callback_args = cbargs
|
||||
self._callback_kwargs = cbkwargs
|
||||
|
||||
def has_images(self):
|
||||
def has_windows(self):
|
||||
if len(self._windows) > 0:
|
||||
return True
|
||||
else:
|
||||
@@ -117,7 +117,7 @@ def prepare_for_display(npy_img):
|
||||
ignored.
|
||||
|
||||
'''
|
||||
if len(npy_img.shape) < 2:
|
||||
if npy_img.ndim < 2:
|
||||
raise ValueError('Image must be 2D or 3D array')
|
||||
|
||||
height = npy_img.shape[0]
|
||||
@@ -125,9 +125,9 @@ def prepare_for_display(npy_img):
|
||||
|
||||
out = np.empty((height, width, 3), dtype=np.uint8)
|
||||
|
||||
if len(npy_img.shape) == 2 or \
|
||||
(len(npy_img.shape) == 3 and npy_img.shape[2] == 1):
|
||||
if npy_img.dtype in [np.float32, np.float64]:
|
||||
if npy_img.ndim == 2 or \
|
||||
(npy_img.ndim == 3 and npy_img.shape[2] == 1):
|
||||
if np.issubdtype(npy_img.dtype, float):
|
||||
out[:,:,0] = npy_img*255
|
||||
out[:,:,1] = out[:,:,0]
|
||||
out[:,:,2] = out[:,:,0]
|
||||
@@ -136,9 +136,9 @@ def prepare_for_display(npy_img):
|
||||
out[:,:,1] = npy_img
|
||||
out[:,:,2] = npy_img
|
||||
|
||||
elif len(npy_img.shape) == 3:
|
||||
elif npy_img.ndim == 3:
|
||||
if npy_img.shape[2] == 3 or npy_img.shape[2] == 4:
|
||||
if npy_img.dtype in [np.float32, np.float64]:
|
||||
if np.issubdtype(npy_img.dtype, float):
|
||||
out[:,:,:3] = (npy_img[:,:,:3])*255
|
||||
else:
|
||||
out[:,:,:3] = npy_img[:,:,:3]
|
||||
@@ -148,4 +148,4 @@ def prepare_for_display(npy_img):
|
||||
else:
|
||||
raise ValueError('Image must have 2 or 3 dimensions')
|
||||
|
||||
return out
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user