コード例 #1
0
  def __init__(self, lst_data_in, show_nums = True, lst_data_mask_in = None):
    self.wx_bmp_arr = rgb_img()
    if(lst_data_in == [None] and lst_data_mask_in == [None] ):
      self._ini_wx_bmp_lst = None

    else:
      self._ini_wx_bmp_lst = []
      for lst_pos in range(len(lst_data_in)):
        #print "lst_pos =", lst_pos
        data_3d_in = lst_data_in[lst_pos]
        xmax = data_3d_in.shape[1]
        ymax = data_3d_in.shape[2]
        # remember to put here some assertion to check that
        # both arrays have the same shape

        if(lst_data_mask_in != None):
          data_3d_in_mask = lst_data_mask_in[lst_pos]

        log_msg = '''
        print "len(data_3d_in) =", len(data_3d_in)
        '''
        self.vl_max = float(np.amax(data_3d_in))
        self.vl_min = float(np.amin(data_3d_in))
        tmp_data2d = np.zeros( (xmax, ymax), 'double')
        tmp_data2d_mask = np.zeros( (xmax, ymax), 'double')
        z_dp = data_3d_in.shape[0]
        single_block_lst_01 = []
        for z in range(z_dp):
          #print "z =", z
          tmp_data2d[:, :] = data_3d_in[z:z + 1, :, :]
          if(lst_data_mask_in != None):
            tmp_data2d_mask[:, :] = data_3d_in_mask[z:z + 1, :, :]
          else:
            tmp_data2d_mask = None

          traditional_generator_of_images_with_matplotlib = '''
          data_sigle_img = self._wx_img(tmp_data2d, show_nums, tmp_data2d_mask)
          #'''

          #new_generator_of_images_with_cpp = '''
          data_sigle_img = self._wx_img_w_cpp(tmp_data2d, show_nums, tmp_data2d_mask)
          #'''

          single_block_lst_01.append(data_sigle_img)

        self._ini_wx_bmp_lst.append(single_block_lst_01)
コード例 #2
0
    def __init__(self,
                 lst_data_in,
                 show_nums=True,
                 palette="black2white",
                 lst_data_mask_in=None):
        self.wx_bmp_arr = rgb_img()
        if lst_data_in == [None] and lst_data_mask_in == [None]:
            self._ini_wx_bmp_lst = None

        else:
            self._ini_wx_bmp_lst = []
            for lst_pos in range(len(lst_data_in)):
                #print "lst_pos =", lst_pos
                data_3d_in = lst_data_in[lst_pos]
                xmax = data_3d_in.shape[1]
                ymax = data_3d_in.shape[2]
                # remember to put here some assertion to check that
                # both arrays have the same shape

                if lst_data_mask_in is not None:
                    data_3d_in_mask = lst_data_mask_in[lst_pos]

                log_msg = '''
        print "len(data_3d_in) =", len(data_3d_in)
        '''
                self.vl_max = float(np.amax(data_3d_in))
                self.vl_min = float(np.amin(data_3d_in))
                tmp_data2d = np.zeros((xmax, ymax), 'double')
                tmp_data2d_mask = np.zeros((xmax, ymax), 'double')
                z_dp = data_3d_in.shape[0]
                single_block_lst_01 = []
                for z in range(z_dp):
                    #print "z =", z
                    tmp_data2d[:, :] = data_3d_in[z:z + 1, :, :]
                    if lst_data_mask_in is not None:
                        tmp_data2d_mask[:, :] = data_3d_in_mask[z:z + 1, :, :]
                    else:
                        tmp_data2d_mask = None

                    data_sigle_img = self._wx_img_w_cpp(
                        tmp_data2d, show_nums, palette, tmp_data2d_mask)

                    single_block_lst_01.append(data_sigle_img)

                self._ini_wx_bmp_lst.append(single_block_lst_01)
コード例 #3
0
def img_arr_n_cpp(show_nums=True):

    n_col = 20
    n_row = 10

    wx_bmp_arr = rgb_img()
    flex_data_in = flex.double(flex.grid(n_row, n_col), 15)
    flex_mask_in = flex.double(flex.grid(n_row, n_col), 0)

    for col in xrange(n_col):
        for row in xrange(n_row):
            flex_data_in[row, col] = col + row

    err_code = wx_bmp_arr.set_min_max(0.0, 28.0)

    palette = "hot ascend"

    if palette == "black2white":
        palette_num = 1
    elif palette == "white2black":
        palette_num = 2
    elif palette == "hot ascend":
        palette_num = 3
    else:  # assuming "hot descend"
        palette_num = 4
    print "before c++"
    img_array_tmp = wx_bmp_arr.gen_bmp(flex_data_in, flex_mask_in, show_nums,
                                       palette_num)
    print "after c++"
    np_img_array = img_array_tmp.as_numpy_array()

    height = np.size(np_img_array[:, 0:1, 0:1])
    width = np.size(np_img_array[0:1, :, 0:1])

    img_array = np.zeros([height, width, 4], dtype=np.uint8)

    #for some strange reason PyQt4 needs to use RGB as BGR
    img_array[:, :, 0:1] = np_img_array[:, :, 2:3]
    img_array[:, :, 1:2] = np_img_array[:, :, 1:2]
    img_array[:, :, 2:3] = np_img_array[:, :, 0:1]

    print "end of np generator"

    return img_array
