[IPOL discuss] enabling conditional visualization in demos

Juan Cardelino juan.cardelino at gmail.com
Tue Aug 16 06:46:51 CEST 2011


Dear all,
           I'm restarting the long and painful process of IPOL-izing
my code, and at the moment I'm concerned about visualizing the
results. I have three main points to ask you: which tools will we
allow for visualization if any, how do we implement them, and finally
a particular question about my demo.  In the following I will explain
each point

A) TOOLS ALLOWED FOR VISUALIZATION:
 I've set up a list of tools which are not necessary, but could
improve visualization a lot, at least in my experience. I'm wondering
what do we think about them.

1) imagemagick's convert:
*status: installed
*what do IPOL think about it?: I don't know
*use: animating gifs for level set evolution for example
*example: http://iie.fing.edu.uy/~juanc/files/ev.gif

2)Graphviz (i.e. dot command line option)
*status: not installed
*what do IPOL think about it?: I don't know
*use: As I've been playing with graphs in many ways since a long time,
I've came across the visualization of the following structures: trees
of shapes, binary partition trees, region adjacency graphs,
association graphs, and general graphs.
*examples:
**Visualization of trees, graphs, RAGs and correspondences among them:
http://iie.fing.edu.uy/rosaluna/wiki/Qnm:apps#results (see only the
images)
**visualization of RAGS:
http://gabarro.org/wiki/glshapes#examples_of_usage_of_the_plugin (see
only the images)
**matching of RAGS:
http://iie.fing.edu.uy/~juanc/files/phd/example01/html/images.html

3) makedepend: not for visualization, but my code uses it, can we
enable it at least temporarily until I clean my code?

B) HOW DO WE ENABLE VISUALIZATION
The problem as I see it involves two parts: a demo using a complex
visualization will have the code of the algorithm and the code for
visualization which could be provided by the author or by a third
party library.
I assume that we at IPOL are interested in the middle and long term
availability of the algorithms and that's what lead to the strict
coding policy.
I think we can also asume the visualization is optional and we can
live with less availability. Thus, if we don't want our demos to crash
due to a visualization library changing or disappearing, we should
implement them in a way that if problem happens visualization can be
easily disabled, and we can assure that the main part of the demo will
keep running.
I would like to hear your opinions on this point. Finally, as an
illustration, in the following I show a possible (naive)
implementation of this idea.

C) IMPLEMENTATION OF OPTIONAL VISUALIZATION OF GRAPHS

I'm sure there are many other examples of visualization that require
external tools. Most of the tools in which I'm interested are easily
separable from the algorithm code because they are command line tools.
Lets use graphviz as an use case.  I think it is safe, because the dot
command line tool receives a text file with the description of the
graph and plots it, so you don't need to call any graphivz library
function from the algorithm's code.

You can see the demo running here:
http://iie.fing.edu.uy/ipol/.
Select Mumford-Shah multiscale, and run it. If it happens that you get
a blank page, just hit reload on the browser because I have some
problems with my reverse proxy.

You can get the full code of the demo at:
https://iie.fing.edu.uy/avn/demos/ipol/xxx_ms_partition/
this is a web view of a svn server.
In particular the app.py is available at:
https://iie.fing.edu.uy/avn/demos/ipol/xxx_ms_partition/app.py

Regarding the code to implement that, at the moment my app.py looks like this:

        p1 = self.run_proc(['qnm','ms_tree_vec_demo',
str(a),str(2),self.input_fname, 'output.tr', 'init_part.part'])
        self.wait_proc(p1)

        p2 = self.run_proc(['qnm','ms_apply_treei_color','output.tr',self.input_fname,
str(lzero), 'output.png'])
        self.wait_proc(p2)

        if (self.use_visualization):
            p3 = self.run_proc(['qnm','partition_to_dot_fancy',
'init_part.part',self.input_fname,'init_part.dot'],
stdout=stdout_file, stderr=stdout_file)
            self.wait_proc(p3)
            p4 = self.run_proc([self.tool_neato, '-n2','-Tpng', '-O',
'init_part.dot'],stdout=stdout_file, stderr=stdout_file)
            self.wait_proc(p4)
        return

Then, after that, in the template/result.html I would like to
conditionally include this list item:

    <li>
      <a href="#">graph
	<span>
	  <img src="${app.work_url + output[1]}" alt="graph" />
	</span>
      </a>
    </li>

to show/hide the graph output. The problem is, I don't have the
slightest clue about how to do it. Can someone lend me a hand? Any
suggestions on a better way to do this?

Thanks in advance and sorry for the length of the email.
Best regards,
                   Juan


More information about the discuss mailing list