mouseland commited on
Commit
f453514
·
verified ·
1 Parent(s): f62e231

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -254,8 +254,22 @@ def tif_view(filepath):
254
  fpath, fext = os.path.splitext(filepath)
255
  if fext in ['tiff', 'tif']:
256
  img = imread(filepath[-1])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  filepath = fpath+'.png'
258
- imsave(filepath, img)
259
  return filepath
260
 
261
  def update_image(filepath):
 
254
  fpath, fext = os.path.splitext(filepath)
255
  if fext in ['tiff', 'tif']:
256
  img = imread(filepath[-1])
257
+ if img.ndim==2:
258
+ img = np.tile(img[:,:,np.newxis], [1,1,3])
259
+ elif img.ndim==3:
260
+ imin = np.argmin(img.shape)
261
+ if imin<2:
262
+ img = np.tranpose(img, [2, imin])
263
+ else:
264
+ Raise ValueError("TIF cannot have more than three dimensions")
265
+
266
+ Ly, Lx, nchan = img.shape
267
+ imgi = np.zeros((Ly, Lx, 3))
268
+ nn = np.minimum(3, img.shape[-1])
269
+ imgi[:,:,:nn] = img[:,:,:nn]
270
+
271
  filepath = fpath+'.png'
272
+ imsave(filepath, imgi)
273
  return filepath
274
 
275
  def update_image(filepath):