Skip to content

Instantly share code, notes, and snippets.

@crizCraig
Last active November 4, 2016 21:29
Show Gist options
  • Save crizCraig/e80a4732ba01d5a2750b88bd9595fbcb to your computer and use it in GitHub Desktop.
Save crizCraig/e80a4732ba01d5a2750b88bd9595fbcb to your computer and use it in GitHub Desktop.
DeepDrive.io image parsing
SIZE = 227
def show_image_read_from_hdf5_file(img):
from skimage.viewer import ImageViewer
img = np.array(img, dtype='u1')
img = img.transpose((1, 2, 0))
img = img[:, :, ::-1]
viewer = ImageViewer(img.reshape(SIZE, SIZE, 3))
viewer.show()
def prepare_image_for_saving_to_hdf5_file():
img = np.array(Image.open(image_path))
img = img[:, :, ::-1] # RGB => BGR by reversing last dimension
img = img.transpose((2, 0, 1)) # in Channel x Height x Width order (switch from H x W x C)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment