Skip to content

Commit

Permalink
Add in distance transform and watershed
Browse files Browse the repository at this point in the history
Add in distance transform and watershed for Stephan
  • Loading branch information
tanchinluh committed Oct 10, 2020
1 parent fd0d65c commit 47b2459
Show file tree
Hide file tree
Showing 26 changed files with 711 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ libgw*
Release/
jar/
2.0/

**/testing

# ignore doc/notes.txt, but not doc/server/arch.txt
#doc/*.txt
Expand Down
101 changes: 101 additions & 0 deletions help/en_US/Image Transforms/imdistransf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
*
* This help file was generated from imdistransf.sci using help_from_sci().
*
-->

<refentry version="5.0-subset Scilab" xml:id="imdistransf" xml:lang="en"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:ns3="http://www.w3.org/1999/xhtml"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:scilab="http://www.scilab.org"
xmlns:db="http://docbook.org/ns/docbook">

<refnamediv>
<refname>imdistransf</refname>
<refpurpose>Distance Transform</refpurpose>
</refnamediv>


<refsynopsisdiv>
<title>Syntax</title>
<synopsis>
imout = imdistransf(imin)

</synopsis>
</refsynopsisdiv>

<refsection>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term>imin :</term>
<listitem><para> Input binary image or 8-bit, single-channel (binary)</para></listitem>
</varlistentry>
<varlistentry>
<term>method :</term>
<listitem><para> Distance type, l1, l2, or c where the setting shall correspond to 1, 2 and 3 respectively:</para></listitem>
</varlistentry>
<varlistentry>
<term>l1 :</term>
<listitem><para> distance = |x1-x2| + |y1-y2|, use 1</para></listitem>
</varlistentry>
<varlistentry>
<term>l2 :</term>
<listitem><para> the simple euclidean distance, use 2</para></listitem>
</varlistentry>
<varlistentry>
<term>c :</term>
<listitem><para> distance = max(|x1-x2|,|y1-y2|), use 3</para></listitem>
</varlistentry>
<varlistentry>
<term>imout :</term>
<listitem><para> Output image with calculated distances. It is a double precision single-channel image of the same size as input</para></listitem>
</varlistentry>
</variablelist>
</refsection>

<refsection>
<title>Description</title>
<para>
This function used to calculates the distance to the closest zero pixel for each pixel of the source image.
</para>
<para>
</para>
</refsection>

<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
S = imread(fullpath(getIPCVpath() + "/images/three_objects.png"));
Sgray = rgb2gray(S);
Sb = im2bw(Sgray,0.1);
Sd = imdistransf(Sb);
subplot(211);imshow(Sb);subplot(212);imshow(Sd);
]]></programlisting>
</refsection>

<refsection role="see also">
<title>See also</title>
<simplelist type="inline">
<member><link linkend="imwatershed">imwatershed</link></member>
</simplelist>
</refsection>

<refsection>
<title>Authors</title>
<simplelist type="vert">
<member>Tan Chin Luh</member>
</simplelist>
</refsection>

<refsection>
<title>Bibliography</title>
<para>1. OpenCV 4.1.2 Online Documentation</para>
</refsection>
</refentry>
93 changes: 93 additions & 0 deletions help/en_US/Image Transforms/imwatershed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
*
* This help file was generated from imwatershed.sci using help_from_sci().
*
-->

<refentry version="5.0-subset Scilab" xml:id="imwatershed" xml:lang="en"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:ns3="http://www.w3.org/1999/xhtml"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:scilab="http://www.scilab.org"
xmlns:db="http://docbook.org/ns/docbook">

<refnamediv>
<refname>imwatershed</refname>
<refpurpose>Performs a marker-based image segmentation using the watershed algorithm.</refpurpose>
</refnamediv>


<refsynopsisdiv>
<title>Syntax</title>
<synopsis>
imout = imwatershed(imin)

</synopsis>
</refsynopsisdiv>

