Last active
November 4, 2016 21:29
-
-
Save crizCraig/e80a4732ba01d5a2750b88bd9595fbcb to your computer and use it in GitHub Desktop.
DeepDrive.io image parsing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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