<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>What&#039;s new about OTB? &#187; Tips</title>
	<atom:link href="http://blog.orfeo-toolbox.org/category/tips/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.orfeo-toolbox.org</link>
	<description>For the latest news on the Orfeo Toolbox</description>
	<lastBuildDate>Tue, 31 Jan 2012 17:01:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>OTB Mad Lab</title>
		<link>http://blog.orfeo-toolbox.org/uncategorized/otb-mad-lab</link>
		<comments>http://blog.orfeo-toolbox.org/uncategorized/otb-mad-lab#comments</comments>
		<pubDate>Fri, 07 May 2010 14:32:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.orfeo-toolbox.org/?p=359</guid>
		<description><![CDATA[It seems that C++ programming can be cumbersome for some users. Well, OTB allows you to work also in other programming languages as for instance Python. The Pylab Project which gathers numeric and scientific Python packages such as NumPy, SciPy and Matplotlib is considered as having the same features as some commercial scientific environments. Some [...]]]></description>
			<content:encoded><![CDATA[<p><tt><tt><span style="color: #000080;"> </span></tt></tt></p>
<p>It seems that C++ programming can be cumbersome for some users. Well, OTB allows you to work also in other programming languages as for instance Python. The <a href="http://www.scipy.org/PyLab">Pylab Project</a> which gathers numeric and scientific Python packages such as NumPy, SciPy and Matplotlib is considered as having the same features as some commercial scientific environments. Some people consider that Pylab is even more powerful than these commercial tools, since you get for free the power of a full featured and general purpose programming language as Python.</p>
<p>Recently I needed to quickly plot the temporal profiles of several pixels coming from temporal image series in order to easily assess the impact of a correction algorithm. I have to admit that my first idea was to generate simple ASCII files with the pixel values and then feed these files to Gnuplot. However, I found a more elegant (at least from my point of view) way to do this.</p>
<p>I use the OTB Python bindings in order to read my images (2 GeoTiff files with 49 bands each). Using the &#8220;GetPixel&#8221; method, I access the pixels I want to plot. Finally I use pylab to plot 2 temporal profiles (before and after correction). Here goes the code.</p>
<pre><tt><tt><strong><span style="color: #000080;">
import</span></strong> sys

<strong><span style="color: #0000ff;">if</span></strong><span style="color: #990000;">(</span> <strong><span style="color: #000000;">len</span></strong><span style="color: #990000;">(</span>sys<span style="color: #990000;">.</span>argv<span style="color: #990000;">)</span> <span style="color: #990000;">!=</span> <span style="color: #993399;">5</span><span style="color: #990000;">):</span>
    <strong><span style="color: #0000ff;">print</span></strong><span style="color: #990000;">(</span><span style="color: #ff0000;">"Usage: "</span><span style="color: #990000;">+</span>sys<span style="color: #990000;">.</span>argv<span style="color: #990000;">[</span><span style="color: #993399;">0</span><span style="color: #990000;">]+</span><span style="color: #ff0000;">" series1 series2 x0 y0"</span><span style="color: #990000;">)</span>
    <strong><span style="color: #000000;">exit</span></strong><span style="color: #990000;">()</span>

<strong><span style="color: #000080;">import</span></strong> itk
<strong><span style="color: #000080;">import</span></strong> otbImages
<strong><span style="color: #000080;">import</span></strong> otbIO
<strong><span style="color: #000080;">import</span></strong> pylab

<em><span style="color: #9a1900;"># Types</span></em>

ImageType <span style="color: #990000;">=</span> otbImages<span style="color: #990000;">.</span>VectorImage<span style="color: #990000;">[</span>itk<span style="color: #990000;">.</span>D<span style="color: #990000;">,</span> <span style="color: #993399;">2</span><span style="color: #990000;">]</span>
ReaderType <span style="color: #990000;">=</span> otbIO<span style="color: #990000;">.</span>ImageFileReader<span style="color: #990000;">[</span>ImageType<span style="color: #990000;">]</span>

<em><span style="color: #9a1900;"># Pixel coordinates</span></em>

index <span style="color: #990000;">=</span> itk<span style="color: #990000;">.</span>Index<span style="color: #990000;">[</span><span style="color: #993399;">2</span><span style="color: #990000;">]()</span>
index<span style="color: #990000;">[</span><span style="color: #993399;">0</span><span style="color: #990000;">]</span> <span style="color: #990000;">=</span> <strong><span style="color: #000000;">int</span></strong><span style="color: #990000;">(</span>sys<span style="color: #990000;">.</span>argv<span style="color: #990000;">[</span><span style="color: #993399;">3</span><span style="color: #990000;">])</span>
index<span style="color: #990000;">[</span><span style="color: #993399;">1</span><span style="color: #990000;">]</span> <span style="color: #990000;">=</span> <strong><span style="color: #000000;">int</span></strong><span style="color: #990000;">(</span>sys<span style="color: #990000;">.</span>argv<span style="color: #990000;">[</span><span style="color: #993399;">4</span><span style="color: #990000;">])</span>

<em><span style="color: #9a1900;"># Import first series</span></em>
readerBefore <span style="color: #990000;">=</span> ReaderType<span style="color: #990000;">.</span><strong><span style="color: #000000;">New</span></strong><span style="color: #990000;">()</span>
readerBefore<span style="color: #990000;">.</span><strong><span style="color: #000000;">SetFileName</span></strong><span style="color: #990000;">(</span>sys<span style="color: #990000;">.</span>argv<span style="color: #990000;">[</span><span style="color: #993399;">1</span><span style="color: #990000;">])</span>
readerBefore<span style="color: #990000;">.</span><strong><span style="color: #000000;">Update</span></strong><span style="color: #990000;">()</span>

pixBefore <span style="color: #990000;">=</span> readerBefore<span style="color: #990000;">.</span><strong><span style="color: #000000;">GetOutput</span></strong><span style="color: #990000;">().</span><strong><span style="color: #000000;">GetPixel</span></strong><span style="color: #990000;">(</span> index <span style="color: #990000;">)</span>

<em><span style="color: #9a1900;"># Import second series</span></em>
readerAfter <span style="color: #990000;">=</span> ReaderType<span style="color: #990000;">.</span><strong><span style="color: #000000;">New</span></strong><span style="color: #990000;">()</span>
readerAfter<span style="color: #990000;">.</span><strong><span style="color: #000000;">SetFileName</span></strong><span style="color: #990000;">(</span>sys<span style="color: #990000;">.</span>argv<span style="color: #990000;">[</span><span style="color: #993399;">2</span><span style="color: #990000;">])</span>
readerAfter<span style="color: #990000;">.</span><strong><span style="color: #000000;">Update</span></strong><span style="color: #990000;">()</span>

pixAfter <span style="color: #990000;">=</span> readerAfter<span style="color: #990000;">.</span><strong><span style="color: #000000;">GetOutput</span></strong><span style="color: #990000;">().</span><strong><span style="color: #000000;">GetPixel</span></strong><span style="color: #990000;">(</span> index <span style="color: #990000;">)</span>

<em><span style="color: #9a1900;"># Chek that both series have the same length</span></em>

<strong><span style="color: #0000ff;">if</span></strong><span style="color: #990000;">(</span> pixBefore<span style="color: #990000;">.</span><strong><span style="color: #000000;">GetSize</span></strong><span style="color: #990000;">()</span> <span style="color: #990000;">!=</span> pixAfter<span style="color: #990000;">.</span><strong><span style="color: #000000;">GetSize</span></strong><span style="color: #990000;">()</span> <span style="color: #990000;">):</span>
    <strong><span style="color: #0000ff;">print</span></strong><span style="color: #990000;">(</span><span style="color: #ff0000;">"Series have different lengths"</span><span style="color: #990000;">)</span>
    <strong><span style="color: #000000;">exit</span></strong><span style="color: #990000;">()</span>

<em><span style="color: #9a1900;"># Plot</span></em>

vectorBefore <span style="color: #990000;">=</span> <span style="color: #990000;">\
 [</span>pixBefore<span style="color: #990000;">.</span><strong><span style="color: #000000;">GetElement</span></strong><span style="color: #990000;">(</span>i<span style="color: #990000;">)</span> <strong><span style="color: #0000ff;">for</span></strong> i <strong><span style="color: #0000ff;">in</span></strong> <strong><span style="color: #000000;">range</span></strong><span style="color: #990000;">(</span>pixBefore<span style="color: #990000;">.</span><strong><span style="color: #000000;">GetSize</span></strong><span style="color: #990000;">())]</span>
vectorAfter <span style="color: #990000;">=</span> \
 <span style="color: #990000;">[</span>pixAfter<span style="color: #990000;">.</span><strong><span style="color: #000000;">GetElement</span></strong><span style="color: #990000;">(</span>i<span style="color: #990000;">)</span> <strong><span style="color: #0000ff;">for</span></strong> i <strong><span style="color: #0000ff;">in</span></strong> <strong><span style="color: #000000;">range</span></strong><span style="color: #990000;">(</span>pixAfter<span style="color: #990000;">.</span><strong><span style="color: #000000;">GetSize</span></strong><span style="color: #990000;">())]</span>

pylab<span style="color: #990000;">.</span><strong><span style="color: #000000;">xlabel</span></strong><span style="color: #990000;">(</span><span style="color: #ff0000;">"Date"</span><span style="color: #990000;">)</span>
pylab<span style="color: #990000;">.</span><strong><span style="color: #000000;">ylabel</span></strong><span style="color: #990000;">(</span><span style="color: #ff0000;">"Reflectance"</span><span style="color: #990000;">)</span>
pylab<span style="color: #990000;">.</span><strong><span style="color: #000000;">plot</span></strong><span style="color: #990000;">(</span>vectorBefore<span style="color: #990000;">,</span> label<span style="color: #990000;">=</span><span style="color: #ff0000;">"Raw"</span><span style="color: #990000;">)</span>
pylab<span style="color: #990000;">.</span><strong><span style="color: #000000;">plot</span></strong><span style="color: #990000;">(</span>vectorAfter<span style="color: #990000;">,</span> label<span style="color: #990000;">=</span><span style="color: #ff0000;">"Clean"</span><span style="color: #990000;">)</span>
pylab<span style="color: #990000;">.</span><strong><span style="color: #000000;">legend</span></strong><span style="color: #990000;">(</span>loc<span style="color: #990000;">=</span><span style="color: #ff0000;">'upper left'</span><span style="color: #990000;">,</span> shadow<span style="color: #990000;">=</span>True<span style="color: #990000;">)</span>
pylab<span style="color: #990000;">.</span><strong><span style="color: #000000;">show</span></strong><span style="color: #990000;">()</span>
</tt></tt></pre>
<p>﻿And here you can see a result example.</p>
<div id="attachment_369" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.orfeo-toolbox.org/wp-content/uploads/2010/05/plot.png"><img class="size-medium wp-image-369  " title="plot" src="http://blog.orfeo-toolbox.org/wp-content/uploads/2010/05/plot-300x226.png" alt="" width="300" height="226" /></a><p class="wp-caption-text">Temporal profiles</p></div>
<p>Of course, you can imagine to make this script a little bit more interactive in order to choose other pixel coordinates, etc., but I hope you grasp the power of this approach. By using the OTB Python bindings and other freely available open source Python goodies (NumPy, SciPy, Matplotlib, <a href="http://rpy.sourceforge.net/">rpy</a>) you get the user friendly approach of Octave, Scilab and their commercial counterparts plus the power of OTB (which in turn makes available ITK, OSSIM, etc.).</p>
<p>Isn&#8217;t it great?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.orfeo-toolbox.org/uncategorized/otb-mad-lab/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Complex system</title>
		<link>http://blog.orfeo-toolbox.org/tips/complex-system</link>
		<comments>http://blog.orfeo-toolbox.org/tips/complex-system#comments</comments>
		<pubDate>Fri, 18 Dec 2009 09:44:26 +0000</pubDate>
		<dc:creator>Emmanuel Christophe</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.orfeo-toolbox.org/?p=280</guid>
		<description><![CDATA[OTB is a complex system, if you don&#8217;t believe it, look at the image here (click on it for a full view): This image shows the dynamic dependencies of otb: the libraries required by each element. This image was generated using cmake: cmake . --graphviz=otb-dep.dot dot -Tpng -ootb-dep.png otb-dep.dot It is a very useful representation [...]]]></description>
			<content:encoded><![CDATA[<p>OTB is a complex system, if you don&#8217;t believe it, look at the image here (click on it for a full view):</p>
<p><a href="http://www.orfeo-toolbox.org/images/otb-dep.png"><img class="aligncenter size-full wp-image-282" title="otb-dep-mini" src="http://blog.orfeo-toolbox.org/wp-content/uploads/2009/12/otb-dep-mini.png" alt="otb-dep-mini" width="600" height="109" /></a></p>
<p>This image shows the dynamic dependencies of otb: the libraries required by each element. This image was generated using cmake:</p>
<pre>
cmake . --graphviz=otb-dep.dot
dot -Tpng -ootb-dep.png otb-dep.dot
</pre>
<p>It is a very useful representation to understand the potential link problems and to find out where some cleaning is required&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.orfeo-toolbox.org/tips/complex-system/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Common compilation errors</title>
		<link>http://blog.orfeo-toolbox.org/tips/common-compilation-errors</link>
		<comments>http://blog.orfeo-toolbox.org/tips/common-compilation-errors#comments</comments>
		<pubDate>Mon, 15 Dec 2008 08:42:26 +0000</pubDate>
		<dc:creator>Emmanuel Christophe</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[compilation error]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://blog.orfeo-toolbox.org/?p=94</guid>
		<description><![CDATA[Programming using OTB is not always easy. However, even if the learning curve is steep at the beginning, it really worths it after you surpassed the initial difficulties. This also applies when you&#8217;re writing a new OTB program. The hardest step is usually to get it to compile and once it compiles, it usually works [...]]]></description>
			<content:encoded><![CDATA[<p>Programming using OTB is not always easy. However, even if the learning curve is steep at the beginning, it really worths it after you surpassed the initial difficulties.</p>
<p>This also applies when you&#8217;re writing a new OTB program. The hardest step is usually to get it to compile and once it compiles, it usually works (as opposed to standard C programs where it is usually easy to compile but hard to find subsequent errors). This is the advantage of using templates. The drawback is that compiler error message can be somewhat cryptic and hard to decipher.</p>
<p>In the wiki, we&#8217;ve started a page to help you find out <a title="OTB compilation errors" href="http://wiki.orfeo-toolbox.org/index.php/Common_compilation_errors" target="_blank">common OTB compilation errors</a> and corresponding solution. Do not hesitate to fill up this page with you experience and help your fellow OTB users.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.orfeo-toolbox.org/tips/common-compilation-errors/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OTB by the hour</title>
		<link>http://blog.orfeo-toolbox.org/tips/otb-by-the-hour</link>
		<comments>http://blog.orfeo-toolbox.org/tips/otb-by-the-hour#comments</comments>
		<pubDate>Tue, 30 Sep 2008 15:09:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.orfeo-toolbox.org/?p=30</guid>
		<description><![CDATA[In the last weeks, intensive work has been carried out by the OTB Development Team in order to set up this. As you can see, you can browse OTB source code (library, applications, bindings and software guide). Every change to the source code is automatically available through the server. Actually we have migrated the OTB [...]]]></description>
			<content:encoded><![CDATA[<p>In the last weeks, intensive work has been carried out by the OTB Development Team in order to set up <a href="http://hg.orfeo-toolbox.org/">this</a>.</p>
<p>As you can see, you can browse OTB source code (library, applications, bindings and software guide). Every change to the source code is automatically available through the server.</p>
<p>Actually we have migrated the OTB source revision system fom Subversion to <a href="http://www.selenic.com/mercurial/wiki/">Mercurial</a>. That means that what you are browsing from <a href="http://hg.orfeo-toolbox.org">hg.orfeo-toolbox.org</a> is the revision system itself!</p>
<p>We have chosen Mercurial because it is distributed (anybody can get a working copy of the repository and the whole history) and easy to use and install on a web server.</p>
<p>From now on, you can get OTB&#8217;s development version anytime and anywhere (if you have internet access!).</p>
<p>Quick tutorial:</p>
<ol>
<li>Get a mercurial client from <a href="http://www.selenic.com/mercurial/wiki/">here</a> or by using your OS available tools (eg. <em>apt-get install mercurial</em>).</li>
<li>Clone the source tree: <em>hg clone http://hg.orfeo-toolbox.org/OTB </em>for example</li>
<li>Use the source code as usual (compile, etc.)</li>
<li>In order to update your source tree: <em>hg pull; hg update</em></li>
</ol>
<p>By now, only OTB developpers have the rights to submit source code to the repository.</p>
<p>You may get this right if you send us good contributions!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.orfeo-toolbox.org/tips/otb-by-the-hour/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