<refsection>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term>imin :</term>
<listitem><para> Input 8-bit 3-channel image.</para></listitem>
</varlistentry>
<varlistentry>
<term>markers :</term>
<listitem><para> Double precision single-channel image (map) of markers. It should have the same size as image.</para></listitem>
</varlistentry>
<varlistentry>
<term>imout :</term>
<listitem><para> Output labelled image</para></listitem>
</varlistentry>
</variablelist>
</refsection>

<refsection>
<title>Description</title>
<para>
The function implements one of the variants of watershed, non-parametric marker-based segmentation algorithm.
</para>
<para>
</para>
</refsection>

<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
S = imread(fullpath(getIPCVpath() + "/images/three_objects.png"));
Sgray = rgb2gray(S);
Sb = im2bw(Sgray,0.1);
Sd = imdistransf(Sb);
dist = Sd > 0.4;
[markers,n] = imlabel(dist);
markers(1:5,1:5) = 255;
Sw = imwatershed(S, markers);
imshow(Sw,hsvcolormap(3));
]]></programlisting>
</refsection>

<refsection role="see also">
<title>See also</title>
<simplelist type="inline">
<member><link linkend="imdistransf">imdistransf</link></member>
</simplelist>
</refsection>

<refsection>
<title>Authors</title>
<simplelist type="vert">
<member>Tan Chin Luh</member>
</simplelist>
</refsection>

<refsection>
<title>Bibliography</title>
<para>1. OpenCV 4.1.2 Online Documentation</para>
</refsection>
</refentry>
4 changes: 4 additions & 0 deletions help/en_US/master_help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@
<!ENTITY ae63d275559f1a30855346404b0057811 SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Stitching/imstitchimage.xml">
<!ENTITY ab5e474517e5fd3b94994a9f48fe3019f SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Stitching/imstitchimage_params.xml">
<!ENTITY a8bc4fd8dec0893dd918bb60b0f96101d SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Transforms/imdct.xml">
<!ENTITY af38c2f40fd269d2fd87a0eb576ee1f68 SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Transforms/imdistransf.xml">
<!ENTITY a0d19cf981a1c35150ace1d395aae6da5 SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Transforms/imhough.xml">
<!ENTITY afd68a6350731398b0743476142e97da2 SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Transforms/imhoughc.xml">
<!ENTITY a8b0cc6513abbe16ecb90a7d85b33866c SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Transforms/imidct.xml">
<!ENTITY a9f9eb4b399246c07f3a1de6a1cc29f0d SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Transforms/imlogpolar.xml">
<!ENTITY a44038e83832186acf3c44df70a75c121 SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Transforms/imradon.xml">
<!ENTITY a6072980fb4793defef9b59abacb01fc4 SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Transforms/imwatershed.xml">
<!ENTITY a7662d65fd2dba5b11dad382414920e0e SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Types and Color Space Conversions/hsv2rgb.xml">
<!ENTITY accaaeddc0eeb04d76d690de62e2a42f7 SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Types and Color Space Conversions/hsv2rgb2.xml">
<!ENTITY a4031d17a900a6e14eef4ab42c14eb1f8 SYSTEM "file:///C:/scilab/scilab-6.1.0/contrib/IPCV/help/en_US/Image Types and Color Space Conversions/im2bw.xml">
Expand Down Expand Up @@ -304,11 +306,13 @@
<part xml:id='section_8adb84d26782c1d3a5d34be202e5d52c'>
<title>Image Transforms</title>
&a8bc4fd8dec0893dd918bb60b0f96101d;
&af38c2f40fd269d2fd87a0eb576ee1f68;
&a0d19cf981a1c35150ace1d395aae6da5;
&afd68a6350731398b0743476142e97da2;
&a8b0cc6513abbe16ecb90a7d85b33866c;
&a9f9eb4b399246c07f3a1de6a1cc29f0d;
&a44038e83832186acf3c44df70a75c121;
&a6072980fb4793defef9b59abacb01fc4;
</part>
<part xml:id='section_4cd16036872803e658f06738c76a972f'>
<title>Image Types and Color Space Conversions</title>
Expand Down
Binary file modified help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS
Binary file not shown.
Binary file modified help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB
Binary file not shown.
Binary file modified help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS
Binary file not shown.
Binary file modified help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS
Binary file not shown.
2 changes: 1 addition & 1 deletion help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
JavaSearch 1.0
TMAP bs=2048 rt=1 fl=-1 id1=2163 id2=1
TMAP bs=2048 rt=1 fl=-1 id1=2189 id2=1
Binary file modified help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP
Binary file not shown.
4 changes: 2 additions & 2 deletions help/en_US/scilab_en_US_help/imdct.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

