<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="http://shapelogicscala.org/feed.xml" rel="self" type="application/atom+xml" /><link href="http://shapelogicscala.org/" rel="alternate" type="text/html" /><updated>2025-10-07T09:20:40+00:00</updated><id>http://shapelogicscala.org/feed.xml</id><title type="html">ShapeLogic Scala</title><subtitle>Generic computer vision in Scala.
</subtitle><entry><title type="html">Welcome to Shapelogic Scala Blog</title><link href="http://shapelogicscala.org/jekyll/update/2017/01/22/start-github-pages.html" rel="alternate" type="text/html" title="Welcome to Shapelogic Scala Blog" /><published>2017-01-22T13:57:03+00:00</published><updated>2017-01-22T13:57:03+00:00</updated><id>http://shapelogicscala.org/jekyll/update/2017/01/22/start-github-pages</id><content type="html" xml:base="http://shapelogicscala.org/jekyll/update/2017/01/22/start-github-pages.html"><![CDATA[<p>I wrote my master thesis on computer vision. It was called Robotic Vision and Visual Arts.</p>

<p>In 2007 I started work on an open source project: ShapeLogic. It was a Java plugin to ImageJ.
My thought was that I wanted to add declarative programming techniques to computer vision.
Turned out that functional programming techniques worked better with what I needed. 
Particularly lazy stream programming.</p>

<p>In 2009 I took a full time work and was not able to do more work on ShapeLogic, 
but late 2016 my company approved that I could resume work on ShapeLogic.</p>

<p>In the meantime functional programming had gone from academia to be a main stream programming.
It is an important aspect of Java 8 and Scala. Both have implementation of 
functional programming that were better than what I had in ShapeLogic.</p>

<p>When I resumed work I was thinking what could be useful to other people?</p>

<p>I have been annoyed by the amount of boilerplate that is involved with image processing.
Also that it is hard to write generic code that works for all number types:</p>

<ul>
  <li>Byte</li>
  <li>Short</li>
  <li>Int</li>
  <li>Long</li>
  <li>Float</li>
  <li>Double</li>
</ul>

<p>I thought that this is a good challange for Scala’s sophisticated type system.</p>

<p>I wanted to come up with only one simple generic class as the main workhorse for algorithms.
What I came up with was BufferImage:</p>

<figure class="highlight"><pre><code class="language-scala" data-lang="scala"><span class="k">sealed</span> <span class="k">class</span> <span class="nc">BufferImage</span><span class="o">[</span><span class="kt">@specialized</span><span class="o">(</span><span class="kt">Byte</span>, <span class="kt">Short</span>, <span class="kt">Int</span>, <span class="kt">Long</span>, <span class="kt">Float</span>, <span class="kt">Double</span><span class="o">)</span> <span class="kt">T:</span> <span class="kt">ClassTag</span><span class="o">](</span>
    <span class="k">val</span> <span class="nv">width</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span>
    <span class="k">val</span> <span class="nv">height</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span>
    <span class="k">val</span> <span class="nv">numBands</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span>
    <span class="n">bufferInput</span><span class="k">:</span> <span class="kt">Array</span><span class="o">[</span><span class="kt">T</span><span class="o">]</span> <span class="k">=</span> <span class="kc">null</span><span class="o">,</span>
    <span class="k">val</span> <span class="nv">rgbOffsetsOpt</span><span class="k">:</span> <span class="kt">Option</span><span class="o">[</span><span class="kt">RGBOffsets</span><span class="o">]</span> <span class="k">=</span> <span class="nc">None</span><span class="o">)</span> <span class="k">extends</span> <span class="nc">WriteImage</span><span class="o">[</span><span class="kt">T</span><span class="o">]</span> <span class="k">with</span> <span class="nc">BufferImageTrait</span><span class="o">[</span><span class="kt">T</span><span class="o">]</span> <span class="o">{</span></code></pre></figure>

<p>I have now gotten to a point of testing it with several generic image algorithms.
BufferImage seems like it should be up for the task.</p>]]></content><author><name></name></author><category term="jekyll" /><category term="update" /><summary type="html"><![CDATA[I wrote my master thesis on computer vision. It was called Robotic Vision and Visual Arts.]]></summary></entry></feed>