Difference between revisions of "Customized video montages"

From Dynamo
Jump to navigation Jump to search
Line 13: Line 13:
 
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 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:.
 
   
 
   
  <nowiki> for k=1:100;
+
  <nowiki> for k=1:1000;
   myData{k} = rand(20000,1);  
+
   myData{k} = randn(20000,1);  
 
end</nowiki>
 
end</nowiki>
  
Line 29: Line 29:
 
Now, we have to tell the GUI object what to do on each frame. This is done by defining the method  <tt>depictorOnAxesFcn</tt> 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:
 
Now, we have to tell the GUI object what to do on each frame. This is done by defining the method  <tt>depictorOnAxesFcn</tt> 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:
  
  <tt>gui.depictorOnAxesFcn = @(x,haxis) hist(haxis,x(:),100);</nowiki>
+
  <tt>gui.depictorOnAxesFcn = @(x,haxis) hist(haxis,x(:),100);</tt>
  
 
This command reads as: "for a frame in position <tt>i</tt>, take the position <tt>i</tt> in the stream (i.e., the <tt>i</tt>-th entry in the cell array <tt>myData</tt>  associated to the <tt>gui</tt> object), and show its histogram (with 100 bins) on the axis associated to the frame".  
 
This command reads as: "for a frame in position <tt>i</tt>, take the position <tt>i</tt> in the stream (i.e., the <tt>i</tt>-th entry in the cell array <tt>myData</tt>  associated to the <tt>gui</tt> object), and show its histogram (with 100 bins) on the axis associated to the frame".  
Line 35: Line 35:
 
Now we are ready to go:
 
Now we are ready to go:
  
  <tt>  gui.show();</nowiki>
+
  <tt>  gui.show();</tt>
  
[[File:CustomVideoMontageInline.png |thumb|center|500px| Customized video montage for a cell array ]]
+
[[File:CustomVideoMontageInline.png |thumb|center|500px| Customized video montage to show the histograms of a cell array of vectors. ]]
  
 
== Subclassed montages ==
 
== Subclassed montages ==

Revision as of 11:37, 11 October 2017

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:1000;
  myData{k} = randn(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);

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();
Customized video montage to show the histograms of a cell array of vectors.

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();