</td>
<td width="30%" class="next">
<span class="next"><a href="imhough.html">imhough &gt;&gt;</a></span>
<span class="next"><a href="imdistransf.html">imdistransf &gt;&gt;</a></span>

</td>
</tr></table>
Expand Down Expand Up @@ -75,7 +75,7 @@

</td>
<td width="30%" class="next">
<span class="next"><a href="imhough.html">imhough &gt;&gt;</a></span>
<span class="next"><a href="imdistransf.html">imdistransf &gt;&gt;</a></span>

</td>
</tr></table>
Expand Down
97 changes: 97 additions & 0 deletions help/en_US/scilab_en_US_help/imdistransf.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>imdistransf</title>
<style type="text/css" media="all">
@import url("scilab_code.css");
@import url("xml_code.css");
@import url("c_code.css");
@import url("style.css");
</style>
</head>
<body>
<div class="manualnavbar">
<table width="100%"><tr>
<td width="30%">
<span class="previous"><a href="imdct.html">&lt;&lt; imdct</a></span>

</td>
<td width="40%" class="center">
<span class="top"><a href="section_8adb84d26782c1d3a5d34be202e5d52c.html">Image Transforms</a></span>

</td>
<td width="30%" class="next">
<span class="next"><a href="imhough.html">imhough &gt;&gt;</a></span>

</td>
</tr></table>
<hr />
</div>



<span class="path" dir="ltr"><a href="index.html">IPCV</a> &gt;&gt; <a href="section_8adb84d26782c1d3a5d34be202e5d52c.html">Image Transforms</a> &gt; imdistransf</span>

<br /><br />
<div class="refnamediv"><h1 class="refname">imdistransf</h1>
<p class="refpurpose">Distance Transform</p></div>


<div class="refsynopsisdiv"><h3 class="title">Syntax</h3>
<div class="synopsis"><pre><span class="default">imout</span><span class="default"> = </span><span class="functionid">imdistransf</span><span class="default">(</span><span class="default">imin</span><span class="default">)</span></pre></div></div>

<div class="refsection"><h3 class="title">Parameters</h3>
<dl><dt><span class="term">imin :</span>
<dd><p class="para">Input binary image or 8-bit, single-channel (binary)</p></dd></dt>
<dt><span class="term">method :</span>
<dd><p class="para">Distance type, l1, l2, or c where the setting shall correspond to 1, 2 and 3 respectively:</p></dd></dt>
<dt><span class="term">l1 :</span>
<dd><p class="para">distance = |x1-x2| + |y1-y2|, use 1</p></dd></dt>
<dt><span class="term">l2 :</span>
<dd><p class="para">the simple euclidean distance, use 2</p></dd></dt>
<dt><span class="term">c :</span>
<dd><p class="para">distance = max(|x1-x2|,|y1-y2|), use 3</p></dd></dt>
<dt><span class="term">imout :</span>
<dd><p class="para">Output image with calculated distances. It is a double precision single-channel image of the same size as input</p></dd></dt></dl></div>

<div class="refsection"><h3 class="title">Description</h3>
<p class="para">This function used to calculates the distance to the closest zero pixel for each pixel of the source image.</p>
<p class="para"></p></div>

