How to use the ndlib.windowcutout.windowCutout function in ndlib

To help you get started, we’ve selected a few ndlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neurodata / ndstore / test / test_time.py View on Github external
def test_window_args(self):
    "Test the window functionality passed as an argument"

    p.args = (3000,3100,4000,4100,200,201,20,22)
    p.window = [0,1500]
    image_data = np.ones([2,2,1,100,100], dtype=np.uint16) * 2000
    response = postNPZ(p, image_data, time=True)

    url = "https://{}/sd/{}/{}/xy/{}/{},{}/{},{}/{}/{}/window/{},{}/".format(SITE_HOST, p.token, p.channels[0], p.resolution, p.args[0], p.args[1], p.args[2], p.args[3], p.args[4], p.args[6], *p.window)
    f = getURL (url)

    from ndlib.windowcutout import windowCutout
    image_data = windowCutout(image_data, p.window).astype(np.uint8)
    slice_data = np.asarray ( Image.open(StringIO(f.content)) )
    assert ( np.array_equal(slice_data, image_data[0][0][0]) )
github neurodata / ndstore / test / test_image.py View on Github external
def test_window_args(self):
    "Test the window functionality"

    p.args = (3000,3100,4000,4100,200,201)
    p.window = [0,1500]
    image_data = np.ones([2,1,100,100], dtype=np.uint16) * 2000
    response = postNPZ(p, image_data)

    url = "https://{}/sd/{}/{}/xy/{}/{},{}/{},{}/{}/window/{},{}/".format(SITE_HOST, p.token, p.channels[0], p.resolution, p.args[0], p.args[1], p.args[2], p.args[3], p.args[4], *p.window)
    f = getURL (url)

    from ndlib.windowcutout import windowCutout
    image_data = windowCutout(image_data, p.window).astype(np.uint8)
    slice_data = np.asarray ( Image.open(StringIO(f.content)) )
    assert ( np.array_equal(slice_data,image_data[0][0]) )
github neurodata / ndstore / test / test_time.py View on Github external
def test_window_default(self):
    "Test the window functionality"

    p.args = (3000,3100,4000,4100,200,201,50,52)
    image_data = np.ones([2,2,1,100,100], dtype=np.uint16) * 2000
    response = postNPZ(p, image_data, time=True)

    url = "https://{}/sd/{}/{}/xy/{}/{},{}/{},{}/{}/{}".format(SITE_HOST, p.token, p.channels[0], p.resolution, p.args[0], p.args[1], p.args[2], p.args[3], p.args[4], p.args[6])
    f = getURL (url)

    from ndlib.windowcutout import windowCutout
    image_data = windowCutout(image_data, p.window).astype(np.uint8)
    slice_data = np.asarray ( Image.open(StringIO(f.content)) )
    assert ( np.array_equal(slice_data, image_data[0][0][0]) )
github neurodata / ndstore / test / test_image.py View on Github external
def test_window_default(self):
    "Test the window functionality"

    p.args = (3000,3100,4000,4100,200,201)
    image_data = np.ones([2,1,100,100], dtype=np.uint16) * 2000
    response = postNPZ(p, image_data)

    url = "https://{}/sd/{}/{}/xy/{}/{},{}/{},{}/{}/".format(SITE_HOST, p.token, p.channels[0], p.resolution, p.args[0], p.args[1], p.args[2], p.args[3], p.args[4])
    f = getURL (url)

    from ndlib.windowcutout import windowCutout
    image_data = windowCutout(image_data, p.window).astype(np.uint8)
    slice_data = np.asarray ( Image.open(StringIO(f.content)) )
    assert ( np.array_equal(slice_data,image_data[0][0]) )
github neurodata / ndstore / webservices / ndwsrest.py View on Github external
"""Performs a window transformation on the cutout area
        window always returns 8-bit data.
     Careful how you use it.  load target data into timeseriescube8.
  """

  if window_range is None:
    window_range = ch.window_range

  [startwindow, endwindow] = window_range

  # KL TODO window with signed channels -a to +b

  if (startwindow == endwindow == 0):
    return np.uint8(data)
  elif endwindow!=0:
    data = windowCutout (data, window_range)
    return np.uint8(data)

  return data
github neurodata / ndstore / django / synaptogram / views.py View on Github external
corner = [ xlow, ylow, zlow ]
      dim = [ xhigh-xlow, yhigh-ylow, zhigh-zlow ]

      outputdict = {}

      # get the data region for each channel 
      for chan in channels:
        # data type on a per channel basis
        ch = proj.getChannelObj(chan)
        try: 
          cb = db.cutout ( ch, corner, dim, resolution )
          # apply window for 16 bit projects 
          if ch.getDataType() in DTYPE_uint16:
            [startwindow, endwindow] = window_range = ch.window_range
            if (endwindow != 0):
              cb.data = np.uint8(windowCutout(cb.data, window_range))
          
          outputdict[chan] = []
          for zslice in cb.data:
          
            if ch.getChannelType() in ANNOTATION_CHANNELS:
              # parse annotation project
              imagemap = np.zeros( [ dim[1], dim[0] ], dtype=np.uint32 )
              imagemap = recolor_ctype( zslice, imagemap )
              img = Image.frombuffer( 'RGBA', (dim[0],dim[1]), imagemap, 'raw', 'RGBA', 0, 1 )

            else: 
              # parse image project  
              img = Image.frombuffer( 'L', (dim[0], dim[1]), zslice.flatten(), 'raw', 'L', 0, 1 )
            
            # convert to base64
            fileobj = cStringIO.StringIO()