<?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 Michael Lellouch on Medium]]></title>
        <description><![CDATA[Stories by Michael Lellouch on Medium]]></description>
        <link>https://medium.com/@michael.lellouch?source=rss-1adf5d20c1cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pdOdeJDIe-1pKJtx.</url>
            <title>Stories by Michael Lellouch on Medium</title>
            <link>https://medium.com/@michael.lellouch?source=rss-1adf5d20c1cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 21:16:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michael.lellouch/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[Finding Shade With Google Street View]]></title>
            <link>https://medium.com/@michael.lellouch/finding-shade-with-google-street-view-28fd58c56298?source=rss-1adf5d20c1cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/28fd58c56298</guid>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[google-street-view]]></category>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Michael Lellouch]]></dc:creator>
            <pubDate>Sat, 24 Feb 2018 00:48:55 GMT</pubDate>
            <atom:updated>2018-02-24T23:40:13.375Z</atom:updated>
            <content:encoded><![CDATA[<p>I have had a question bouncing in my head for some time. Can I find which streets are more shaded than others?</p><p>This question came up to my mind every time I walked through the city during the summer. Unfortunately, navigation apps still don’t consider shade as a parameter for the chosen route, and this made my walks not as pleasant as they could be.</p><p>Fast forward to October 2017, the perfect opportunity came along — DataHack 2017, a data science hackathon.</p><p>Unlike the rest of the participants, I wasn’t a deep learning ninja. Moreover, my teammate couldn’t attend much of the hackathon, so my idea had to be simple. No fancy deep neural nets, just something short and sweet.</p><h4>Rejected Idea</h4><p>When I initially thought about this problem, my immediate solution was using satellite imagery. I dropped this idea after I realized the satellite’s resolution is too low to deduce the necessary information. For example, here are some streets in Tel Aviv:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ZooNT7l2SUm22dOS1MRMQ.jpeg" /><figcaption>Satellite image of Tel Aviv</figcaption></figure><p>Can you tell which streets are more shaded? I can’t…</p><h4>The Real Idea</h4><p>OK, so Google Maps can’t cut it. But what about Google Street View? If I’d show you a picture of a street, you’ll probably be able to tell me how much shade is in it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f-T0ywQXOAuXHJNa1oWz2w.jpeg" /><figcaption>A street In Tel Aviv</figcaption></figure><p>There’s something even cooler —the Google Street View API lets you decide the camera angle of the image. This means that for each location, we can get a full view of the street and where is the light coming from.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LWx7gsQX8GDo_TGQKFcKVg.jpeg" /><figcaption>Same place, but now the camera angle is pointed at four directions: north, west, south and east. We can clearly see that the street is well shaded from the north and south sides.</figcaption></figure><p>Now, my idea was clear:</p><ol><li>Choose a grid of locations in the city.</li><li>For each location, take 4 different images — one for each direction.</li><li>Assign each image a “Shade Rating” that describes how much shade is seen.</li></ol><h3>Shade Rating</h3><p>Only one question left — how do we find how much shade is in an image?</p><p>As you may remember, I needed to create something simple — I couldn’t waste time on trying to debug a neural net that doesn’t converge properly. Plus, I didn’t have any training set and creating one was too much work. Hence, I went with a different approach: instead of trying to find the shade in the image, maybe I will find the sky?</p><p>If you’ll look at more images, you’ll see that that the more sky we see, the less shade there is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RqTMG6HMIOYIeQRY32ZKRA.jpeg" /></figure><p>I understand this measurement is not perfect, but by averaging a lot of data points I believe we can get a nice estimation.</p><p>Something cool about this method is that it can ignore the time the picture was taken — we only care about how much pixels are of the sky</p><h3>Implementation</h3><p>Luckily, I’ve done this thinking process before the hackathon, which gave me a nice head start. I’ve followed the process I’ve described before:</p><h4>Building a grid of points</h4><p>This is simple:</p><ol><li>Find all the street names in the city.</li><li>For each street, iterate over its addresses</li><li>Use Google’s geocoding API to get the address’ coordinates.</li></ol><p>Only one problem — Google API quotas. In its standard free package, Google allows up to 2500 API calls per day. And since there are almost a thousand streets in my city (Tel Aviv) we’ll run out of calls quickly.</p><p>To solve this, I did a pretty nifty trick. The usual API call looks like this:</p><blockquote>https://maps.google.com/…/1600 Pennsylvania Ave Washington</blockquote><p>and returns something like:</p><pre>...<br>&quot;geometry&quot; : {<br>            &quot;location&quot; : {<br>               &quot;lat&quot; : 38.8976633,<br>               &quot;lng&quot; : -77.03657389999999<br>            },<br>            &quot;location_type&quot; : &quot;ROOFTOP&quot;,<br>         },<br>         &quot;place_id&quot; : &quot;ChIJGVtI4by3t4kRr51d_Qm_x58&quot;,<br>         &quot;types&quot; : [ &quot;establishment&quot;, &quot;point_of_interest&quot;, &quot;premise&quot; ]<br>      }</pre><p>But what’s cool is that if we don’t specify the full address, we get the center of the location. For example, if we want to know the center of Pennsylvania Avenue we will send</p><blockquote>https://maps.google.com/…/Pennsylvania Ave Washington</blockquote><p>and we’ll get:</p><pre>&quot;geometry&quot; : {<br>            &quot;location&quot; : {<br>               &quot;lat&quot; : 38.8987709,<br>               &quot;lng&quot; : -77.0351295<br>            },<br>            &quot;location_type&quot; : &quot;<strong>GEOMETRIC_CENTER</strong>&quot;,<br>         },<br>         &quot;place_id&quot; : &quot;ChIJG8NBDr23t4kR1IXnFqrTYVY&quot;,<br>         &quot;types&quot; : [ &quot;route&quot; ]<br>      }</pre><p>Thus, our solution will be to first find the street’s start (“1 Pennsylvania Ave Washington”), and then the street’s center(“Pennsylvania Ave Washington”). From those we can infer the street’s end, and with linear interpolation we can get as many points on the street as we please.</p><p>For example, lets take a street in Tel Aviv named Pinkas. It starts here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*BgxtKYJCE-7P9yiBDZUvlQ.png" /></figure><p>And searching it without a specific address give us its center:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vACIHZpKzg-5ZKS1Nu5K0g.png" /></figure><p>So its end is probably there:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2lYYhrlLedtYO5-hLK37Q.png" /></figure><p>So we can check these locations to understand how shaded the street is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81a4OOnI44swoKDoH6TmVA.png" /></figure><h4>Taking Images</h4><p>This part went surprisingly smoothly. Google’s quota is 25000 calls per day, so we had enough for ~6000 points (remember that we use 4 images per location?)</p><h4>Finding the Sky</h4><p>We’re left with the last problem: finding how much pixels in a picture are of the sky. To solve this I chose a very simple algorithm, since I’ve had little experience with image processing. The algorithm is as follows:</p><ol><li>Start and assume that all the top pixels are of the sky.</li><li>Verify the difference between each of those pixels and one pixel below it doesn’t pass a certain threshold.</li><li>If it doesn’t pass that threshold, assume that this pixel is also part of the sky and repeat the process with the pixel below it.</li></ol><p>When running this, we get some OK results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*x08HkpkDg1AQ2u6UoU89Hg.jpeg" /><figcaption>The original image</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*eRaW3_0D5YRz89fvZKOmFA.jpeg" /><figcaption>The pixels the algorithm decided were part of the sky are in black.</figcaption></figure><p>This is OK, but clearly not good enough. I’ve tried to fine tune the threshold to achieve better results, but couldn’t find that sweet spot.</p><p>At this point in the hackathon, a mentor from <a href="https://en.wikipedia.org/wiki/Mobileye">Mobileye</a> saw me getting frustrated about this problem. Since he’s such a nice guy we sat down together and tried to solve it. His first idea worked well: what if we blurred the images?</p><p>Retrospectively, my intuition is that when we blur the image, each pixels gets some color from it’s entire neighborhood, and not just from the pixel below it. This greatly improve my results, for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*w3zxqSDOVP9h7wMlh7zonw.png" /><figcaption>The detected pixels after blurring the image</figcaption></figure><p>This is this not perfect, but at this point I’ve decided that enough is enough.</p><h4>GUI</h4><p>Finally, time for some quick &amp; dirty GUI. Nothing fancy, just a simple way to show all the data we’ve collected. Since this entire project used Google APIs, why stop now? A heat map showing how much light is visible in a certain location will do the trick:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ax9vuRgkvFKyNO0Fi4PG-Q.jpeg" /></figure><p>And… we’re done :)</p><h3>Final Notes</h3><p>Concerning DataHack 2017: I didn’t win. There were some very nice projects which really stunned me with their technical complexity. But I’ve had a lot of fun doing that project, and learned a lot.</p><p>Moreover, when I got the chance to talk about this with an urban architect, he mentioned that some municipalities are looking for some tools similar to this, so maybe I’ll revisit this project someday, who knows :).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28fd58c56298" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>