Customized video montages

From Dynamo
Revision as of 11:32, 11 October 2017 by Daniel Castaño (talk | contribs)
Jump to navigation Jump to search

Video montages are widely used in Dynamo to show in a single montage part of a stream of data. The user can slide on the subset of the data that is represented at a given moment. Examples of this are found in the slider GUIs used to explore sets of particles, slices inside a given volume, or selections of gold beads.

In this page, we explain how to use the underlying Dynamo objects to create your own visualization systems. We explain two possible approaches:

  • Inline montages

Can be defined easily from the command line without definition of further classes.

  • Subclassed montages

Advanced method. This method offers full flexibility at the cost of requiring from the user the creation of new classes.

Inline montages

You can use the class mbvid.guis.montages.cells.Inline, that allows inline definition of the action to be computed at each frame. For instance, imagine that you have a set of 1000 vectors, and you want to quickly explore their histograms separately. Let's generate a random data set:.

 for k=1:100;
  myData{k} = rand(20000,1); 
end

For 1000 elements, you probably don't want to show them all in a single screen, but rather slide through the data. Thus, we create the object that represents the GUI

  gui = mbvid.guis.montages.cells.Inline(); 

we link now this object with the stream of data

   gui.setVideo(myData); 

My data is a matlab cell array in this example, but you could pass any other object that implicitly defines an stream of data. If you pass, for instance, a volume of dimensions lx x ly x lz, the stream will be defined as a succesion on lz frames.

Now, we have to tell the GUI object what to do on each frame. This is done by defining the method depictorOnAxesFcn to be an inline function of two variables. The first is a dummy variable that represents the content of the stream for a given frame. The second is the graphical axis associated to the frame in the montage. Thus:

gui.depictorOnAxesFcn = @(x,haxis) hist(haxis,x(:),100);</nowiki>

This command reads as: "for a frame in position i, take the position i in the stream (i.e., the i-th entry in the cell array myData associated to the gui object), and show its histogram (with 100 bins) on the axis associated to the frame".

Now we are ready to go:

  gui.show();</nowiki>
Customized video montage for a cell array

Subclassed montages

The underlying generic class for video montages is mbvid.guis.Montage.

Showing the GUI of an user-defined subclass myVideoMontageof mbvid.guis.Montage requires first creating the instance

gui  = myVideoMontage();

then attaching the video stream (if it is not included in the constructor)

 gui  = myVideoMontage();

and them invoking the show method:

gui.show();