<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yaswanth Nag on Medium]]></title>
        <description><![CDATA[Stories by Yaswanth Nag on Medium]]></description>
        <link>https://medium.com/@yaswanthnag12?source=rss-3a45e8001f61------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lK9Mo-CNogU0egIR.jpg</url>
            <title>Stories by Yaswanth Nag on Medium</title>
            <link>https://medium.com/@yaswanthnag12?source=rss-3a45e8001f61------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 12:59:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yaswanthnag12/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hyperspectral Image Reconstruction]]></title>
            <link>https://medium.com/hyperspectral-image-reconstruction/hyperspectral-image-reconstruction-c2002275423e?source=rss-3a45e8001f61------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2002275423e</guid>
            <dc:creator><![CDATA[Yaswanth Nag]]></dc:creator>
            <pubDate>Tue, 16 Jun 2020 13:55:55 GMT</pubDate>
            <atom:updated>2020-06-17T08:40:23.384Z</atom:updated>
            <content:encoded><![CDATA[<p>Converting Normal Images to Hyperspectral Images</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*cLv1ZgZ9nbhhHTccI4LKPA.png" /><figcaption>NORMAL VS HYPERSPECTRAL IMAGE</figcaption></figure><p>Before going to understand about Hyperspectral images, let us discuss some fundamental things. Now-a-days everyone is having a smartphone in their hands and always try to pose for a selfie.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*-m4cfU1NsbXI-Q59O9ZuhQ.png" /><figcaption>Capturing a photo on Smartphone</figcaption></figure><p>Look at the above picture and see how the mobile camera is capturing the beauty of nature. It looks very colorful and almost every color which we experience through our eyes is captured by this device. But there may be some aspects of the given image which might not be visible to our naked eyes. This is where the hyperspectral images come into play.</p><p><strong>What is a Hyperspectral Image?</strong></p><p>A normal image comprises of 3 color channels: Red, Green, Blue. Hence these images are referred to as RGB Images. This is the way how our eyes capture the environment and giving it a view how colorful it is. Human eyes can only perceive the images only if the light reflected from the objects falls in the visible spectrum which is ranging between wavelengths of 3 colors (RGB).</p><p>A <strong>Hyperspectral Image</strong> is a image that consists information from across the electromagnetic spectrum. <strong>Hyperspectral imaging</strong> (HSI) is a technique that analyzes a wide spectrum of light instead of just assigning primary colors (red, green, blue) to each pixel. The light striking each pixel is broken down into many different spectral bands in order to provide more information, with the purpose of finding objects, identifying materials, or detecting processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*KOKWsf3_HNcviCFEUIE09w.png" /><figcaption>Hyperspectral Imaging</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*xLrUC8o9qUX8J2AdmDU94Q.png" /><figcaption>RGB vs Hyperspectral Image</figcaption></figure><p><strong>Reconstruction of Hyperspectral images using RGB:</strong></p><p>Hyperspectral recovery from a single RGB image has seen a great improvement with the development of deep convolutional neural networks (CNNs). There are many approaches for hyperspectral image reconstruction, we’ll discuss one of them in this article.</p><p>Hyperspectral recovery from RGB images is a severely ill-posed problem, since much information is lost after integrating the hyperspectral radiance into RGB values. Recently, with the success of deep learning in many computer vision tasks, CNN based methods are also introduced to this task. Among these methods, Xiong et al. proposed a unified deep learning framework, i.e., HSCNN, for hyperspectral recovery from both RGB and compressive measurements.</p><p>HSCNN is one of the first CNN-based methods for hyperspectral recovery from a single RGB image. HSCNN first upsamples the RGB input to a hyperspectral image using a spectral interpolation algorithm. This spectrally upsampled image has the same number of bands as the expected hyperspectral output. Then, the network takes the spectrally upsampled image as input and predicts the missing details (residuals) by learning a stack of convolutional layers.</p><p>As the spectral upsampling requires the knowledge of the spectral response function, HSCNN cannot be applied in the situation when the spectral response function is unknown. Actually, the explicit upsampling is suboptimal and can be replaced by a simple convolution layer. Also, according to the results of HSCNN, it fails to achieve an improved performance with the growth of the network depth. To solve these problems, we propose several new models that greatly improve the capability of HSCNN.</p><p>We discuss a densely-connected structure as an alternative solution, i.e., the HSCNN-D model. It is the first time to apply the dense structure to the hyperspectral reconstruction task. The dense structure can substantially reduce the vanishing of gradient during training. With a much deeper network, HSCNN-D can offer higher reconstruction facility provided sufficient computing resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XpD1XfXmgc8Q2OxSuZkBlQ.png" /><figcaption>Figure 1. Network structures of our proposed models and the baseline HSCNN. The “C” with a rectangular block denotes the convolution, and the following “1” and “3” denote the kernel size (<em>i.e</em>., 1×1 and 3×3 respectively). The “R” represents the ReLU activation function. And the “C” with a circular block denotes the concatenation.</figcaption></figure><p>Specifically, given a three-channel (i.e., RGB) image as input, we aim to reconstruct a hyperspectral image with multi-channels (typically tens of bands in practice) as output. The main gap between the input and output lies in the decrease of channels. The concatenation operator adopted in each dense block explicitly increases the channel number which has the potential to learn a more effective model for this inverse problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*_IzmwRCKSomWUmge0XfpaA.png" /><figcaption>Table 1. A typical setting of hyper-parameters for the HSCNN-D model. C(·) stands for the convolution with (kernel size × kernel size × filter number). [·]× and {·}× stand for concatenation operators with certain blocks (×1 is omitted). And the symbol “/” denotes the parallel operation for path-widening fusion.</figcaption></figure><p>Now let us get started with the code and see how the model is designed.Let’s start with loading all the libraries and dependencies required.</p><pre>import tensorflow as tf<br>import keras<br>import os, stat, sys<br>from skimage import img_as_ubyte<br>from data_loader import *</pre><p>Here, data_loader is a user defined module in which there are two functions: load_trainData(), load_validData(), normalize_data() which enables us to get the image data in the form of numpy arrays from the directories as provided by the user. Then, we’ve specified the directories from which the directories where the data is located.</p><pre>clean_data = &#39;./dataset/NTIRE2020_Train_Clean&#39;<br>spectral_data = &#39;./dataset/NTIRE2020_Train_Spectral&#39;<br>lr = tf.keras.backend.placeholder(dtype=tf.float32)<br>base_lr = 0.001</pre><p>The lr variable is used to instantiate a placeholder tensor with datatype tf.float32 and the base_lr contains the learning rate value 0.001. The variable clean_data is the directory that consists of normal images and the spectral_data is the directory that consists of spectral images.</p><pre>X_data = _get_data(mode=&#39;train&#39;)<br>Y_data = _get_data(mode=&#39;valid&#39;)<br>X_data=normalize_data(X_data)<br>print(&quot;Shape of X_data:&quot;,X_data.shape)<br>print(&quot;Shape of Y_data:&quot;,Y_data.shape)</pre><p>The output for the above code is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*gjVfjovRE63E0eAqq91Akg.png" /></figure><p>The X_data array looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*-5tuHg79mh_ziAJlQxQWzw.png" /></figure><pre>from sklearn.model_selection import train_test_split<br>X_train, X_val, Y_train, Y_val= train_test_split(X_data,Y_data,<br>                                               test_size = 0.2)</pre><p>We import the train_test_split function from sklearn.model_selection module and we split the given data to training and validation sets respectively with a test_size value of 0.2.</p><pre>from model import Net<br>net = Net(X_data)<br>model = net.build_net()</pre><p>The model is designed same as HSCNN-D (Figure-1b) and the code is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r64wT1cf9guUoz7n_fNGeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3so5W2X7topSxANEmpbuXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H4DMaA5epk_epQb6BJ4KUQ.png" /></figure><p>In the above code, the build_net() function calls the ddfn_block() which is responsible for applying 2 layers of Conv2D layers of size (3x3) and 2 layers of Conv2D layers of size (1x1) and concatenating them both. This block is mainly responsible for feature extraction as given in the figure. And, this concatenated layer is passed to dfus_block() which applies a Conv2D layer of size (1x1), 2 layers of Conv2D layers of size (3x3) and 2 layers of Conv2D layers of size (1x1) and concatenating them all to one layer. Finally, this layer is again passed to the Conv2D layer of size (1x1) and it is fed to the model.</p><p>You can find how the data flows through all these layers by executing the following code:</p><pre>print(model.summary())</pre><p>We can compile the model and train the data by executing the following code:</p><pre>opt = tf.keras.optimizers.Adam(learning_rate = 0.001)<br>model.compile(loss = &#39;mean_absolute_error&#39;, optimizer = opt,<br>                                        metrics = [&#39;mae&#39;, &#39;mse&#39;])</pre><pre>history = model.fit(x= X_data, y= Y_data, epochs= 100, verbose = 1,<br>          validation_split= 0.2, validation_data= (X_val, Y_val))</pre><p>As the training needs higher computing resources, we have trained for 8 samples and validated on 2 samples and got the results as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*OU12R1Lx2NdbrbNUBTXBxQ.png" /></figure><p>…..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*VXXqzBKuVgXEv_KFWt2OuA.png" /></figure><p>We got a loss value of 0.0965 and validation_loss of 0.0908. Although this project is far from complete but it is remarkable to see the success of deep learning in such real world problems. Having more computational resources and training on more images can reduce the loss, leading us to find more data from the RGB images that can be found in Hyperspectral Images.</p><ul><li>Mentor: <a href="https://medium.com/u/a6d373cb0fc2">Navyasingh</a></li><li>Done by <a href="https://medium.com/u/3a45e8001f61">Yaswanth Nag</a>, <a href="https://medium.com/u/1810120fe077">Pratish Pushparaj</a> and <a href="https://medium.com/u/3b2543b98ed7">Kshitij Pal</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2002275423e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hyperspectral-image-reconstruction/hyperspectral-image-reconstruction-c2002275423e">Hyperspectral Image Reconstruction</a> was originally published in <a href="https://medium.com/hyperspectral-image-reconstruction">Hyperspectral Image Reconstruction</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>