def make_rgb_arrays(self, state): obs = state['pw_obs'] rgb = ind_to_rgb(obs, LUT) # TODO: better size control size = [10 * rgb.shape[0], 10 * rgb.shape[1]] rgb = better_imresize(rgb, size, interp='nearest') return [rgb]
def make_rgb_arrays(self, state): obs = self.make_observation(state) rgb = ind_to_rgb(obs, LUT) # max_dim = float(max(rgb.shape)) #get the resize factor # #f = max(self._render_size)/max_dim #resize for viewing # f = max([x/float(y) for x,y in zip(self._render_size, rgb.shape)]) # size = [2*int(rgb.shape[0]*f/2.), 2*int(rgb.shape[1]*f/2.)] # TODO: better size control size = [10 * rgb.shape[0], 10 * rgb.shape[1]] rgb = better_imresize(rgb, size, interp='nearest') return [rgb]
def make_rgb_arrays(self, state): if state['signal'] == self.positive_signal: color = 9 elif state['signal'] == self.negative_signal: color = 2 else: color = 7 ind = np.array([[color]]) rgb = ind_to_rgb(ind, LUT) size = [50, 50] rgb = better_imresize(rgb, size, interp='nearest') return [rgb]
def test_ind_to_rgb(self): """Check that ind_to_rgb works as expected""" val = np.zeros((2, 2), dtype=int) val[0, 1] = 1 val[1, 0] = 2 val2 = utils.ind_to_rgb(val, utils.base_lut) self.assertEqual(val2.shape, (2, 2, 3)) self.assertTrue(np.array_equal(val2[0, 0, :], utils.base_lut[0])) self.assertTrue(np.array_equal(val2[0, 1, :], utils.base_lut[1])) self.assertTrue(np.array_equal(val2[1, 0, :], utils.base_lut[2])) self.assertTrue(np.array_equal(val2[1, 1, :], utils.base_lut[0]))