<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>HTML5 on bramp.net</title>
    <link>https://blog.bramp.net/</link>
    <description>Recent content in HTML5 on bramp.net</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-GB</language>
    <lastBuildDate>Tue, 15 May 2012 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bramp.net/tags/html5/" rel="self" type="application/rss+xml" />
    
    <item>
      <title>MRI scan of my brain</title>
      <link>https://blog.bramp.net/post/2012/05/15/mri-scan-of-my-brain/</link>
      <pubDate>Tue, 15 May 2012 00:00:00 +0000</pubDate>
      
      <guid>https://blog.bramp.net/post/2012/05/15/mri-scan-of-my-brain/</guid>
      <description><p>I had a <a href="http://en.wikipedia.org/wiki/Magnetic_resonance_imaging">MRI</a> today, and afterwards I was given a CD of my scan. The data on the CD was stored in <a href="http://en.wikipedia.org/wiki/DICOM">DICOM</a> format, and after some searching I was able to find some open source software to view the data. I especially liked <a href="http://aeskulap.nongnu.org/">Aeskulap</a> which allowed interactive viewing of the data in multiple dimensions.</p>
<p>I wanted to put my scans online, so I found another set of tools, <a href="http://xmedcon.sourceforge.net/">medcon</a>, that allowed me to convert the DICOM images into png/gif format, and then I used <a href="http://ffmpeg.org/">ffmpeg</a> to create the following videos:</p>
<div class="row">
  <div class="col-md-6 text-center">
  	<video width="288" height="288" controls="controls"><source src="004.mp4" type="video/mp4" /><source src="004.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
  <div class="col-md-6 text-center">
  	<video width="288" height="288" controls="controls"><source src="000.mp4" type="video/mp4" /><source src="000.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
</div>
<div class="row">
  <div class="col-md-6 text-center">
  	<video width="256" height="256" controls="controls"><source src="001.mp4" type="video/mp4" /><source src="001.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
  <div class="col-md-6 text-center">
 	 <video width="256" height="256" controls="controls"><source src="003.mp4" type="video/mp4" /><source src="003.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
</div>
<div class="row">
  <div class="col-md-12 text-center">
  	<video width="256" height="256" controls="controls"><source src="008.mp4" type="video/mp4" /><source src="008.webm" type="video/webm" />Your browser does not support the video tag.</video>
  </div>
