예제 #1
0
    def show_thumbnail_montage(self, wellkey, pos):
        images = db.execute(
            'SELECT %s FROM %s WHERE %s ORDER BY %s' %
            (','.join(p.image_thumbnail_cols), p.image_table,
             dbconnect.GetWhereClauseForWells([wellkey]), p.image_id))
        if images == []:
            return
        imsets = []
        for channels in images:
            try:
                pngs = [Image.open(StringIO(im), 'r') for im in channels]
            except IOError as e:
                pngs = [
                    Image.open(StringIO(b64decode(im)), 'r') for im in channels
                ]

            imsets += [[
                np.fromstring(png.tobytes(), dtype='uint8').reshape(
                    png.size[1], png.size[0]).astype('float32') / 255
                for png in pngs
            ]]

        n_channels = len(imsets[0])
        composite = []
        for i in xrange(n_channels):
            # composite each channel separately
            composite += [
                imagetools.tile_images([imset[i] for imset in imsets])
            ]
        bmp = imagetools.MergeToBitmap(composite, p.image_channel_colors)

        popup = BitmapPopup(self, bmp, pos=pos)
        popup.Show()
    def show_thumbnail_montage(self, wellkey, pos):
        images = db.execute('SELECT %s FROM %s WHERE %s ORDER BY %s'%
                            (','.join(p.image_thumbnail_cols), p.image_table,
                             dbconnect.GetWhereClauseForWells([wellkey]),
                             p.image_id))
        if images == []:
            return
        imsets = []
        for channels in images:
            try:
                pngs = [Image.open(StringIO(im), 'r') for im in channels]
            except IOError as e:
                pngs = [Image.open(StringIO(b64decode(im)), 'r') for im in channels]

            imsets += [[np.fromstring(png.tobytes(), dtype='uint8').reshape(png.size[1], png.size[0]).astype('float32') / 255
                        for png in pngs]]                
        
        n_channels = len(imsets[0])
        composite = []
        for i in xrange(n_channels):
            # composite each channel separately
            composite += [imagetools.tile_images([imset[i] for imset in imsets])]
        bmp = imagetools.MergeToBitmap(composite, p.image_channel_colors)
        
        popup = BitmapPopup(self, bmp, pos=pos)
        popup.Show()
예제 #3
0
    p.image_id = 'ImageNumber'
    p.channels_per_image = [1, 1, 1]
    images = [
        np.ones((200, 200)),
        np.ones((200, 200)) / 2.,
        np.ones((200, 200)) / 4.,
        np.ones((200, 200)) / 8.,
        np.ones((200, 200)),
        np.ones((200, 200)) / 2.,
        np.ones((200, 200)) / 4.,
        np.ones((200, 200)) / 8.,
    ]

    pixels = []
    for channel in p.image_channel_colors:
        pixels += [imagetools.tile_images(images)]

    f = ImageViewer(pixels)
    f.Show()

    ##    if not p.show_load_dialog():
    ##        logging.error('ImageViewer requires a properties file.  Exiting.')
    ##        wx.GetApp().Exit()
    ##        raise Exception('ImageViewer requires a properties file.  Exiting.')
    ##
    ##    db = DBConnect.getInstance()
    ##    dm = DataModel.getInstance()
    ##    ir = ImageReader()
    ##
    ##    obKey = dm.GetRandomObject()
    ##    imagetools.ShowImage(obKey[:-1], p.image_channel_colors, None)
    p.image_names = ['a', 'b', 'c']
    p.image_id = 'ImageNumber'
    p.channels_per_image = [1,1,1]
    images = [np.ones((200,200)),
              np.ones((200,200)) / 2. ,
              np.ones((200,200)) / 4. ,
              np.ones((200,200)) / 8. ,
              np.ones((200,200)),
              np.ones((200,200)) / 2. ,
              np.ones((200,200)) / 4. ,
              np.ones((200,200)) / 8. ,
              ]

    pixels = []
    for channel in p.image_channel_colors:        
        pixels += [imagetools.tile_images(images)]

    f = ImageViewer(pixels)
    f.Show()


##    if not p.show_load_dialog():
##        logging.error('ImageViewer requires a properties file.  Exiting.')
##        wx.GetApp().Exit()
##        raise Exception('ImageViewer requires a properties file.  Exiting.')
##    
##    db = DBConnect.getInstance()
##    dm = DataModel.getInstance()
##    ir = ImageReader()
##    
##    obKey = dm.GetRandomObject()
예제 #5
0
            return
        imsets = []
        for channels in images:
            try:
                pngs = [Image.open(StringIO(im), 'r') for im in channels]
            except IOError, e:
                pngs = [Image.open(StringIO(b64decode(im)), 'r') for im in channels]

            imsets += [[np.fromstring(png.tostring(), dtype='uint8').reshape(png.size[1], png.size[0]).astype('float32') / 255
                        for png in pngs]]                
        
        n_channels = len(imsets[0])
        composite = []
        for i in xrange(n_channels):
            # composite each channel separately
            composite += [imagetools.tile_images([imset[i] for imset in imsets])]
        bmp = imagetools.MergeToBitmap(composite, p.image_channel_colors)
        
        popup = BitmapPopup(self, bmp, pos=pos)
        popup.Show()

        
if __name__ == "__main__":
    app = wx.PySimpleApp()

    data = np.arange(5600.)
    a = np.zeros((40,140))
    i = 0
    for r, row in enumerate(a):
        if r % 2 == 0:
            a[r] = data[i:i+140]
예제 #6
0
                pngs = [
                    Image.open(StringIO(b64decode(im)), 'r') for im in channels
                ]

            imsets += [[
                np.fromstring(png.tobytes(), dtype='uint8').reshape(
                    png.size[1], png.size[0]).astype('float32') / 255
                for png in pngs
            ]]

        n_channels = len(imsets[0])
        composite = []
        for i in xrange(n_channels):
            # composite each channel separately
            composite += [
                imagetools.tile_images([imset[i] for imset in imsets])
            ]
        bmp = imagetools.MergeToBitmap(composite, p.image_channel_colors)

        popup = BitmapPopup(self, bmp, pos=pos)
        popup.Show()

if __name__ == "__main__":
    app = wx.PySimpleApp()

    data = np.arange(5600.)
    a = np.zeros((40, 140))
    i = 0
    for r, row in enumerate(a):
        if r % 2 == 0:
            a[r] = data[i:i + 140]