{"id":54,"date":"2017-07-28T15:43:11","date_gmt":"2017-07-28T13:43:11","guid":{"rendered":"https:\/\/wp.uni-koblenz.de\/hyko\/?page_id=54"},"modified":"2017-10-22T22:41:20","modified_gmt":"2017-10-22T20:41:20","slug":"dataset","status":"publish","type":"page","link":"https:\/\/wp.uni-koblenz.de\/hyko\/dataset\/","title":{"rendered":"Dataset"},"content":{"rendered":"<h2>Annotated Dataset<\/h2>\n<p>The second part of our dataset consists of annotated MATLAB Level 5 MAT files. Each of file contains one extracted, preprocessed and annotated hyperspectral image. You may load the file using Python as follows.<\/p>\n<pre>from scipy.io import loadmat\r\ndata = loadmat('path_to_file.mat')\r\n<\/pre>\n<p>This method returns a Python dictionary object with the following entries.<\/p>\n<p><strong> HyKo1:<\/strong><\/p>\n<ul>\n<li><em>data<\/em>: [numpy.ndarray] The preprocessed image<\/li>\n<li>wavelengths: [numpy.ndarray] List of wavelengths, corresponding to the spectral bands of the preprocessed image<\/li>\n<li><em>labels<\/em>: [numpy.ndarray] A per pixel annotation of the\u00a0preprocessed image.<\/li>\n<\/ul>\n<p><strong>Hyko2: <\/strong><\/p>\n<ul>\n<li><em>image<\/em>: [numpy.ndarray] The raw image extracted from the bagfile before preprocessing.<\/li>\n<li><em>data<\/em>: [numpy.ndarray] The preprocessed image<\/li>\n<li>wavelengths: [numpy.ndarray] List of wavelengths, corresponding to the spectral bands of the preprocessed image<\/li>\n<li><em>label_*<\/em>: [numpy.ndarray]* One or more entries start with <em>label_.\u00a0<\/em>Each of them contains a per pixel annotation of the\u00a0preprocessed image.<\/li>\n<li><em>id_<\/em>*: [String]: Unique ID corresponding to each type of annotation to make sure no two annotations are getting confused. This entry is irrelevant for practical usage, however useful for keeping order. The exact names correspond to the names of each of the label_* entries.<\/li>\n<li><em>stats<\/em>: [numpy.ndarray] Six values to determine the exposure of the image. It was used for choosing usable images and\u00a0is irrelevant for practical usage.<\/li>\n<\/ul>\n<p>The following script gives a starting point for usage.<\/p>\n<pre>#!\/usr\/bin\/env python3\r\n\r\nfrom scipy.io import loadmat\r\nfrom argparse import ArgumentParser\r\nimport matplotlib.pyplot as plt\r\n\r\ndef show_img(im, title, **args):\r\n    plt.imshow(im, **args)\r\n    plt.axis('off')\r\n    plt.title(title)\r\n    plt.show()\r\n\r\ndef example(path_in, show):\r\n    # conditional show_img\r\n    img_show = show_img if show else lambda *x, **y: None\r\n\r\n    print('Processing {}.'.format(path_in))\r\n\r\n    # load the file\r\n    data = loadmat(path_in)\r\n\r\n    # what was in the file?\r\n    content = [i for i in data.keys() if not i.startswith('_')]\r\n    print(\"The mat file contains {} entries:\\n{}\".format(len(content), content))\r\n\r\n    # image\r\n    title = \"The 'image' entry is the raw image.\\nIt was captured by the hyper spectral camera.\"\r\n    print(title)\r\n    img_show(data['image'], title, cmap='gray')\r\n\r\n    # ['image', 'data', 'wavelengths', 'stats']\r\n\r\n    # data\r\n    title = \"The 'data' entry contains the extracted hypercube.\\n Its shape is {}x{}x{}\".format(*data['data'].shape)\r\n    print(title)\r\n    img_show(data['data'].sum(axis=-1), title, cmap='gray')\r\n    # access\r\n    hyper = data['data']\r\n    img_show(hyper[:, :, 0], \"\", cmap='gray')\r\n\r\n    # wavelengths\r\n    title = \"The 'wavelengths' entry contains a list of the wavelengths of the hypercube.\"\r\n    print(title)\r\n    plt.plot(data['wavelengths'][0], 'ob')\r\n    plt.title(title)\r\n    plt.show()\r\n\r\ndef main():\r\n    command_help = 'This script loads a mat file and visualizes its content. It\\'s mean to be a starting point.'\r\n    parser = ArgumentParser(description=command_help)\r\n    parser.add_argument('-i', '--input', help='input file [default=\".\/\"]', default='.\/')\r\n    parser.add_argument('-s', '--show', help='show images [Y\/n]', default='Y')\r\n    args = vars(parser.parse_args())\r\n    file_input = args['input']\r\n    show = (args['show'] == 'Y')\r\n    print('Input file:  ', file_input)\r\n    print('Show images: ', show)\r\n    example(file_input, show)\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Annotated Dataset The second part of our dataset consists of annotated MATLAB Level 5 MAT files. Each of file contains one extracted, preprocessed and annotated hyperspectral image. You may load the file using Python as follows. from scipy.io import loadmat data = loadmat(&#8216;path_to_file.mat&#8217;) This method returns a Python dictionary object with the following entries. HyKo1: [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-54","page","type-page","status-publish","hentry","post"],"_links":{"self":[{"href":"https:\/\/wp.uni-koblenz.de\/hyko\/wp-json\/wp\/v2\/pages\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.uni-koblenz.de\/hyko\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wp.uni-koblenz.de\/hyko\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wp.uni-koblenz.de\/hyko\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.uni-koblenz.de\/hyko\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":9,"href":"https:\/\/wp.uni-koblenz.de\/hyko\/wp-json\/wp\/v2\/pages\/54\/revisions"}],"predecessor-version":[{"id":100,"href":"https:\/\/wp.uni-koblenz.de\/hyko\/wp-json\/wp\/v2\/pages\/54\/revisions\/100"}],"wp:attachment":[{"href":"https:\/\/wp.uni-koblenz.de\/hyko\/wp-json\/wp\/v2\/media?parent=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}