<div class="refsection"><h3 class="title">Examples</h3>
<div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabid">S</span> <span class="scilaboperator">=</span> <span class="scilabid">imread</span><span class="scilabopenclose">(</span><a class="scilabcommand" href="scilab://fullpath">fullpath</a><span class="scilabopenclose">(</span><span class="scilabid">getIPCVpath</span><span class="scilabopenclose">(</span><span class="scilabopenclose">)</span> <span class="scilaboperator">+</span> <span class="scilabstring">&#0034;</span><span class="scilabstring">/images/three_objects.png</span><span class="scilabstring">&#0034;</span><span class="scilabopenclose">)</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
<span class="scilabid">Sgray</span> <span class="scilaboperator">=</span> <span class="scilabid">rgb2gray</span><span class="scilabopenclose">(</span><span class="scilabid">S</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
<span class="scilabid">Sb</span> <span class="scilaboperator">=</span> <span class="scilabid">im2bw</span><span class="scilabopenclose">(</span><span class="scilabid">Sgray</span><span class="scilabdefault">,</span><span class="scilabnumber">0.1</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
<span class="scilabid">Sd</span> <span class="scilaboperator">=</span> <span class="scilabid">imdistransf</span><span class="scilabopenclose">(</span><span class="scilabid">Sb</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span>
<a class="scilabmacro" href="scilab://subplot">subplot</a><span class="scilabopenclose">(</span><span class="scilabnumber">211</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span><span class="scilabid">imshow</span><span class="scilabopenclose">(</span><span class="scilabid">Sb</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span><a class="scilabmacro" href="scilab://subplot">subplot</a><span class="scilabopenclose">(</span><span class="scilabnumber">212</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span><span class="scilabid">imshow</span><span class="scilabopenclose">(</span><span class="scilabid">Sd</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div>

<div class="refsection"><h3 class="title">See also</h3>
<ul class="itemizedlist"><li class="member"><a href="imwatershed.html" class="link">imwatershed</a> &#8212; Performs a marker-based image segmentation using the watershed algorithm.</li></ul></div>

<div class="refsection"><h3 class="title">Authors</h3>
<ul class="itemizedlist"><li class="member">Tan Chin Luh</li></ul></div>

<div class="refsection"><h3 class="title">Bibliography</h3>
<p class="para">1. OpenCV 4.1.2 Online Documentation</p></div>
<br />

<div class="manualnavbar">
<table width="100%">
<tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr>
<tr>
<td width="30%">
<span class="previous"><a href="imdct.html">&lt;&lt; imdct</a></span>

</td>
<td width="40%" class="center">
<span class="top"><a href="section_8adb84d26782c1d3a5d34be202e5d52c.html">Image Transforms</a></span>

</td>
<td width="30%" class="next">
<span class="next"><a href="imhough.html">imhough &gt;&gt;</a></span>

</td>
</tr></table>
<hr />
</div>
</body>
</html>
4 changes: 2 additions & 2 deletions help/en_US/scilab_en_US_help/imhough.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="manualnavbar">
<table width="100%"><tr>
<td width="30%">
<span class="previous"><a href="imdct.html">&lt;&lt; imdct</a></span>
<span class="previous"><a href="imdistransf.html">&lt;&lt; imdistransf</a></span>

</td>
<td width="40%" class="center">
Expand Down Expand Up @@ -71,7 +71,7 @@
<tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr>
<tr>
<td width="30%">
<span class="previous"><a href="imdct.html">&lt;&lt; imdct</a></span>
<span class="previous"><a href="imdistransf.html">&lt;&lt; imdistransf</a></span>

</td>
<td width="40%" class="center">
Expand Down
4 changes: 2 additions & 2 deletions help/en_US/scilab_en_US_help/imradon.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

</td>
<td width="30%" class="next">
<span class="next"><a href="section_4cd16036872803e658f06738c76a972f.html">Image Types and Color Space Conversions &gt;&gt;</a></span>
<span class="next"><a href="imwatershed.html">imwatershed &gt;&gt;</a></span>

</td>
</tr></table>
Expand Down Expand Up @@ -82,7 +82,7 @@

</td>
<td width="30%" class="next">
<span class="next"><a href="section_4cd16036872803e658f06738c76a972f.html">Image Types and Color Space Conversions &gt;&gt;</a></span>
<span class="next"><a href="imwatershed.html">imwatershed &gt;&gt;</a></span>

</td>
</tr></table>
Expand Down
Loading

0 comments on commit 47b2459

Please sign in to comment.