</div>
<p>I don’t know the exact layout, but on the CD I seemed to have 12 different scans, each with a series of images. The name of the files were all 8 digits numbers, with the first three being the scan number (0 to 11), and the following five digits being (0 to whatever). For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">DICOM/185723/00000000: DICOM medical imaging data
</span></span><span class="line"><span class="cl">DICOM/185723/00000001: DICOM medical imaging data
</span></span><span class="line"><span class="cl">DICOM/185723/00000002: DICOM medical imaging data
</span></span><span class="line"><span class="cl">...
</span></span><span class="line"><span class="cl">DICOM/185723/00100000: DICOM medical imaging data
</span></span><span class="line"><span class="cl">DICOM/185723/00100001: DICOM medical imaging data
</span></span><span class="line"><span class="cl">DICOM/185723/00100002: DICOM medical imaging data
</span></span><span class="line"><span class="cl">...
</span></span></code></pre></div><p>To create videos the first thing I did was to convert the images from DICOM to PNG</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt-get install medcon
</span></span><span class="line"><span class="cl">mkdir png
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in DICOM/185723/*<span class="p">;</span> <span class="k">do</span> medcon -f <span class="nv">$i</span> -c png -o png/<span class="sb">`</span>basename <span class="nv">$i</span><span class="sb">`</span>.png <span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span></code></pre></div><p>Now to batch the images I started by creating animated gifs.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt-get install imagemagick
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Create animated gifs</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in <span class="sb">`</span>seq -w <span class="m">000</span> 011<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> convert -delay <span class="m">20</span> -loop <span class="m">0</span> png/<span class="nv">$i</span>*.png <span class="nv">$i</span>.gif<span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span></code></pre></div><p>However, those gifs were huge, up to 20mb. So next I created a set of videos (that were a order of magnitude smaller than the gifs):</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt-get install ffmpeg
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Create MP4</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in <span class="sb">`</span>seq -w <span class="m">000</span> 011<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> avconv -r <span class="m">5</span> -i png/<span class="nv">$i</span>%05d.png -r <span class="m">24</span> <span class="nv">$i</span>.mp4<span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Create webm</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in <span class="sb">`</span>seq -w <span class="m">000</span> 011<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> avconv -r <span class="m">5</span> -i png/<span class="nv">$i</span>%05d.png -r <span class="m">24</span> <span class="nv">$i</span>.webm<span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Create ogg video</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> i in <span class="sb">`</span>seq -w <span class="m">000</span> 011<span class="sb">`</span><span class="p">;</span> <span class="k">do</span> avconv -r <span class="m">5</span> -i png/<span class="nv">$i</span>%05d.png -r <span class="m">24</span> <span class="nv">$i</span>.ogg<span class="p">;</span> <span class="k">done</span><span class="p">;</span>
</span></span></code></pre></div><p>easy!</p>
</description>
    </item>
    
    <item>
      <title>HTML5 Canvas: Lunch Wheel</title>
      <link>https://blog.bramp.net/post/2011/07/27/html5-canvas-lunch-wheel/</link>
      <pubDate>Wed, 27 Jul 2011 00:00:00 +0000</pubDate>
      
      <guid>https://blog.bramp.net/post/2011/07/27/html5-canvas-lunch-wheel/</guid>
      <description><p>In the on going battle to make my lunch time more optimised I decided to learn some Javascript, and how to use the HTML5 <a href="https://html.spec.whatwg.org/multipage/scripting.html#the-canvas-element">Canvas</a> element. Turns out it’s not that hard, and I have now created</p>
<p><a href="https://blog.bramp.net/wheel/"><figure><img src="/post/2011/07/27/html5-canvas-lunch-wheel/lunchwheel.png"><figcaption>
      <h4>Click to win</h4>
    </figcaption>
</figure>
</a></p>
<p>The Lunch Wheel]<a href="https://blog.bramp.net/wheel/">3</a>. It helps me find lunch close to my office in the <a href="http://maps.google.com/maps?q=Courthouse,+Arlington,+VA&amp;hl=en&amp;sll=37.0625,-95.677068&amp;sspn=59.206892,135.263672&amp;z=15">Courthouse area of Arlington, VA</a>.</p>
<p>While making this I found that information on the Canvas element seemed to be lacking. For example, not many sites talked about ways to optimise or profile the javascript. Also I was disappointed to see that not all browsers supported the Canvas completely. Here is a quick list of the problems:</p>
<ol>
<li>
<p>Firefox 3.5 (linux) doubled the size of the fonts when I was setting the font in “pt”. When I switched to “em” things seemed to work consistently across browsers. 30fps</p>
</li>
<li>
<p>Android 2.2 (Droid 2) works well but slowly. It also didn’t support the <a href="https://developer.mozilla.org/En/HTML/Element/audio">Audio</a> tag. 6fps</p>
</li>
<li>
<p>Android 3.0 (Xoom Tablet) seemed to have some issues rendering half of the wheel. It looked like a bug with the hardware acceleration. I made some minor tweaks to the rendering and things started to work. 15fps</p>
</li>
<li>
<p>iPhone 3 didn’t render any of the text, but played the sound and spun the wheel. 3fps</p>
</li>
<li>
<p>iPhone 4 rendered fine but as slowly as the Android 2.2 device. 5fps</p>
</li>
<li>
<p>Chrome (linux) worked great, and was the platform I was developing on. 30fps (max)</p>
</li>
</ol>
<p>I was also using the <a href="https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-clip">clip()</a> method to ensure the text didn’t go outside of the wheel, but this heavily impacted performance. So instead I just chopped the text manually and performance doubled.</p>
<p>I realise HTML5 is new, but I’m really hoping all browsers will start to support it consistently and across the board. I’d hate to start writing large blocks of code to cope with all the browser quirks.</p>
<p>Also, thanks to <a href="http://jquery.com/">jQuery</a>, <a href="http://tinysort.sjeiti.com/">TinySort</a> and <a href="http://excanvas.sourceforge.net/">ExplorerCanvas</a> (which I still haven’t made work).</p>
<p><strong>Update:</strong> Soon to come, the ability to find your own lunch places, as well as integration with <a href="https://foursquare.com/">foursquare</a> so you can see how popular the venues are with your friends.</p>
</description>
    </item>
    
  </channel>
</rss>