コード例 #4
0
def GetBitmap_from_np_array(data2d, mask2d):

  time1 = time.time()

  wx_bmp_arr = rgb_img()
  img_array_tmp = wx_bmp_arr.gen_bmp(data2d, mask2d).as_numpy_array()

  height = np.size( img_array_tmp[:, 0:1, 0:1] )
  width = np.size(  img_array_tmp[0:1, :, 0:1] )
  img_array = np.empty( (height, width, 3),'uint8')
  img_array[:,:,:] = img_array_tmp[:,:,:]

  time2 = time.time()
  print ("dif(time) =", time2 - time1 )

  #print "img_array.max =", img_array.max()
  image = wx.EmptyImage(width, height)
  image.SetData( img_array.tostring())
  wxBitmap = image.ConvertToBitmap()       # OR:  wx.BitmapFromImage(image)
  return wxBitmap
コード例 #5
0
def GetBitmap_from_np_array(data2d, mask2d):

    time1 = time.time()

    wx_bmp_arr = rgb_img()
    img_array_tmp = wx_bmp_arr.gen_bmp(data2d, mask2d).as_numpy_array()

    height = np.size(img_array_tmp[:, 0:1, 0:1])
    width = np.size(img_array_tmp[0:1, :, 0:1])
    img_array = np.empty((height, width, 3), "uint8")
    img_array[:, :, :] = img_array_tmp[:, :, :]

    time2 = time.time()
    print(("dif(time) =", time2 - time1))

    # print "img_array.max =", img_array.max()
    image = wx.EmptyImage(width, height)
    image.SetData(img_array.tostring())
    wxBitmap = image.ConvertToBitmap()  # OR:  wx.BitmapFromImage(image)
    return wxBitmap
コード例 #6
0
ファイル: bitmap_from_array.py プロジェクト: dials/dials
  def __init__(self, lst_data_in, show_nums = True, palette = "black2white", lst_data_mask_in = None):
    self.wx_bmp_arr = rgb_img()
    if lst_data_in == [None] and lst_data_mask_in == [None]:
      self._ini_wx_bmp_lst = None

    else:
      self._ini_wx_bmp_lst = []
      for lst_pos in range(len(lst_data_in)):
        #print "lst_pos =", lst_pos
        data_3d_in = lst_data_in[lst_pos]
        xmax = data_3d_in.shape[1]
        ymax = data_3d_in.shape[2]
        # remember to put here some assertion to check that
        # both arrays have the same shape

        if lst_data_mask_in is not None:
          data_3d_in_mask = lst_data_mask_in[lst_pos]

        log_msg = '''
        print "len(data_3d_in) =", len(data_3d_in)
        '''
        self.vl_max = float(np.amax(data_3d_in))
        self.vl_min = float(np.amin(data_3d_in))
        tmp_data2d = np.zeros((xmax, ymax), 'double')
        tmp_data2d_mask = np.zeros((xmax, ymax), 'double')
        z_dp = data_3d_in.shape[0]
        single_block_lst_01 = []
        for z in range(z_dp):
          #print "z =", z
          tmp_data2d[:, :] = data_3d_in[z:z + 1, :, :]
          if lst_data_mask_in is not None:
            tmp_data2d_mask[:, :] = data_3d_in_mask[z:z + 1, :, :]
          else:
            tmp_data2d_mask = None

          data_sigle_img = self._wx_img_w_cpp(tmp_data2d, show_nums, palette, tmp_data2d_mask)

          single_block_lst_01.append(data_sigle_img)

        self._ini_wx_bmp_lst.append(single_block_lst_01)
コード例 #7
0
 def __init__(self):
     self.wx_bmp_arr = rgb_img()
コード例 #8
0
ファイル: img_view_tools.py プロジェクト: ndevenish/DUI
 def __init__(self):
     self.wx_bmp_arr = rgb_img()