43
BLIM Toolbox Manual L. Pape Institute for Marine and Atmospheric Research Utrecht Utrecht, The Netherlands November 2008 R 08-02

BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

BLIM Toolbox Manual

L. Pape

Institute for Marine and Atmospheric Research UtrechtUtrecht, The NetherlandsNovember 2008R 08-02

Page 2: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM
Page 3: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Contents

1 Introduction 31.1 Structure of this manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Installation 52.1 Basic installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.2.1 Argus Runtime Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.2 Matlab versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.3 Mex files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.4 Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 General usage 73.1 Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2 Input location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.3 Image navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.4 Tabpanels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.5 Closing the session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4 Working with BLIM Toolbox 114.1 BLIM tabpanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.1.1 Region of interest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.1.2 BLIM options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.1.3 Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.1.4 Re-BLIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.1.5 Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4.2 View tabpanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.3 Plot tabpanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.3.1 Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.3.2 Plot types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.3.3 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.3.4 Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

4.4 Movie tabpanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.5 Export tabpanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.5.1 Transferring between databases and file system . . . . . . . . . . . . . . . . . . . . 244.5.2 Transferring hydrodynamic data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244.5.3 Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.6 Shared settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254.7 Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.7.1 Settings files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254.7.2 Line colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

1

Page 4: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

4.7.3 Input and output formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

5 Tabpanels 275.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

5.2.1 Tabpanel subfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285.2.2 Toolbox functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

5.3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325.4 Lines in images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

6 Toolbox functions 37

Bibliography 39

Page 5: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

1. Introduction

BLIM Toolbox is a collection of tools for the extraction and analysis of visual features in Argus imagesof the nearshore zone. The toolbox provides an implementation of the BarLine Intensity Mapper (BLIM)algorithm, which extracts more or less horizontal high-intensity bands from Argus images. Also, severalanalysis and export functions are included in this toolbox, such as timestack plots and movies. The mainincentive for the development of this toolbox was reducing the amount of time and effort a user spendson image analysis. This is achieved by a user-friendly graphical interface, functionality for browsingthrough images and results, flexible import and export functions, and the possibility to add user interfacecomponents and additional implementations of algorithms. Because BLIM Toolbox is meant to work withother Argus software, it is programmed in Matlab. For the BLIM Toolbox to run, Matlab needs to beinstalled. However, knowledge of Matlab programming is not required for using the toolbox.

1.1 Structure of this manual

This document consists of a manual describing all the features of the BLIM Toolbox and how to use them.It is advisable to read at least the basic topics, and try to perform the actions in the BLIM Toolbox whileyou are reading about them. This section continues with a brief introduction to the Argus program, andthe background of the BLIM algorithm. Next, the notation that is used in the remainder of this documentwill be described. Section 2 describes how to install and run the BLIM Toolbox. Section 3 explains howto use the general features of BLIM Toolbox, while Sect. 4 describes all functionality in more detail. InSect. 5 is explained how additional modules can be added to the toolbox. Section 6 gives an overview ofsome handy toolbox functions and examples of how to use them in your own scripts.

Some chapters contain advanced tricks and techniques in additional sections, which you can skip onfirst reading. However, when you get more familiar with the toolbox you might find some valuable tips inthose sections.

1.2 Background

The BLIM toolbox is mainly developed for the analysis of Argus images. In the Argus program (Holmanand Stanley, 2007) images of the nearshore zone are gathered using video monitoring stations. Eachdaylight hour, the station’s cameras acquire a time-exposure image (e.g. Fig. 1.1(a)) created by averagingover several hundreds of consecutive images collected at 1–10 Hz. This averages the individual waves toreveal one or more smooth white bands of breaking waves. The oblique images of the individual camerascan be merged and rectified (Holland et al., 1997) to yield a single planview image (e.g. Fig. 1.1(b)). Thecontinuous high-intensity bands that are manifested in the planview images serve as a reasonable estimatefor the submerged sandbars (Lippmann and Holman, 1989), and can be extracted from the images bythe alongshore tracking of intensity maxima (van Enckevort and Ruessink, 2001) (e.g. Fig. 1.1(b)). TheBarline Intensity Mapper (BLIM) algorithm on which the BLIM Toolbox is based, was developed by vanEnckevort and Ruessink (2001). In this algorithm each vertical row of pixels is searched from left to rightfor the maximum intensity value within some neighborhood. The vertical positions of the pixels withmaximum intensity are then smoothed which results in a continuous smooth line that follows the locationof the high-intensity band in the image. This approach works quite well for crisp high-quality images with

3

Page 6: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

(a) Time-exposure Argus images of all cameras; the high-intensity bands in each image are due to persistent wave breakingon the sandbars

cross-shore distance (m)

alon

gshoredistance

(m)

0

400

800

1500 3000

(b) Tracked outer (solid) and inner (dashed) blimlines in plan view

Figure 1.1: Argus camera images, merged plan view and tracked blimlines

clear wave-breaking patterns and no distracting features, but unfortunately such images are not alwaysavailable. To simplify the process of finding the position of the high-intensity bands in the image, a majorimprovement was made to the original algorithm; the region of interest (ROI). With the introduction of anROI, the BLIM algorithm is less confused by distracting features, but the specification of an ROI requiressome additional effort. Specifying the ROI can be done manually by selecting points in the image, but itis also possible to use results of an image as the source of the ROI in the next or previous image. Thisworks exceptionally well when the features do not move much between subsequent images, which is thecase for sandbars on a timescales of hours to days. The combination of these functions in a Graphical UserInterface (GUI) called BLIM Toolbox allows for the extraction of several tens of thousands of sandbarpositions without much effort. This document explains how you can apply the BLIM Toolbox to createyour own datasets of extracted sandbar positions.

1.3 Notation

This manual uses the following notation:[square brackets] GUI elements[Bold, square brackets] keys (on the keyboard)verbatim Matlab code, paths and filenames

4

Page 7: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

2. Installation

2.1 Basic installation

The BLIM Toolbox was designed to run in Matlab version 7.0 and higher, and requires the Image Pro-cessing Toolbox and the Statistics Toolbox to be installed. To see the version of Matlab and the toolboxesthat are installed on your system, open Matlab and enter ver in the Matlab command line. If yourMatlab installation satisfies the requirements, place the BLIM Toolbox Matlab files in a directory (e.g.D:/Matlab/blimtool).

2.2 Advanced topics

Some features of the BLIM Toolbox depend on additional toolboxes and files. If you don’t understandwhat the rest of this section is about, just ignore it and proceed to Sect. 3. BLIM Toolbox will work finewithout the extra features (although you might get some warnings).

2.2.1 Argus Runtime Environment

The analysis of Argus image is usually performed with the Matlab functions that are available in the ArgusRuntime Environment (ARE). However, BLIM Toolbox is designed to work independent of the ARE. Thatmeans that the ARE does not need to be initialized before running BLIM Toolbox. One exception is thetransfer of hydrodynamic data in the [Export] tabpanel, as described in Sect. 4.5.2. Although BLIMToolbox can run without initializing ARE, it mostly adheres to ARE conventions. In several functions itis assumed that filenames are in Argus format. If this is not the case, the functions will still work, butthe results might make no sense.

The functions that are used to communicate with the ARE are located in the argusio directory of theBLIM Toolbox installation path. Some actually communicate with ARE, some duplicate existing AREfunctionality for speed considerations, and some were implemented because the required ARE functionalitywas missing.

2.2.2 Matlab versions

It seems that there are people who think that Matlab 6.5 is the best version of Matlab ever, and try open.mat binary files in a higher version of Matlab and save them in a format that is backwards compatiblewith Matlab 6.5 and earlier. Unfortunately for those people, this trick is not going to work for the BLIMToolbox. When this manual stated that the BLIM Toolbox was designed for Matlab 7.0 and higher, itmeant that the BLIM Toolbox was designed for Matlab 7.0 and higher. Certain functions are simply notavailable in Matlab 6.5, so please update to Matlab 7.0 or higher to use the BLIM Toolbox.

2.2.3 Mex files

BLIM Toolbox uses some custom made mex files which need to be compiled for your system. Especially inMatlab 7.0 and 2007b the settings for mex files have changed, so it is not feasible to supply a compilationfor every operating system. You have to do it yourself. The source files are located in the argusio/avar

5

Page 8: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

directory. If you have no idea what this is about, just ignore it, the BLIM Toolbox will run fine withoutthe mex files, but some features might not be available.

2.2.4 Databases

For certain not altogether aesthetical reasons BLIM Toolbox can communicate with an SQL databaseusing ODBC or JDBC connections. To use the database functionality, the BLIM Toolbox requires theMatlab Database Toolbox to be installed and correctly configured. The words “correctly configured”have to be stressed here, because the Matlab Database toolbox sometimes runs into trouble with itsgetdatasources function. Make sure the getdatasources command does not produce any errors whenthe Database Toolbox is installed. getdatasources is a Database Toolbox function, and if it does notwork, the BLIM Toolbox won’t work either. If you cannot fix the behavior of the getdatasources

function, remove the Database Toolbox; it is not going to be of any use. Ask Matlab to return the moneyyou spent on this mostly useless toolbox. BLIM Toolbox also works fine with a file system instead of adatabase.

Database storage of matrices from the BLIM Toolbox is implemented in Java, because Matlab’s veryexpensive Database Toolbox cannot store and retrieve matrices to database fields. The Java classes inthe argusio/java directory facilitate the storage and retrieval of Matlab matrices. If you cannot get itto work, just ignore it; BLIM Toolbox also works fine with a file system instead of a database. There arehowever some improvements in terms of speed to gain from the use of a database for input and output.

To use a database for your results, you need a database with the right tables and columns in it. MySQLtemplates are given in the examples/mysql directory. Copy the files into your MySQL data directory, andcreate an ODBC or JDBC link to this database. If the Matlab database toolbox is correctly configured,you should see the ODBC or JDBC link listed in the BLIM Toolbox under [Database] in the [Select inputlocation] and [BLIM location] panels. ODBC or JDBC links to other types of databases might work aswell, but this is not tested. Note that the database used for storing images does not actually contain theimage data, but rather a link to an image in the file system. Blimlines and settings are however completelystored in entries in the database and do not contain references to external files.

Everything in the database is referenced on the basis of the filenames of the images. The entrydata

table in the database contains a column with those names, and an additional column with the timestamps,that is used for sorting. Each entry in the database has an id that is used to find corresponding entries inthe imgdata or blimdata tables. To start populating your database, transfer the images from a directoryto the database using the [Export] tabpanel (see Sect. 4.5). More information on storing and retrievingimages and blimlines from a database is given in Sect. 4.7.3, and in the documentation of the loadimage,loadblimline, saveimage and saveblimline functions.

6

Page 9: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

3. General usage

3.1 Start

The BLIM Toolbox starts from the Matlab command line. Change the Matlab working directory to theBLIM Toolbox installation path, and enter the command blimtool. For example, if the BLIM Toolboxis installed in D:/Matlab/blimtool, enter cd 'D:/Matlab/blimtool' in the Matlab command line tochange the Matlab working directory, and enter blimtool to start the BLIM Toolbox. The BLIM Toolboxshould now load, and display on your screen (see Fig. 3.1).

3.2 Input location

The BLIM Toolbox needs to know the location of the input files. Input files are image files in any formatthat Matlab can read (enter imformats in the Matlab command line to get a list), and whose file names arein the Argus filename format (e.g. 928152900.Mon.May.31_12_15_00.GMT.1999.egmond.cx.plan.jpg).Usually, the input location is the directory where the images created by the Argus Merge Tool (AMT) arestored. There are also other ways to tell BLIM Toolbox where to look for image files. You can select andset the input location in the [Select input location] panel (bottom left). There are three different sourcesfrom which the BLIM Toolbox can obtain a list of image files:

[Database]: The BLIM Toolbox can locate input files using an ODBC or JDBC database connection.If the Matlab Database Toolbox is installed, the selection consists of the entries that are returnedby the getdatasources command from the Database Toolbox. When you press the button (rightof the [Database] dropdown menu) a dialog pops up where you can enter a login and password forthe selected source. See Sects. 2.2.4 and 4.7.3 for more information on ODBC and JDBC databasesand tables.

[File]: You can enter the location of the input file, or press the button to select an input file usingthe system’s default file selection dialog. The input file should be a text file containing one filenameper line (without the path to that file), and should be in the same directory as the image filenamesit refers to.

[Directory]: You can enter the input directory, or press the button to select an input directoryusing the system’s default directory selection dialog. Additionally, you can set a filename filter. Thedefault options for this filter are [*.jpg], [*.gif], [*.tiff] and [*.bmp]. At the bottom of the list isan additional custom file filter that you can edit. When you have set a directory and filter, the BLIMToolbox loads all files in the directory whose names match the filter. For example, if the selecteddirectory is D:/Matlab/blimtool/examples/merged, and the filter is set to *.cx.plan.jpg, BLIMToolbox loads all files in that directory that end with .cx.plan.jpg.

The BLIM Toolbox displays the list of files from the selected location in the [Navigate] panel (middle left).Each time the input location changes, the list is loaded from the file system or the database and the firstentry is selected.

7

Page 10: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Figure 3.1: The initial view of the BLIM Toolbox

3.3 Image navigation

The [Navigate] panel contains a list of filenames sorted in ascending order. The selected file and its fullpath are displayed in the image panel at the top of the window. You can navigate through the imagesby direct interaction with the list itself, using the GUI elements, or by using the keyboard. In the GUI,you can press the and buttons to navigate back and forward through the list, or you can enter thenumber of the file in the text field between the two buttons. You can also navigate through the list usingyour [Up], [Down], [PageUp], [PageDown], [Home] and [End] keys.

Instead of selecting and viewing a single file, in some tabpanels it is possible to select multiple filesat the same time. You can select multiple files by clicking and dragging in the file navigation list, or byusing the keyboard controls while holding the [Shift] or [Ctrl] keys. Furthermore, you can use the [Selectnone] and [Select all] buttons at the bottom right to select no or all files respectively. When multiple orno files are selected in the navigation list, the image panel will be empty.

Selections of one or more files can be saved to a text file. Press the [Save selection...] button and selectthe filename and location of the file to which the selection is saved. The resulting text file contains thefilenames in the selection using a one entry per line format. It is recommended that you save this file inthe same directory as the selected files. You can load a saved selection file using the [File] option in the[Select input location] panel on the left. Note that the input file contains the filenames without the pathto each file, and should therefore be in the same directory as the files it refers to.

The zoom functions enable the partial display of a loaded image. To zoom in to an image you canselect a zoom factor from the [Zoom] menu. It is also possible to click in the image itself using the leftmouse button and drag a rectangle. Using this direct manipulation will cause the [Custom] zoom valueto be selected in the [Zoom] menu. When you click the right mouse button, the image zooms out to theprevious zoom level. Zooming in on an image activates the horizontal and vertical sliders for navigation todifferent parts of the image. The selected zoom factor and slider positions will be kept when you navigatethrough images of the same dimension. This feature enables the analysis of large images in smaller parts.

As you might have noticed, in between the image navigation buttons and the zoom menu, there is acheckbox called [Fast navigation]. When this box is selected, the GUI will not be updated when the usercycles through the navigation list very rapidly (e.g. by holding the [Up] or [Down] keys). Only whenthe navigation is stopped, the GUI will be updated and the corresponding image will be shown. This canbe a useful feature when navigating through large datasets.

8

Page 11: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

3.4 Tabpanels

Dividing GUI functionality in a number of tabpanels has certain advantages: for some image sets multipletasks have to be performed; switching between tabpanels enables quick comparisons between differenttypes of information; functions can easily be grouped within the GUI; etc. BLIM Toolbox includes severaldefault tabpanels, and offers the possibility to add your own custom-made tabpanels. The tabpanels arelinked to the navigation panel, and perform operations based on the image or images that are selected inthe file navigation list. A brief overview of the functionality of each tabpanel will be given here, while thenext section discusses each tabpanel in more detail.

[View]: Browse through image details, show a quick overview of blimlines and blimline settings.

[BLIM]: Functionality and parameters settings for the BLIM algorithm.

[Plot]: Plots several timestacks and other types of graphs for blimline results.

[Movie]: Create movies of sequences of image files with blimlines and custom text overlays.

[Export]: Export images or blimlines from a database or directory to another database or directory.

Apart from those tabpanels, you can create your own tabpanels to extend the BLIM Toolbox functionality.How this can be achieved is explained in Sect. 5.

3.5 Closing the session

When analyzing a dataset of several thousands of pictures, you might want to take some rest in betweenor turn to other activities. The BLIM Toolbox saves all GUI settings on exit, and automatically sets theGUI back to the saved settings when you start it the next time. This allows you to resume your analysiswhere you left.

9

Page 12: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

10

Page 13: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

4. Working with BLIM Toolbox

The BLIM Toolbox functions are grouped under a number of tabpanels. The tabpanels are linked to thenavigation panel, and perform their operations based on the image or images that are selected in the filenavigation list. Below, the description of the functionality per tabpanel is given in the order in which youare probably going to use the BLIM Toolbox. It is recommended to try everything while you are readingabout it, because that is the fastest way to learn to use the toolbox.

There is one important thing that you need to keep in mind while working with the BLIM Toolbox:because the BLIM Toolbox works directly with images, it does not know about meters! Every image-related output is therefore given in pixel coordinates, not meters. Exceptions are the plots produced bythe export functions of some tabpanels. For those plots you can enter the pixel resolution (meters perpixel), which will be used to compute the unit labels in meters along the axes of the plot.

4.1 BLIM tabpanel

The functions that produce blimlines can be found under the [BLIM] tabpanel. When this tabpanel isselected, the BLIM Toolbox should look like Fig. 4.1. In the image in Fig. 4.1, two clear horizontal whitebands can be distinguished. These are caused by waves breaking on the underlying sandbars. The BarlineIntensity (maximum) Mapper (BLIM) algorithm can be used to extract the location of these white bandsfrom the image. To restrict the area in which the BLIM algorithm searches for the maximum intensity, aregion of interest (ROI) is used. The ROI is the part of the image in which the BLIM algorithm searchesfor the maximum intensity. In the BLIM toolbox, the ROI is delimited by two parallel, more or lesshorizontal dashed green lines. Instead of searching for the maximum intensity in each vertical row ofpixels in the image as was done in early versions of BLIM (see Sect.1.2), the BLIM algorithm that is usedin the BLIM Toolbox only has to search for the maximum intensity in each row of pixels in the ROI. Thisdoes not only considerably speed up the algorithm, it also makes it possible to set the ROI and interactwith it before the actual BLIM algorithm is executed.

When an ROI is selected, the BLIM algorithm can be executed. The blimline that is tracked by theBLIM algorithm is displayed in the image as a solid red line. If you don’t like the course of the red line,you can simply click on it, and drag it to the position you want. When you release it, it will be smoothedso that it nicely fits into the adjacent parts of the blimline. When you are happy with the blimline, youcan indicate what you want to do with it. The possibilities are to accept, discard or skip the blimline.An accepted blimline is saved to the blimline location (file system or database). In case it is discardedit is also saved to the blimline location, but a reason for discarding it can be given. BLIM results canalso be skipped, which means that nothing is written to the blimline location. Each blimline is savedunder a certain number (from 1 to 10), which allows for the presence of several blimlines in a single image.Blimlines with different numbers have different colors. You can change these colors in the [Options] menu.Previously saved blimlines will automatically be loaded from the blimline location and are displayed whenthe [View] or [BLIM] tabpanels are selected. Accepted blimlines are displayed as solid lines and discardedblimlines as dashed lines. Of course, previously saved blimlines can also be deleted. When a blimline isskipped, discarded, deleted or accepted, the BLIM Toolbox automatically navigates to the previous, sameor next image, depending on the navigation settings.

Setting the ROI for each image can be a time-consuming process. The ROI functions in the BLIMToolbox are mainly implemented to facilitate and speed up the process of ROI selection. An interesting

11

Page 14: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Figure 4.1: The BLIM tabpanel

property of sandbars that can be of great help for determining ROIs in subsequent images is that theymigrate very slowly. Especially when sandbar positions are extracted on hourly to daily timescales, theposition of a sandbar changes only a little bit between subsequent images. When the location of a sandbaris known for a certain image, it would probably be a good idea to search for the position of the sandbarwithin the vicinity of this location in the next image. To implement this idea in the BLIM Toolbox, acopy of the previous accepted blimline is kept in the memory, and can be used as the source for the ROIin another image. For example, if you have found a blimline for a certain day that you are satisfied with,you can save it and proceed to the next image. In that image the BLIM toolbox uses the previously savedblimline and searches within a certain amount of pixels for the maximum intensity. The new blimline canthen be saved and used as indication of the position of the sandbar in the next image, and so on. In thisfashion, you can go through a large number of images and extract sandbar positions without much effort.

4.1.1 Region of interest

Before the BLIM algorithm can be started, the ROI needs to be specified. Because the BLIM algorithmworks for high-intensity bands with a more or less horizontal orientation, the left and right edge of thedomain can be set using two straight, vertical delimiter lines. If you look carefully, there are two greenvertical dashed lines at the left and right edge of a loaded image. These two delimiters determine theleft and right edge of the BLIM domain, and are included in the domain. Of course, the left delimitercannot be placed to the right of the right delimiter, and vice versa. Both delimiters can be picked up anddragged around. However, for some reason Matlab won’t let you pick up the right one when it is too closeto the right edge. The position of the delimiters can also be changed using the sliders and numbers under[Domain]. You can adjust the left and right pixel values of the delimiters, or just enter some values.

Say, for example, you want to analyze only the right part of the image. You can drag the left greendelimiter to 600 pixels. Since you are not going to use the left part of the image, you might as well zoom into the right part by dragging a zoom window around it in the image. In this example, the right delimiteris left in place, but it can of course also be moved to another position.

There are a number of parameters that are used to set the vertical limits of the ROI. Upper and lowerlimits of the ROI are determined by two parallel curves, which are shown as dashed green lines in theimage. The distance between the green lines can be set with the [height] parameter under [Size] (the[width] parameter can also be set here for compatibility with previous versions of the BLIM algorithm).The vertical limits of the ROI are derived from a certain source, which is also a curve. The upper limit of

12

Page 15: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

the ROI is half the size of the height parameter above the source curve, and the lower limit half the sizebelow the source curve. Which source curve is used can be selected in the [Region of interest] area. As youmight have guessed, most of the time, you can use a previously saved blimline as the source curve. Whenno blimline is saved yet, or if you don’t like the ROI based on a previously saved blimline, the sourcecurve of the ROI can be clicked manually in the image. An additional source for the ROI is a blimline inthe present image. This option is meant to make changes to previously saved blimlines.

Another parameter that determines the ROI is the source strength parameter that can be adjustedunder [Strength]. This parameter is a number between 0 and 1, and determines the importance of thesource curve relative to the actual position of the maximum intensity in the image. When this number isset to 0, only the leftmost point in the source curve is used to determine the ROI, while for each adjacentpoint the ROI is guided by the actual image intensity instead of the source curve. A value of the sourcestrength between 0 and 1 indicates that the ROI is determined by a weighted average between the positionof the source curve and the position of the actual highest intensity in the image. When the source strengthis 1, only the source curve is used to determine the ROI, while the actual image intensities are discarded.Most of the time a source strength value of 1 will be the right one for you, because the source curve (theprevious blimline) is a best indicator of the sandbar location.

When you start using the BLIM Toolbox for the first time, no blimline is saved yet, so the [Previousline] option cannot be used. Instead you have to select the ROI manually. You probably also want toselect the ROI manually when you first start analyzing a new set of images or a new sandbar. To selectthe source curve of the ROI manually, click the [Manual] radio button in the [Region of interest] panel.When you click the [Click] button, the mouse cursor changes into a cross, and you can click a numberof points in the image. The last clicked point can be removed by pressing the [Backspace] key on yourkeyboard, and when you are finished clicking points, press [Return], or doubleclick or right-click the lastpoint. The source curve on which the ROI is based, is now composed of straight lines between the pointsyou clicked. To change certain manually selected points, click the [Add points] button. Again, the mousecursor changes into a cross and the manually clicked points appear as green stars in the image. Nowyou can click additional points in the image, and press [Return] when you are finished, or doubleclickor right-click to add the last point. When you add multiple points to the source curve, existing pointsbetween the added left and right points are deleted. In this fashion you can easily change a small part ofthe ROI without having to click all the other points again.

As noted before, a copy of the previous accepted blimline is kept in the memory. When the [Previousline] radio button is selected this blimline is used as the source of the ROI. When you want to extract theblimlines from subsequent images this is the option you probably want to use. Each time you accept ablimline, a copy is kept in the memory, and this copy is used as the source of the ROI in the next image.However, sometimes when something goes wrong, you want to trace back a number of images and restartfrom there. Now, the previously accepted blimline might not be a good source for the ROI anymore.Instead, you can select another saved blimline as source for the ROI. To do so, press the [Select. . . ]button under [Previous line]. In the popup window that appears the present image is already selected,but you can also select any saved blimline from another image. Just make sure you select the right linenumber. The name of the radio button changes from [Previous line] to [Other line] to indicate that theblimline that was in the memory is overwritten by another blimline. When you press the [Accept] buttonor [a] key on your keyboard to save a blimline, this new blimline is kept in the memory, and the name ofthe radio button changes back to [Previous line].

Sometimes you want to make changes to previously saved blimlines, for example to change the smooth-ing factor. Instead of having to specify the ROI again from another blimline, the current blimline canalso be used as the ROI for the current blimline. To do so, select the [Current line] radio button, and thepreviously saved line for the selected line number will be used as the source for the ROI. Note that anROI will not be available when no blimline is saved for the current image under the selected line number.

You might not yet have spotted the small [∧] buttons next to the [Previous line] and [Current line]options, but they are there to copy the blimline that is in the memory or a previously saved blimline tothe [Manual] ROI source. If one of these buttons is clicked, or the [c] key on your keyboard is pressed,points with an interval of 10 pixels are taken from the selected ROI source, and are used to overwrite the

13

Page 16: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

manually clicked points. After that, the [Manual] radio button is automatically selected, and you can addor change points if you like, or just use them to create a new blimline.

Each time you change a setting of the ROI, it is recomputed and updated in the image panel. Notethat changes to an editable text field will only be processed after the [Return] key on your keyboardis pressed, or when another GUI element is selected. Also note that Matlab does not handle graphicaluser interfaces very fast, so being too fast on clicking the buttons will generally result in a Matlab crash.Really.

The upper and lower limits of the ROI are displayed in the image as two dashed green lines. If youdon’t like green lines or if you think they get in front of the interesting stuff, you can disable them byunchecking the [Show ROI] checkbox. Alternatively, you can press the [r] key on your keyboard to switchthe [Show ROI] checkbox. Usually, if you have been working with the BLIM Toolbox for some time youget a feeling for what the ROI does. In that case you don’t need to display it anymore, and you willprobably like the view better without the green lines.

4.1.2 BLIM options

Now that you are able to produce those terribly interesting green lines (see Fig. 4.2), it is about timeto press to [BLIM] button to get a real blimline. Alternatively, you can press the [b] key as a keyboardshortcut for the [BLIM] button. But before you do so, you might want to have a look at the BLIMoptions. The most important option is the smoothing factor. Because the BLIM algorithm works on thepixel intensity values in the image, the results might be at bit wiggly. To smooth out the blimline a bit,each blimline is adjusted by a smoothing algorithm that convolves a window with the noisy blimline. Thewidth of this window (in pixels) can be set by adjusting the [Smooth] parameter in the [BLIM options]panel. To disable smoothing, set this value to 1. The other BLIM parameters are stowed away in thewindow that pops up when you press the [Options. . . ] button.

In the BLIM options window a number of different parameters can be set. In the [Algorithm] panel, youcan select some additional parameters of the BLIM algorithm. In the [Fit function] dropdown menu, youcan select which function is used in case multiple pixels have the same maximum value. The recommendedoption is [Linear], which takes the average vertical position of the pixels with maximum intensity. Thereis also the [Quadratic] fit function which fits a parabola to the pixels with maximum intensity and theirneighboring pixels, and takes the position of the optimum. This gives increased accuracy of the locationof the optimum, but increases computation time drastically.

Another option that can be selected in this panel is the type of smoothing window that is appliedfor the smoothing algorithm. However, since nobody is ever going to use that option, it is left for futureimplementation. The width of this window can be set in the [BLIM] tabpanel in the main window of theBLIM Toolbox, as explained before.

Dragging around blimlines is one of the coolest options in the BLIM Toolbox. However, if you areafraid you can’t stop yourself from dragging around blimlines with your mouse and making up blimlinedata, you can disable this option in the [Enable manual correction] checkbox. When you are dragginga blimline with your mouse, a very simple (for speed) smoothing algorithm is immediately applied eachtime you move your mouse. You can easily see why this feature is implemented by setting the smoothingwindow width for manual correction to 1, and try to drag around a blimline. The width of the smoothingwindow for manual correction should be between about 5 and 50 pixels, but you can change it the wayyou like. Just try some values to see what works best for you. In the distant future the type of smoothingwindow for manual correction can also be set here. Note that the smoothing for manual correction isapplied during the manual correction of a blimline, while the BLIM smoothing window is applied aftereach application of the BLIM algorithm.

Right of the [Algorithm] panel, there is the [Show additional features] panel. In this panel you canselect the blimlines that will be displayed in the images (if available). Also the color of each blimline canbe set by clicking on the color patch that is displayed next to each checkbox. You can also disable thedisplay of all blimlines by disabling the [Show BLIM lines] checkbox. Note that display of blimlines is aglobal option, and will also affect the settings in the [View], [Movie] and other tabpanels. Other featuresthat can be displayed are the progress bar that indicates the progress of the BLIM algorithm, which you

14

Page 17: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

probably want to disable, and the intensity meter. The intensity meter displays the intensity of pixels inthe image when you move your mouse over them. It looks very cool, but it is not sure what it can actuallybe used for. Just disable it if you don’t like it.

The [BLIM location] panel at the bottom can be used to specify the location where the blimlines aresaved and loaded from. When the database toolbox is installed on your system, you can select a databasehere, but otherwise you should select or enter the output directory where the results will be stored. If the[Directory] option is chosen and the directory field is left empty, the Matlab working directory will be used.Blimlines are saved to structures in files with Matlab’s binary .mat format or to a database. Togetherwith the blimlines, the settings that were used for the BLIM algorithm, plus some other information suchas the accept status and the source for the ROI, are also stored. In case the blimline location is a directory,the filenames of the blimline files are the same as the name of the image file from which the blimlineswere extracted, but the filename extension can be different. The default extension is .bar, but you canchange this in the [Extension] field. For example, if you extracted a blimline from the image file named928152900.Mon.May.31_12_15_00.GMT.1999.egmond.cx.plan.jpg, and the blimlines file extension is.bar, the blimline and its settings will be saved to 928152900.Mon.May.31_12_15_00.GMT.1999.egmond

.cx.plan.bar. All blimlines that are available in the BLIM directory or database will automaticallybe loaded and displayed when the corresponding image is selected. To disable the visibility of certainblimlines in the images, you can uncheck the corresponding checkbox in the options window, as explainedbefore. For more information on the format of the blimline files or how the BLIM results are stored in adatabases see Sect. 4.7.3.

When the BLIM options are changed, the blimline that was computed by the BLIM algorithm (if any)is removed. In case the [AutoBLIM] option is checked the blimline is computed anew and displayed in theimage panel. If this box is not checked, you have to press the [BLIM] button or [b] key again to see how thechanged settings of the BLIM algorithm affect the blimline. Also, when the ROI is adjusted by changingany of its parameters, the blimline is not recomputed automatically; you have to press the [BLIM] buttonor [b] key again to see how the changes affect the results. This might seem a bit uncomfortable at first,but you will probably be quite happy that your blimline will stay in place when you carefully dragged itto the right position, and then make a change to say, the smoothing window width or the ROI. Anotherreason for not automatically recomputing a blimline when any of the ROI parameters is changed, is thatthe computation of the blimline takes some time even on really fast computers, especially when you selectthe quadratic fit function for multiple maxima in the BLIM [Options] window. So remember: use the[BLIM] button or [b] key to recompute a blimline after you made changes to the parameter settings.

4.1.3 Workflow

The blimline that is the result of the BLIM algorithm is plotted in the image panel as a solid red line (seeFig. 4.2). As long as it is a solid red line, it is not saved yet. Blimlines can be manipulated by draggingthem around. Just left-click on the blimline, hold the mouse button down and move the mouse around todrag the blimline to a new position. On slow computers this will go really slow, so you have to move yourmouse accordingly slow. Release the mouse button when you are satisfied with the new position. Thepart of the blimline that was changed is smoothed with the present BLIM smooth window settings uponmouse button release, so it will nicely fit into the adjacent parts of the blimline.

Now that you know how to create and adjust a blimline, the blimline can be saved to the file system orto a database. The blimline location can be set in the BLIM options window as explained in Sect. 4.1.2.The only thing that remains to be set is the blimline number. For each image, a total of 10 differentblimlines can be saved to the same blimline file or database record. Each blimline has its own number andcolor, which makes it easy to differentiate between them. When you have selected the blimline number ofyour choice, press the [Accept] button or the [a] key on your keyboard to save the red blimline to the filesystem or database. The saved blimline will be loaded and displayed in the right color in the image panelthe next time you load the image. If a blimline with the selected blimline number already exists in theblimline file or database record, the existing blimline and its settings will be overwritten without furtherquestion.

15

Page 18: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Figure 4.2: A blimline in the BLIM tabpanel

When you are not satisfied with a blimline, it can be saved as a blimline with a discard flag. Pressthe [Discard] button or [d] on your keyboard to open the discard dialog. In that dialog the reason fordiscarding the blimline can be specified. At first, the explanations list will be empty, but you can addexplanations such as “Missing camera”, “Incorrect geometry” or “Bad atmospheric conditions”, and selectthem from the list. Press [OK] to save the blimline and set the discard flag. The explanation text willalso be added to the file or database. Discarded blimlines will be displayed in the image panel as dashedlines.

Another option is to entirely skip the BLIM result, and do nothing to it at all. Press the [Skip] buttonor [s] on your keyboard to do so. You can also delete the blimline with the number that is currentlyselected in the [Line number] dropdown menu, by pressing the [Delete] button or the [Delete] key onyour keyboard. If the blimline with that line number does not exist, nothing is deleted.

You might have noticed the [≫] sign next to the text in the [Skip], [Discard], [Delete] and [Accept]buttons. That sign means that after saving the blimline, the next image is automatically loaded. Thisbehavior can be changed in the [Navigate] dropdown menu. The options are [Next ≫], [Same] and[Previous ≪], meaning that the next, same and previous image is loaded respectively after skipping,discarding, deleting or accepting a blimline. When the [Next] option is selected the arrows in the [Skip],[Discard], [Delete] and [Accept] buttons will be [≫], for the [Previous] option the arrows change to [≪],and for the [Same] option no arrows are shown. Usually you go through your dataset from start to end, sothe [Navigate] menu is set to [Next ≫]. Sometimes, going through the data the other way around mighthelp when you have to deal with a sequence of bad quality images. At other times you like one image somuch that you want to save the blimlines over and over again. That is what the [Same] option is for.

The first time you are using the BLIM Toolbox you probably want to click the [BLIM] button eachtime you want to see some results. It is big, black, bold, you can find it easily at the bottom right,and it just feels good to click on it. After a short while, the blimline appears in red. Then you haveto press the [Accept] button or [a] key to save the blimline. So you probably end up clicking [BLIM],[Accept], [BLIM], [Accept], [BLIM], [Accept], [BLIM], [Accept], or [b], [a], [b], [a], [b], [a], [b], [a], etc.To save some energy, your wrist and your mouse, the automatic BLIM function is implemented. Whenthe [AutoBLIM] checkbox is enabled, the BLIM algorithm is automatically executed each time an imageis loaded. Most of the time you will be perfectly happy with the results of the BLIM algorithm, so youjust press the [Accept] button or [a] key each time. To convince you of the use of the [AutoBLIM] feature,the [Accept] button will automatically be selected each time the BLIM algorithm is executed. So, eachtime an image is loaded, the BLIM algorithm is executed, and the [Accept] button is selected. The only

16

Page 19: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

thing you need to do now is press the [Spacebar]. Instead of clicking [BLIM], [Accept], [BLIM], [Accept],[BLIM], [Accept], [BLIM], [Accept], or pressing the [b], [a], [b], [a], [b], [a], [b], [a] keys, you now usethe [Spacebar] four times. Don’t forget to disable the [AutoBLIM] checkbox when you cycle throughthe images just to have a look at your results. It will save you a lot of time. You can also switch the[AutoBLIM] checkbox with the [t] key on your keyboard.

4.1.4 Re-BLIM

Most Argus image datasets contain some images that cannot be used for the extraction of blimlines.There are various reasons for that, and you can specify one when you click [Discard]. The blimline isstill saved, but the discard flag is set to the explanation you selected. Of course additional reasons fordiscarding blimlines can be added to the list. Finding images that were discarded in general, or for aspecific reason can be done in the [Re-BLIM] panel. It works just like the [Navigate] panel. The list ofselected entries is in the dropdown menu that appears when you click the [∨] button. Click it again tomake it disappear. There are three default options: [All entries], [Accepted lines] and [Discarded lines],which load all blimlines, all blimlines which were saved by using the [Accept] button, and all blimlinesthat were discarded for whatever reason, respectively. Note that the line number that is selected is alsoadded after each option for clarity. For each reason in the discard list an option is added to the Re-BLIMselection list. The number of entries that is selected is also given under [Selected entries], which allowsyou to see the number of images that were discarded for a certain reason.

When a selection from the Re-BLIM dropdown menu is made (other than [All entries]), the behavior ofthe navigate action that is performed when the [Skip], [Discard], [Delete] or [Accept] buttons are pressedchanges. Instead of navigating to the next or previous file in the input navigation list, the next entry inthe Re-BLIM navigation list is loaded. In this fashion it is possible to go through the list of discarded oraccepted images, or to perform the BLIM algorithm again on previously discarded blimlines. When theselected reason in the [Make selection] dropdown menu is changed, the list of blimlines has to be scannedfor blimlines that match the selected criterion. When the blimline location is a directory, this can takequite some time. Each time a blimline is saved, the list has to be updated, which might cost some time.So when you are not looking for discarded images in specific, the selection should be set to [All entries].The selection is automatically reset to [All entries] when the blimline number, the image input location orthe blimline location is changed. Note that it is much less time-consuming to select a list of blimlines thatsatisfy a certain discard criterion from a database, so loading blimlines from a database is the preferredoption if you want to use the Re-BLIM functions.

4.1.5 Advanced topics

This section contains some tips and tricks to enhance your skills of working with blimlines and increaseyour productivity. Make sure you understand the previous sections, before you proceed to the advancedtopics below.

Dragging around blimlines is exceedingly cool. For some users it might take some time to realize thatit is not only possible to drag blimlines up and down, but that they can also move their mouse to the leftand right while dragging. Try this if you don’t understand what this is about.

It might be the case that you are for some reason not satisfied with the smooth window width, thedomain or some other setting that was used for a set of blimlines. It is possible to go through the resultsand alter them relatively quickly. First, you have to set the source of the ROI to [Current line]. Noweach time an image is loaded, the toolbox checks if there is already a stored blimline for the selected linenumber, and uses that blimline as the source of the ROI. To get the exact same blimline, set the ROIheight to a value of 1 or 2. Next, check [AutoBLIM], set [Navigate] to [Next ≫], and you can easily gothrough the images with the new settings clicking [Accept], or just pressing [Spacebar].

Using very small heights of the ROI can cause unexpected results. The ROI boundaries are set tointeger pixel values, so some rounding of the ROI source values occurs. Furthermore, odd values of theROI height must be rounded because top and bottom boundaries are rounded to integer pixel coordinates.Values are rounded down, which causes the ROI to move slowly down for odd ROI heights when going

17

Page 20: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

through a large number of all-black images. This is not really a problem, because blimlines for all-blackimages are meaningless anyway. At least you can understand now why this happens if you encounteredthis problem.

As mentioned before, Matlab won’t let you pick up the right ROI delimiter when it is too close tothe right edge. The position of the delimiters can also be changed using the sliders and numbers under[Domain]. Just decrease the [Domain (right)] value a little bit and you will be able to pick the line up andmove it around in the image.

Like any other smoothing algorithm the smoothing algorithm that is used to smooth blimlines has todecide what happens at the edges. The algorithm that is used for the BLIM Toolbox extends the blimlineon both edges with the value at had at the edge. If you want to use your own smoothing algorithm, readthe documentation in the smoothline function. Make sure it runs fast.

The BLIM Toolbox works with lists of images whose filenames are in Argus format. The files areordered by timestamp, but no actual notion of time is available in the toolbox. Usually lists of images arecreated using Argus Merge Tool (AMT). AMT does not produce a merged image when the input imagesare missing for all cameras. It would make sense to produce an all-black image instead of no image at all,but that is up to the creators of AMT. When navigating through a list of images in the BLIM Toolboxit is not immediately clear that certain images are missing from the list. Only a careful examination ofthe time values in the filenames reveals this. When you go through the images using previously savedblimlines as the source of the ROI, this can become a problem. For example, if images are missing for acertain period in which the sandbar moves considerably, it is not immediately clear to the user that thishas actually taken some time. After all, the next available image after the period in which the images weremissing is loaded without notice. It might therefore be useful to add all-black images instead of leavingout missing images. Of course those all-black images should have the same size as the other images in thedataset, in order to leave the zoom and domain values of BLIM Toolbox unaltered.

Sometimes a certain region of the images cannot be used for blimline extraction. For example, theremight be a pier in the middle of the images which distorts the results. In that case it is possible to extractblimlines from the left and right parts of the images individually. First, you start with the left part bysetting the domain delimiters to the left and middle of the image respectively, and extract blimlines fromthat half. Next, you can move the right domain delimiter to the right of the image, and the left domaindelimiter to the middle of the image. Don’t forget to select another line number for the right part of theimage, because otherwise the blimlines of the left part will be overwritten. Now you can go through theimages once more and extract blimlines from the right part of the images.

Each blimline in the BLIM Toolbox has its own color. If you don’t like the colors in which the blimlinesare displayed, you can change them in the [Options] window. You can also change the color of the currentlyselected line by clicking on the color patch next to the line number selection menu. The line colors areused by other tabpanels as well, so any changes you make will be visible in all tabpanels.

The reasons for discarding blimlines are stored in a file called explanations.set, which is stored in thetabpanels directory of the BLIM Toolbox installation path. Make sure not to delete this file accidentally.

4.2 View tabpanel

In the [View] tabpanel (see Fig. 4.3) the details of blimlines and images are show. Image width, height,and colorspace details are displayed in the [Image info] panel. This data is of course updated when a newimage is loaded. To show blimlines on top of the images, select the blimline location and the blimlines tobe shown in the dialogs that pop up when you clicking the [Select location...] and [Select lines...] buttons.The location of the blimlines is the same as in the BLIM tabpanel as described in Sect. 4.1.2, so you onlyhave to set it once. Changing the location or the blimlines to be shown will also affect the location andblimlines in other tabpanels.

In the [BLIM info] panel, the details of a single blimline are show. If there are multiple blimlines, youcan select another blimline by clicking on it in the image, or selecting it from the [Line number] dropdownmenu. When you navigate to another image, the selected line number will be shown if it exists. If not,the available blimline with the lowest line number will be displayed.

18

Page 21: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Figure 4.3: The View tabpanel

Sometimes you want to communicate the idea of a blimline with the rest of the world, preferably nicelydrawn on top of the best Argus image you can find. To export an image with the blimlines drawn on topof it, click the [Export image. . . ] button in the bottom right panel. But before you do so, you might wantto set the export options first. The colors and widths of the lines that are shown can be set in the [Selectlines. . . ] panel. Another cool option is to include axes around the image that gives the viewer some ideaabout the scales involved. Since in BLIM Toolbox everything is counted in pixels, you should specify thenumber of meters that go in one pixel. The zoom settings will be preserved in the exported image, so youcan export just part of an image by drawing the rectangle in the image panel. When you are done, pressthe [Export image. . . ] button, and a new window with the image and everything in it pops up. Use thenormal Matlab (edit and) save functions to save your image the way you like.

4.3 Plot tabpanel

After producing several blimlines, an overview of the results can be plotted in the [Plot] tabpanel (seee.g. Fig. 4.4). This tabpanel offers functions for visualizing results in different ways, such as blimlineposition and migration timestacks, and alongshore averaged blimlines as a function of time. Severalplotting options, such as zooming (in time), line colors, background colors and color maps, are available.This allows you to clearly visualize any features of interest in the blimlines, which is not only useful toanalyze the data, but also to reveal any sudden changes or other errors made in the creation of blimlinesor the images from which they are derived (e.g. geometry errors). If you find a blimline that mightbe wrong, you can go to the BLIM tabpanel and correct it. BLIM Toolbox automatically updates anychanges made to the blimlines when the [Plot] tabpanel is selected again. Additionally, when you createa graph or timestack you can export it to a Matlab figure, and then print or save it in any format yourMatlab installation supports.

4.3.1 Navigation

The first step in creating a plot is selecting the entries in the navigation panel for which you would liketo load the blimlines. Alternatively, you can press the [Select all] button to select all entries in the list.Next, choose the blimline that you want to load from the [Line number] dropdown menu (this menu isonly visible for the [Position] and [Migration] plot options). Now press the [Load] button to load the

19

Page 22: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Figure 4.4: A timestack in the Plot tabpanel

selected blimline. Note that the timestack data is loaded for only one line number at a time. Loading allblimlines for the selected entries would cost too much memory for large datasets. If you want to load adifferent blimline, you have to select another blimline from the [Line number] dropdown menu, select theentries for which you want to load that blimline, and press the [Load] button once more. Apart from theblimlines for the selected number, also the average cross-shore positions for all blimlines are loaded. Oncethe blimlines and averages are loaded, you can easily switch between the different timestack or averageplots. You can navigate through the navigation list or change the plot type and plot options withouthaving to reload all the lines. However, when you change the image input location, the blimline location,or the selected line number, you will have to reselect the entries and reload the blimlines. As mentionedbefore, blimlines that are changed in the [BLIM] tabpanel will automatically be updated once the [Plot]tabpanel is selected again.

You can navigate through the list of image by selecting a (single) entry in the file navigation list, orby clicking in the plot. In case of the migration plots, a horizontal line will be shown at the index of theselected input file, while in the average plot, a vertical line will indicate this position. Just click in the plotto move the line, and the selected entry in the file navigation list. On multiple or no selection, no line willbe shown. The indicator line is especially useful for correcting erroneous blimlines. For example, whenyou spot a deviating value for a blimline, you can select it by clicking in the graph. This will select thecorresponding entry in the navigation list. Now you can go to the [BLIM] tabpanel, correct the blimlineand save it. When you go back to the [Plot] tabpanel, the changed blimline will automatically be loadedand updated in the plot. If you did not change the selected entry (this could happen if the [Next ≫]option was selected in the [Navigate] menu in the [BLIM] tabpanel), the location of the black line willhelp you remember which blimline you selected.

Because detail might be lost for large datasets, you can choose to zoom in on part of the data in thetemporal dimension. Selecting one of the options in the [Zoom] menu in the [Plot] tabpanel will set theheight (timestack) or width (average) of the plot to the corresponding number of entries. If more entriesare loaded than specified in the zoom option, horizontal (timestack) or vertical (average) scrollbars willbecome active, which allow you to scroll to other parts of the data. Note that on slow computers andlarge datasets, scrolling can be slow.

20

Page 23: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Figure 4.5: An average plot in the Plot tabpanel

4.3.2 Plot types

There are basically two types of plots that can be created in the [Plot] tabpanel: timestacks and alongshoreaveraged blimlines. Timestack plots display the properties of each blimline in the selection stacked fromtop to bottom (equivalent to the ordering in the file navigation list). The vertical axis represents the timein number of image entries, while the horizontal axis represents the alongshore position (in pixels). Thecolors in the timestack plot represent some cross-shore feature, such as the position or migration betweensubsequent entries. An example of a timestack plot in BLIM Toolbox is depicted in Fig. 4.4. Apartfrom the timestack modes, there also is an [Average] plot mode. The averages that were loaded for eachblimline are plotted in the vertical as a function of time (in entry number) on the horizontal axis. Youcan enable or disable each blimline, and set its color in the [Select lines. . . ] menu that becomes visiblewhen the [Average] option is selected. Figure 4.5 gives an example of an average plot for two blimlines.Several options are available for each mode:

[Position]: The colors represent the cross-shore position of the blimline. Color values increase fromcold (to the top) to warm (to the bottom of the image). Because the shoreline might be curved,or not exactly horizontal in the image, you can choose to detrend the blimlines by enabling the[detrend] checkbox. This will subtract the alongshore variability larger than half the width of thetimestack plot from each blimline. Note that some bending might occur at the edges. The valuesin the detrended timestack plot are given relative to the subtracted trendline (i.e. positive andnegative).

[Migration]: This type of timestack contains the difference between the blimlines of subsequententries in the file navigation list. Values can be negative (to the top) or positive (to the bottom ofthe image). Checking the [absolute] value will only yield positive values, so that the magnitude ofmigration can be revealed.

[Average] This plots the cross-shore average position of each blimline as a function of time. Whenthe [weighted] mode is selected, the weighted average instead of the normal average will be plotted.Weighted averages are computed using pixel footprint maps, but some releases of BLIM Toolboxmight not implement this feature.

21

Page 24: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

4.3.3 Options

Each type of plot has several additional options available that determine its look and feel. First, youcan choose whether to show any blimlines that were flagged as discarded in the BLIM process. Averageplots will show discarded blimlines as dotted, and accepted blimlines as solid lines, while missing blimlinesare simply gaps. Timestack plots show missing blimlines in the background color, accepted blimlines asopaque according to the selected colormap, and the opacity of discarded blimlines can range between 0.1and 1. If you don’t like the default (gray) background color of the graphs, you can change it by clickingon the patch next to [Background color] and select a new color. Timestack plots also allow you to set thecolormap, and the range of its values. Just play around with these to see what the effects are. Changingthe color limit values can be especially useful to visualize large changes in the data.

While in the timestack plots only one line number is shown, the average plot displays average valuesfor all blimlines. You can choose which blimlines to show in the [Select lines. . . ] menu, set the color ofeach line, and set the width. A legend for the blimline numbers is shown to the right of the graph. Youcan choose the location of this legend in the [Legend] dropdown menu.

4.3.4 Export

Once you have created the perfect graph or timestack, you might want to export it, so that you can use itoutside BLIM Toolbox. Press the [Export. . . ] button to open a new figure. All settings that were madein BLIM Toolbox will also be used in the exported figure. Additionally, since BLIM Toolbox only knowsabout pixels, while the axes probably should be given in meters, you can select the number of meters perpixel for the exported graph. If the entries in the navigation list are specified in Argus filename format,times are derived from the image filenames, and the corresponding axis is labeled accordingly. Next youcan export the graph to any format your Matlab installation supports.

4.4 Movie tabpanel

In the [Movie] tabpanel (see Fig. 4.6) you can create movies of images and blimlines. Several filters andinterpolation algorithms are applied to ensure that the resulting movies look great. To reduce flickeringcaused by difference in light conditions between images, a moving window filter is applied to the list ofimages. Additionally, frames can be added in between subsequent images to ensure a smooth transitionfrom one image to the next. The movie creation function can load and render additional features intoeach movie frame, such as blimlines, text and a graph of hydrodynamic data. You can select the featuresthat will be included in the movie in the [Movie] tabpanel.

Additional settings for movie creation can be found in the [Advanced options. . . ] menu in the [Movieoptions] section. You can specify the size of the movie in pixels in the [Width] and [Height] fields. Settingone of these values to 0 will set the width (height) proportionally to the height (width). If both the widthand height are 0, then the original image size will be used. The number of movie frames per second can beset in the [FPS] field, and the number of images per second in the [IPS] field. If the number of frames persecond is larger than the number of images per second, additional interpolated frames are added betweentwo subsequent images, which results in a smooth transition. You cannot set the number of images persecond to a higher value than the number of frames per second. A smoothing filter can be applied tosubsequent images, which can substantially reduce the flicker in movies due to rapidly changing lightconditions. The type of filter can be set in [Filter], and the width (in number of images) in [Size]. If youdo not want to use the smoothing filter, you should set the smoothing window width to 1. Additionalsettings that can be changed are the compression filter (dependent on your operating system), the qualityof the compression, the renderer of lines and text in movie frames, and the amount of memory that willbe allocated to the movie creation process. Set the amount of memory allocated to the movie creationprocess to at most half of your system’s operating memory, because Matlab might need several tens ofmegabytes just for itself. If you set it to a value that is too large, a lot of loading back and forth betweenthe swapfile or pagefile of your operating system occurs, which drastically increases the time needed forcreating a movie.

22

Page 25: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Figure 4.6: The Movie tabpanel

Apart from creating fascinating movies, the toolbox can also put additional information in each movieframe. The date of each frame derived from the filename can be rendered in the movie, together withsome additional user-specified text. Enable the [Show image info in movie frame] field to do so. You canenter some additional text in the [Movie name] field. The font, size, location, and color of the text can beadjusted in the [Advanced options. . . ] menu in the [Text] panel. [Text x] is the horizontal offset in pixelsand [Text y] the vertical offset, counted from the bottom-left corner. You can change the font by clickingon the [Font. . . ] button, and the font color by clicking on the patch next to the [Color] field.

Blimlines can also be plotted on top of each movie frame. Check the [Show BLIM lines in movie] boxto do so. You can select the blimline location and the blimlines you want to display in dialogs that pop upwhen you click the [Select location...] and [Select lines...] buttons respectively. The colors and widths ofthe blimlines in the movie can also be set in the [Select lines...] panel. Changing the blimline location orthe visibility and color of blimlines will also affect the blimline location and blimlines in other tabpanels.The positions of blimlines are interpolated between subsequent images if the number of frames per secondis larger than the number of images per second.

The hydrodynamic data that is present in the blimline files can be plotted as an additional graph ineach movie frame. To use this option, check the [Plot hydrodynamic data] option, and select the blimlinelocation from which this data should be loaded. Note that hydrodynamic data should first be queriedfrom the ARE and saved to blimline files as explained in Sect. 4.5.2.

In the [Advanced options. . . ] menu, the margins of the image can be set as a ratio between 0 and 1in the [Horizontal margin] and [Vertical margin] fields. The background color that will be used to fill themargins can be set by clicking on the [Background] color field. Set the margins to 0 to disable.

When all the settings are the way you want them to be, you can select the images that should beincluded in the movie in the navigation panel. You can also press [Select all] to select all images at once.Now click the [Save movie...] button, and specify the location where the movie will be saved in the save filedialog. Press [OK] and the movie creation process starts. Images are loaded into the memory in batchesbefore they are processed. The amount of memory that is reserved for one batch is set in the [Memorylimit] option in the options dialog. Per batch a progress bar is shown with the number of the batch in it.Note that creating movies can take quite some time depending on your system, the amount of images andthe movie settings (O(hours)).

If you are interested in the details of the movie creation function, read the documentation in theimgblimhydro2movie function.

23

Page 26: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Figure 4.7: The Export tabpanel

4.5 Export tabpanel

The [Export] tabpanel (see Fig. 4.7) was developed to perform tasks on a selection of entries at once.The main purpose is to export images, blimlines or other settings to another location or format (hencethe name [Export]). Other functionalities are implemented as beta, and might not be available in somedistributions.

4.5.1 Transferring between databases and file system

One function that is implemented by the [Export] tabpanel is the transfer of images, blimlines and blimlinesettings between the file system and a database. A database template can be found in the examples/mysqldirectory of the BLIM Toolbox installation path. Since in the database everything is referenced by thefilenames of images, a list of filenames has to be created first. This list will be stored in the entrydata

table, which is used to refer to other entries such as blimlines. To create this list, specify a file or directorythat contains image files as input location in the [Navigate] panel. In the [What to transfer?] panel select[Images]. Next, select the images you want to transfer to the database, or select them all by pressing the[Select all] button. Choose a database from the list of databases in the [Select output location] panel.Since the transfer might take some time for large image datasets, you can check the [Show progress bar]button to show the progress during transfer. Press the [Transfer] button to start the transfer. Note thatthe database contains only references to the location of the images files, not the image data itself.

Transferring blimlines goes in the same fashion. Select the images for which you want to transfer theblimlines in the [Navigate] panel, choose the blimline location by pressing the [Select location...] button,and start the transfer.

Note that transferring blimlines or settings from one directory to another in your file system can beachieved easily by just making a copy of the blimline files with the functionality of your operating system.

4.5.2 Transferring hydrodynamic data

The [Hydrodynamic data] option is implemented as beta, and might not be available in some distributions.When the [Hydrodynamic data] option is selected, hydrodynamic data obtained from the Argus RuntimeEnvironment (ARE) are transferred to the blimlines files or database. The ARE needs to be initializedwhen transferring hydrodynamic data. This can also be done after BLIM Toolbox is started. Just reselect

24

Page 27: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

the [Hydrodynamic data] option in the [What to transfer?] panel after initializing ARE. BLIM Toolboxwill try to select the right station from the list of available stations in ARE automatically. If this doesnot work, you can manually select the station from the dropdown list.

The hydrodynamic data is saved in the blimsettings structure of blimline files, or in the hydrodata

table in case of a database. Hydrodynamic data is queried in two modes; instantaneous, and averaged.Instantaneous values are queried at the time that is derived from the filename, so approximately at thetime the image was taken. Average values are queried in between subsequent images. These values areindexed at the time of the second image, so they represent the values of the hydrodynamic data averagedover the period between that image and the preceding image in the selection. For the computation ofaverage values for the first image, the average time between all selected subsequent images is computed,subtracted from the time of the first image, and the average over that period is taken. Further informationcan be found in the exportpanel function.

4.5.3 Advanced topics

If you made changes to the saveblimline function, you might want to use the export tabpanel func-tionality to update all your blimline files at once. Just press [Select all], [BLIM lines], and choose a newoutput location, or the same location as the blimline or input location if you feel lucky. Press [Transfer]to save the updated blimline files or database records.

4.6 Shared settings

There are a number of settings that are shared between the different tabpanels. If you change them in onetabpanel, they will also change in all the other tabpanels that use those shared settings. Most of the time,the help text for a certain field will contain a warning that it concerns a shared setting. Shared settingsare the blimline location, the blimline filename extension, whether to show any blimlines in the images,the selection of blimlines to show and the colors and widths of those lines. The advantage of using sharedsettings is that you have to change it only once. However, make sure not to accidentally overwrite yourdata when changing the blimline location!

4.7 Advanced topics

4.7.1 Settings files

Although highly unlikely, it might occur that you have changed some settings that cause BLIM Toolboxto crash on loading. For example, if you select a database as input location, close the toolbox, uninstallMatlab’s database toolbox, and start BLIM Toolbox again, it tries to load the database, which it cannotand crashes. Also when you start developing your own tabpanels (see Sect. 5), things might go wrong.As discussed in Sect. 3.5, the toolbox loads the settings that were saved the last time you closed it. Thishappens before the toolbox is displayed, so it will crash before you can change the setting that causes theproblem. All settings are written to several .set files in the tabpanels directory. If you remove thosefiles, the default settings will be used when the toolbox loads (which should work), and a new file will bewritten when you close the toolbox. Files that you might not want to delete are linecolors.set (seeSect. 4.7.2) and explanations.set (see Sect. 4.1.5).

4.7.2 Line colors

Each blimline number in the BLIM Toolbox has its own color. The file linecolors.set contains the colorvalues for the blimlines. If you don’t like the colors in which the blimlines are displayed, you can changethem. Note that in BLIM Toolbox, lines that are used for the ROI are green, while active blimlines arered. You might want to avoid those colors to prevent confusion. The ten blimline colors are used by othertabpanels as well, so any changes you make will be visible in all tabpanels. Changes are automatically

25

Page 28: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

saved to linecolors.set. If for some reason the linecolors.set file is missing, all blimlines will bedisplayed in the default (= white) color.

4.7.3 Input and output formats

The BLIM Toolbox needs to communicate with the outside world to load images and to load and saveblimlines. There are a number of functions that form a bridge between the BLIM Toolbox and the fileformats that are used. These functions can be found in the argusio directory of the BLIM Toolboxinstallation path. For loading and saving images the functions loadimage and saveimage are used. Thesefunctions load and save images from the specified locations and convert them between their native formatand the format that is used by the toolbox. The loadimage function uses the Matlab imread and iminfo

functions, so the types of images that can be read are determined by the Matlab settings for loading images(enter imformats in the Matlab command line to get a list). BLIM Toolbox works with images in 24-bitRGB color space in uint8 format. Loading images from binary .mat files is not implemented, but if youneed to load them, it can be easily implemented. See the documentation in the loadimage function. Iffor some reason you need to save images from inside BLIM Toolbox, you can use the saveimage function.

In case of a database, the entries in the imgdata table are used to load the image with the name inthe filename column from the location in the location column. The entries in the imgdata table arelinked with their id to those in the entrydata table, which uses the filename of an image as its identifierin the name column, and an additional column time for sorting.

Loading and saving blimlines is handled by the loadblimline and saveblimline functions. Addi-tionally there is a deleteblimline function that is used to delete blimlines. In the documentation ofthese functions is explained how the blimlines are saved and what you need to do to change them if youwant to use your own format. In case the location of the blimlines is a directory, the blimlines are savedto a file with the same name as the image file from which they are extracted. The file name extensionof the blimline file can however be different (the default is .bar). Blimline files are written in Matlab’sbinary .mat format, and can be loaded using the Matlab load function with the mat option. It is howeveradvisable not to load them directly, but to use the loadblimline function instead. Per file a total often different blimlines can be saved. Each blimline is saved in the variable blimline_linenumber, wherelinenumber is the number of the blimline that was selected in the GUI (e.g. blimline_2 for line number2). Each blimline_linenumber is a 2 × d matrix, where d is the length of the domain as explained inSect. 4.1.1. The first (horizontal) row contains the horizontal pixel coordinates, and the second row thecorresponding vertical pixel coordinates of the blimline. Furthermore, the settings for each blimline arealso stored in the blimline files in blimsettings_linenumber structures, where linenumber again is thenumber of the blimline that was selected in the toolbox. The elements that are stored in this variable arelisted in the documentation of the loadblimline and saveblimline functions.

Blimlines can also be stored and loaded from a database. First, the id column of the image from whichthe blimline was extracted is looked up in the entrydata table, and the record with the correspondingid in the blimdata table is written. This table contains a column for each of the different variables ofthe ten blimlines. For example, a blimline with number 6 will be saved to the blimline_6 column, andthe settings that were used for this blimline to the blimstart_6, blimend_6, discard_6, etc. columns.See the documentation of the saveblimline and loadblimline functions for a complete listing of thevariables that are saved.

26

Page 29: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

5. Tabpanels

BLIM Toolbox is created in a modular fashion. Modules in BLIM Toolbox are represented in the GUI bytabpanels, and in the code as tabpanel files. If you want to extend the toolbox with you own functionality,you can add a tabpanel of you own. Adding tabpanels instead of programming your own GUI has severaladvantages: you can use the BLIM Toolbox functionalities for viewing, loading and browsing throughimages. Also, if your added functionality involves blimlines, the toolbox can be helpful in loading anddisplaying those. Another advantage is that you can easily switch between different tabpanels while usingthe BLIM Toolbox, which then includes your own tabpanel. Creating a tabpanel requires beginners knowl-edge of Matlab, and a template tabpanel called mypanel.m, which is located in the examples/tabpanels

directory of the BLIM Toolbox installation path. This section will guide you through the process ofcreating your own tabpanel and extending the functionality of BLIM Toolbox.

5.1 Basics

The default tabpanels of the BLIM Toolbox are located in the tabpanels directory of the BLIM Toolboxinstallation path. These .m or .p files contain the code for the creation of GUI elements, and severalsubfunctions that implement the actions that can be performed by the tabpanel. BLIM Toolbox searchesfor .m and .p files that implement the PanelName subfunction, each time you start it. When you place an.m or .p in the tabpanels directory that implements this subfunction, BLIM Toolbox will think that itis a tabpanel, and will try to load it into the GUI.

The execution of code in a tabpanel is initiated by the interaction with the GUI elements of that orother tabpanels. The functions that should be executed when the user interacts with the GUI elementsof a tabpanel should be specified within that tabpanel file as subfunctions. Sometimes, a tabpanel shouldperform certain actions when the GUI elements of the BLIM Toolbox in general or other tabpanels areinteracted with. Those actions require certain subfunctions to be present in the tabpanel file. Every timesuch an action is performed, BLIM Toolbox calls those subfunctions in all tabpanel files. These subfunctionmight not do anything (i.e. contain no code), but they always need to be declared! In Sect. 5.2.1 thesubfunctions that need to be declared in a tabpanel file are discussed. How tabpanels can notify BLIMToolbox about the general actions that need to be performed, is explained in Sect. 5.2.2.

Subfunctions of tabpanels perform actions on variables. All data that can be accessed by the GUIand the tabpanels, are contained in a variable called handles. This structure is the GUI equivalent ofthe workspace in Matlab. The handles structure should be passed from function to function, until theactions that need to be performed by the initiating GUI element are complete. It should then be savedto the GUI. How and why this should be done exactly, and more details of the handles structure is thetopic of Sect. 5.3.

In the tabpanels directory of the BLIM Toolbox installation path you will find an example tabpanel,that already implements the required subfunctions and some examples of GUI elements and settings. Youcan use this file to see some examples of what a tabpanel can be used for and how certain features canbe implemented. If you want to load this tabpanel and experiment with it, just copy it to the tabpanels

directory of the BLIM Toolbox installation path, and load BLIM Toolbox. You will now see an additionaltabpanel called ‘MyPanel’. This tabpanel can serve as the basis for your own added functions in BLIMToolbox.

27

Page 30: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

5.2 Functions

A question that might have risen while reading the previous is how BLIM Toolbox can load subfunctionsthat are located inside a file. While this is normally not possible in Matlab, each tabpanel file as well as theBLIM Toolbox blimtool file implements a main function whose only task is to transfer calls to subfunc-tions in that file. The main function has the same name as the filename of the tabpanel. In the mypanel.mfile, the main function is specified with function varargout = mypanel(varargin). This main functionsimply transfers all calls that are made to it to the specified subfunction in the mypanel.m file. To call asubfunction from outside a file, you should supply the subfunction name as the first argument of the mainfunction, and the subfunction’s arguments as the next arguments. Subfunctions of the BLIM Toolbox andthe tabpanels can be called with the following syntax: [out1, out2, ...] = filename('subfunction',arg1, arg2, ...), where filename is the name of the function, subfunction the name of the subfunction,arg1, arg2, ... the input arguments that will be provided to the subfunction, and [out1, out2 , ...]

the output values of the subfunction. For example, the onImageLoad subfunction of mypanel has threeinput arguments: hObject, eventdata and handles, and one output argument: handles. To call thissubfunction from outside the mypanel function, use: handles = mypanel('onImageLoad', hObject,

eventdata, handles).

5.2.1 Tabpanel subfunctions

There are several subfunctions whose declaration in the tabpanel file is required, because BLIM Toolboxmight call them on some occasions. This section contains a list of those subfunctions, and explains whatthey are for. You might want to open the template tabpanel file mypanel.m for comparison while readingthis section. Also, the other tabpanel files in the tabpanels directory might give you some hints on howto achieve certain functionality.

function name = PanelName

The PanelName subfunction should do only one thing: return the tabpanel name. This name will be usedas the name of the tab button for that tabpanel in the GUI, and also as an indicator, for example, tocheck which tabpanel is currently selected. If you create a tabpanel based on the mypanel template, justchange the name variable.

function handles = LayoutFcn(hObject, eventdata, handles)

The first subfunction that is called after BLIM Toolbox recognized the tabpanel by successfully executingthe PanelName subfunction, is LayoutFcn. This subfunction should contain the commands that createthe GUI elements. Any GUI elements that you create, will be added to the handles structure in a fieldname specified by the Tag field of the GUI element. So, for example if you add a checkbox, and assign thevalue cbmycheckbox to the Tag field, the handle to that checkbox after the execution of the LayoutFcn

will be handles.cbmycheckbox. Similarly, when you have to specify the parent of a GUI element, youcan use this syntax by referring to handles.tabframe, which is the frame where the GUI elements of eachtabpanel are displayed. GUI elements whose parent is handles.tabframe, need to have their UserData

field set to the value that is returned by the PanelName subfunction. This must be done so that BLIMToolbox can keep track of the GUI elements that need to be shown for the selected tabpanel. Other GUIelements that do not have the Parent field set to handles.tabframe should leave the UserData fieldempty.

Now you can already see why the handles argument is present in almost every function; it containsall handles to the GUI elements. Apart from the handles to the GUI elements, the handles structurecontains every variable that you can refer to in BLIM Toolbox. In Sect. 5.3 using variables in BLIMToolbox will be discussed in more detail. For now it is only important to know that each function thatneeds a variable or refers to GUI elements, can do so through the handles structure.

For some GUI elements, you want to specify what happens when you or some other user interactswith it. Some examples are: check boxes, editable text fields, list boxes, dropdown menus, push but-tons, radio buttons, sliders and toggle buttons. In Matlab, the Callback field of a GUI element con-

28

Page 31: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

tains the code that will be executed when that element is clicked. Callback functions should preferablybe subfunctions of the tabpanel file you are working with. The handles structure, which is often in-put argument to such a function, can be obtained with guidata(gcbo). While this might seem a bitcomplicated, it is the default way of handling GUI elements in Matlab. Other input arguments tothe callback function should be the handle to the object that called it, referred to as gcbo, and anargument called eventdata, which is reserved for future use. This also is standard practice in Mat-lab. As an example, the cbmycheckbox checkbox in the mypanel tabpanel, has as callback function:mypanel('cbmycheckbox_Callback',gcbo,[],guidata(gcbo)). That means that when this checkboxis clicked, the subfunction cbmycheckbox_Callback in the mypanel.m file is called with input argu-ments gcbo, [], and guidata(gcbo). Here, gcbo is the handle to the checkbox, and guidata(gcbo)

the handles structure. The cbmycheckbox_Callback subfunction then assigns the value of the checkboxto the handles.mypanel.mycheckboxvalue variable, which can later be used by other functions (e.g. theCloseRequestFcn saves this variable to a settings file).

Another GUI element that is important, is the tab button for the tabpanel itself. The mypanel tabpanelcontains an example of this button (the last element in the LayoutFcn subfunction). You don’t need tochange this code, except maybe the position. If you add several copies of the mypanel tabpanel to BLIMToolbox you manually need to adjust the position of the tab button. Otherwise it will be plotted on topof other tab buttons, and you might get the idea that your tabpanel is not loaded at all!

Apart from the fields discussed before, you might want to set the values of other fields of GUI elements.There are many fields that can be set, whose functions are explained in Matlab’s uicontrol help page.However, most of the fields are fine at their default values. Some examples of setting fields to non-defaultvalues are given in the mypanel tabpanel. An easy way to get the (pixel) positions for a certain layoutof GUI elements is to align them in a panel in Matlab’s guide function, export from there, and copy thePosition fields in the tabpanel file.

function handles = OpeningFcn(hObject, eventdata, handles)

The OpeningFcn is called after the GUI elements are loaded into the BLIM Toolbox main window, but be-fore they are made visible. This subfunction can be used to load settings from settings files, and set the GUIelements accordingly. For example, the OpeningFcn of the mypanel tabpanel loads the mycheckboxvalue

variable, and sets its value to the cbmycheckbox GUI element.

function handles = CloseRequestFcn(hObject, eventdata, handles)

When the BLIM Toolbox closes, because the user pressed the window [close] ([x]) button, or the operatingsystem’s [close] keyboard shortcut, CloseRequestFcn is called before any GUI element is deleted. Youcan use this subfunction to save any unsaved variables, or any other important action that needs to be per-formed before the BLIM Toolbox is actually closed. For example, the CloseRequestFcn of the mypanel

tabpanel saves the value of the mycheckboxvalue. Together with the loading of this variable in theOpeningFcn, and the synchronization with the checkbox in the GUI in the cbmycheckbox_Callback sub-function, this makes the value of the cbmycheckbox persistent between different sessions of BLIM Toolbox!

function handles = onImageLoad(hObject, eventdata, handles)

This subfunction is called when the user navigates to an(other) image. First, the image is loaded, then theonImageLoad subfunction of each panel is called, and after that the actual image is plotted. You can usethis subfunction to perform certain operations on the image, change GUI elements that represent certainimage features, or to add lines that will be plotted on top of the image. The latter option is explained inmore detail in Sect. 5.4. Note that this subfunction is also called when multiple or no images are selected,so you might need to check whether an image was actually loaded with:

if isempty(handles.image.cdata)

% actions to perform when no image is loaded

else

% actions to perform when an image is loaded

end

29

Page 32: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

In case no image is loaded, you might want to reset certain GUI elements instead.

function handles = onTabSelected(hObject, eventdata, handles)

When the user selects another tabpanel, this subfunction is called. Note that this does not only happenwhen the current tabpanel is selected, but every time a tabpanel is selected. You might want to performcertain actions when your tabpanel is selected, and other actions when the tabpanel is deselected. Forexample, you might have added certain lines to the image which should not be shown in other tabpanels.Use the onTabSelected subfunction to remove those lines when your tabpanel is deselected. The mypaneltabpanel contains an example on how to achieve this:

if strcmpi(handles.iosettings.selectedtab, PanelName)

% specify actions that are performed when this tabpanel is selected

else

% specify actions that are performed when another tabpanel is selected

end

function handles = onInputLocationSelected(hObject, eventdata, handles)

The input location is the location from which a list of entries is loaded. When this list changes, you mightwant to perform certain actions. If you do not want to do so, just leave this subfunction empty.

function handles = WindowButtonMotionFcn(hObject, eventdata, handles)

While this subfunction name might come somewhat as a surprise, it actually is called every time the usermoves his or her mouse pointer over the BLIM Toolbox window. You might already have found out aboutthis subfunction when you changed the mypanel template, made a syntax error, and Matlab produced allthose red error lines every time you moved your mouse. When you do it right, you can use this subfunc-tion to handle moving elements, or to update the GUI when the user moves the mouse pointer over theimage. The vertical ROI lines and the intensity meter in the [BLIM] tabpanel are examples of this. If youspecify code in this subfunction, make sure it runs fast, because if this subfunction takes too much timeto complete, Matlab might give up.

function handles = WindowButtonUpFcn(hObject, eventdata, handles)

The WindowButtonUpFcn is called, as you might have expected, when the mouse button is released. Thissubfunction is not meant to check whether a button, checkbox or other GUI element was pressed, becauseGUI elements have their own callback functions. It can however be used to perform certain actions whenthe user clicks in the image.

function handles = ResizeFcn(hObject, eventdata, handles)

Resizing the window, as well as selecting a tabpanel will cause this subfunction to be called. You mightuse it to reposition or resize certain GUI elements, but usually, this is not necessary.

function handles = onSharedSettingsChanged(hObject, eventdata, handles)

As discussed in Sect. 5.3 there are certain variables that are shared among all tabpanels. This subfunction iscalled when one of the shared variables changes. You might want to use this subfunction to update GUI el-ements that handle these shared settings when they are changed by another tabpanel. When your tabpanelchanges one of the shared settings, make sure to call handles = blimtool('sharedSettingsChanged',

hObject, eventdata, handles) afterwards, which will cause the onSharedSettingsChanged subfunc-tion of all tabpanels to be executed (including the currently selected tabpanel!). To prevent endless loops,never call sharedSettingsChanged from within onSharedSettingsChanged or any subfunction that iscalled from within onSharedSettingsChanged!

function handles = onBlimLocationChanged(hObject, eventdata, handles)

While the blimline location is also a shared setting, it has its own handler function. Changing the blimline

30

Page 33: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

location might not happen so often, and might have other effects than changing one of the other sharedsettings. In this subfunction you can specify what happens when the blimline location is changed by theuser. Also, make sure that if your tabpanel changes the blimline location, the handles = blimtool('blim

LocationChanged', hObject, eventdata, handles) is called afterwards. This will call the onBlim

LocationChanged of all tabpanels (including the currently selected tabpanel!).

function handles = onEntryChanged(hObject, eventdata, handles)

If your tabpanel changes one or more blimlines and saves it or them to the blimline location, you mightwant to notify the other tabpanels that you have done so. Enter the following line after you have madethe changes: handles = entryChanged(hObject, eventdata, handles, ientries), and the onEntry

Changed subfunction of each tabpanel will be executed. The variable ientries must contain the indexor indices of the entry or entries that were changed. This subfunction can then take the necessary actionsto update the changed blimline, or in the case of mypanel just do nothing.

function handles = onKeyPress(hObject, eventdata, handles)

This subfunction is called when a key on the keyboard is pressed. You can implement your own ac-tions, such as keyboard shortcuts here. A inherent limitation of Matlab GUIs is that they will not call theonKeyPress subfunctions when no GUI element is selected. Also, the onKeyPress subfunctions will not becalled when a text field, drop-down menu or listbox is selected, because these elements deal with keyboardinput themselves. So if during testing your onKeyPress subfunction is not called, you now have someidea why. Note that the onKeyPress subfunction of all tabpanels is called when a key is pressed, so youmight want to check whether your panel is currently selected, just as in the onTabSelected function above.

5.2.2 Toolbox functions

Apart from the subfunctions that are called by BLIM Toolbox and must be implemented by your tab-panel, there are also subfunctions of the BLIM Toolbox GUI that you might want to call from inside yourtabpanel. Calling subfunction of the BLIM Toolbox works in the same fashion as calling subfunctions intabpanels. The name of the BLIM Toolbox main file is blimtool.m, so the syntax for calling subfunctionsinside blimtool is: [out1, out2, ...] = blimtool('subfunctionname', arg1, arg2, ...). Thereare a number of functions that you might want to use, some of which were already mentioned before:

function handles = blimtool('sharedSettingsChanged', hObject, eventdata, handles)

This subfunction needs to be called each time you change one of the shared settings, except for the blimlinelocation, which has its own subfunction. sharedSettingsChanged calls the onSharedSettingsChanged

of each tabpanel, including the one that initiated the call.

function handles = blimtool('blimLocationChanged', hObject, eventdata, handles)

The blimLocationChanged subfunction needs to be called each time you change the blimline location.blimLocationChanged calls the onBlimLocationChanged of each tabpanel, including the one that initi-ated the call.

function handles = entryChanged(hObject, eventdata, handles, ientry)

Each time one or more blimline files are changed, the entryChanged subfunction must be called. Thevariable ientries should contain the index or indices of the entry or entries that were changed. Formore information about these indices, see Sect. 5.3. entryChanged will call the onEntryChanged of eachtabpanel, including the one that initiated the call.

function handles = navigate(hObject, eventdata, handles, selected)

The navigate subfunction is used to navigate to another entry, select multiple or no entries, or reload thecurrent entry. The variable selected is the index or list of indices of the entry or entries that are to beselected in the navigation list. In case of a single number (index) the corresponding image is loaded and

31

Page 34: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

shown in the image panel. The navigate subfunction will check whether the selected indices fall in thelist of loaded files, so you don’t have to do this yourself. Note that navigate calls the onImageLoad of alltabpanels, so be sure not to call navigate in the onImageLoad subfunction or any function that is calledby the onImageLoad subfunction.

function handles = showImage(hObject, eventdata, handles)

This subfunction can be called after changing image properties of the loaded image, or after adding orchanging lines that are plotted on top of the image in the image preview panel. Note that showImage isalready called by BLIM Toolbox after navigating to an image, selecting a tabpanel, or changing the inputlocation, so you don’t have to call it explicitly in the onImageLoad, onTabSelected, or onInputLocationSelected subfunctions.

5.3 Variables

As you might have noticed in the previous sections, most subfunctions have three input arguments and oneoutput argument. Because BLIM Toolbox consists of a GUI from which several functions and subfunctionsare called, it needs a way to store the variables that can be used by the different subfunctions that arespread out over several files. For BLIM Toolbox the convention of Matlab’s GUI builder guide is used.In this convention, the first argument of a function that is called when a GUI element is activated, is thehandle to the GUI element that initiated the call, indicated by the name hObject. The second element,eventdata is implemented, but reserved for future use. The third argument is the handles structure,which contains all the variables that are used in the BLIM Toolbox, and is the GUI equivalent of theMatlab workspace. It is the most important variable in the GUI, and needs to be handled with care.The handles structure is saved ‘inside’ the GUI, and can be accessed by the command guidata(gcbo).By default, callback functions of GUI elements use this command as the third input argument of thefunction they call. If you specify your own callback function, you might want to adhere to this standardas well. When the handles structure is passed on to a function, that function can perform certain actionsand computation on the fields of that structure. However, when the values of the handles structureare changed, it needs to be saved back to the GUI again. The command that performs this action is:guidata(hObject, handles), where hObject is the handle of a GUI object. It is therefore important topass on the handles structure from function to function and from subfunction to subfunction, and whenthe actions following a GUI interaction are completed, the changed handles structure should be savedback to the GUI. Here is an example of this cycle:

The user clicks a checkbox in [MyPanel] whose callback is mypanel('cbmycheckbox_Callback',gcbo,[],guidata(gcbo)). Here gcbo is the handle to the checkbox, and guidata(gcbo) fetches the handles vari-able. The subfunction cbmycheckbox_Callback uses the handles variable as its third input argumentand changes one of the fields on the handles structure. Because of this change, the handles structureneeds to be saved back again, by calling guidata(hObject, handles) at the end of that subfunction.

In case cbmycheckbox_Callback makes a call to another function or subfunction that could also makechanges to the handles structure, for example, the sharedSettingsChanged subfunction of blimtool,then the changed handles structure needs to be returned to cbmycheckbox_Callback. The code for such acall would then have as output argument the handles variable: handles = blimtool('sharedSettings

Changed', hObject, eventdata, handles). Subfunction sharedSettingsChanged does however nothave to call guidata(hObject, handles) by itself, because it returns the handles structure to the callingfunction. Actually, most functions have handles as their output argument, because they make changes tothe handles structure, or call other functions that might makes changes to the handles structure. Whenthe changes handles structure is finally returned to the original callback function and no other tasks haveto be performed, the guidata(hObject, handles) can be called and the callback function is done.

As was already mentioned in Sect. 5.2.1, the handles structure contains as its fields the handles tothe GUI elements with fieldnames specified by their Tag values. For example, a handle to the checkbox in

32

Page 35: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

[MyPanel] is stored in handles.cbmycheckbox, because on creation its Tag was set to 'cbmycheckbox'.There are however other fields stored in the handles structure that you might find interesting. First, thesettings per tabpanel are stored in fields of the handles.panelnamesettings field, where panelname isthe name of the tabpanel. This settings field is itself a structure. For example, the value of the checkbox in[MyPanel] is stored in the handles.mypanelsettings.mycheckboxvalue field. While this might seem along name for a variable, it is quite similar to storing variables in the workspace instead of the in handles

structure (although you have to make sure that the handles variable is passed on from one function tothe next, and back). Grouping the variables per tabpanel helps keeping things ordered.

Apart from the settings per tabpanel, the handles structure also contains some fields that are main-tained by the BLIM Toolbox itself, such as the loaded image filename, the image data or the input location.These fields can be used by your tabpanel, but you should normally not attempt to change these variablesdirectly, because it might screw up things for other tabpanels. If you need to change any of those vari-ables, use the subfunctions specified in Sect. 5.2.2, and if you want to add lines to the displayed image,see Sect. 5.4. Here is an overview of the most important fields in the handles structure:

handles.image

This structure contains the image that is loaded in case a single entry is selected in the navigation list.The fields in this structure are: cdata (3-d matrix with color values for each pixel), height (height ofthe image), width (height of the image), title (the title displayed in the image panel), cspace (the colorspace) and ctype (the type of color (e.g. gray or rgb)). To check whether an image is loaded, use:

if ˜isempty(handles.image.cdata)

% actions perform when an image is loaded

end

One more thing; don’t use size(handles.image.cdata) to find the width and height of the loaded im-age, but use handles.image.width and handles.image.height instead. This is at least an initial stepto speed up your code.

handles.iosettings

The fields in this structure contain information about the list of files that is loaded and the index orindices of this list that are selected in the navigation panel. Images can be loaded from different sources:a file, a directory, or a database. The selectedsource field determines which of the three is selected.The location field is the directory of the files of which the relative names are given in the entrylist

field, or the link to the database in case a database connection is selected. The functions that perform theinput and output for BLIM Toolbox can handle both types of input locations (file system and database),and can take the location field as input argument. The index or indices of the selected files in theentrylist field are stored in the ientries field. The name of the tabpanel that is selected is containedin the selectedtab field. Here is an example of how to use those fields:

% if this tab is selected

if strcmpi(handles.iosettings.selectedtab, PanelName)

% the indices of the selected entries in the navigation list

ientries = handles.iosettings.ientries;

switch numel(ientries)

case 0

disp('No entries selected');

case 1

if ˜isempty(handles.image.cdata)

filename = handles.iosettings.entrylist{handles.iosettings.ientries};

disp(['Selected file number: ' num2str(ientries) ' name: ' filename])

33

Page 36: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

else

disp('The selected file contains no image data Matlab can load')

end

otherwise

disp(['Multiple selection on indices: ' num2str(ientries)]);

end

end

Tabpanels need to keep track of their own variables as well. In Sect. 5.2.1 you have seen a simpleexample of how the value of a checkbox can easily be stored, even between different sessions of BLIMToolbox. There are three functions that can help you keep track of all the variables in your tabpanel or loadand store those variables: loadsettings, savesettings and getPanelnameFields, where Panelname isthe name of the tabpanel. The settings fieldnames, default values and filename can be retrieved with thegetMyPanelFields subfunction. The fieldnames are the names of the fields that you want to use, and youcan also specify default values for those fields. The fields will be stored in a field of the handles structureas subfields. For example, the mycheckboxvalue fieldname in mypanel defaults to true and will be loadedinto handles.mypanelsettings.mycheckboxvalue. The file from which the settings for your tabpanelare loaded and in which they are stored can also be specified. This file will be stored in the tabpanels

directory of the BLIM Toolbox installation path. If the file cannot be found, the defaults will be usedinstead.

Loading the settings into the handles variable can best be performed in the OpeningFcn subfunction.Also, this subfunction can update the GUI with the loaded settings. To maintain settings between BLIMToolbox sessions, you have to synchronize any changes in the GUI with the settings in the handles

structure (e.g. as is done in cbmycheckbox), so that when the GUI closes, the CloseRequestFcn can callthe savesettings function to save any changes to the settings file. For an example, see the mypanel

tabpanel.Apart from the settings for your tabpanel, there also is a structure called handles.sharedsettings,

which contains the values that are shared among different tabpanels. If you want to use these values,you can load them in the same fashion as you load other settings. Examples of tabpanels that load (andsave!) the shared settings are viewpanel and blimpanel. Because any changes that you make to theshared settings (e.g. disabling the display of blimlines) can affect other tabpanels, you will have to notifyBLIM Toolbox that you changed them. The subfunctions that need to be called are located in blimtool:sharedSettingsChanged and blimLocationChanged. Also the subfunctions that are called when anothertabpanel changes a shared setting need to be implemented in each tabpanel: onSharedSettingsChangedand blimLocationChanged. See Sect. 5.2.1 and 5.2.2 on how to use these.

5.4 Lines in images

One thing you might want to do in a tabpanel is plotting lines into the image in the preview panel.Unfortunately, the image is mostly handled by the blimtool function, and when you add your own stuff,you will mess things up. Instead, BLIM Toolbox allows you to plot lines in the image by adding themto the handles.lines structure, and calling the showImage subfunction afterwards. To add a line to theimage, add a Matlab struct with the following fields to the handles.lines structure:

line: a two-dimensional array, in which the first row indicates the horizontal positions of the line,and the second row the vertical positions

color: a Matlab color specification

style: a Matlab line style specification

order: order in which the line should be drawn; lines with the lowest number are drawn the last(and shown on top)

34

Page 37: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

handle: the handle to the line will be set when showImage is called; this handle can be used if someproperty of the line should be changed later

fcn: function that is called when the line is clicked

After adding a line you might want to invoke the showImage fuction of blimtool to display all linesin the handles.lines structure. If you add lines to the handles.lines structure in the onImageLoad

subfunction or a function that is called by it, calling showImage is not needed, because this is alreadydone by the blimtool function. Remember, showImage is a subfunction of the blimtool.m file, so callingit from inside a tabpanel goes with: handles = blimtool('showImage',hObject,eventdata,handles).Here is an example of how to add a line to the image, and make it visible:

handles.lines.myline.line = [1:100; sin(1:100)];

handles.lines.myline.color = 'y';

handles.lines.myline.style = '*';

handles.lines.myline.order = 1;

handles.lines.myline.handle = 0;

handles.lines.myline.fcn = 'mypanel(''myline_ButtonDownFcn'',gcbo,[],guidata(gcbo))';

handles = blimtool('showImage', hObject, handles);

Please keep in mind that adding lines is not the only thing there is to lines, they always have to be deletedat some point, and you have to specify the code for deletion yourself! Deleting lines goes as follows:

if isfield(handles.lines, 'myline')

handles.lines = rmfield(handles.lines, 'myline');

end

After that you can call the showImage subfunction again to update the GUI with the absence of myline.One place where you need to implement the deletion of the lines that you added is in the onTabSelected

subfunction, because the lines you added probably need to be deleted when another tabpanel is selected.For the onTabSelected subfunction, you might want to use:

if ˜strcmpi(handles.iosettings.selectedtab, PanelName)

if isfield(handles.lines, 'myline')

handles.lines = rmfield(handles.lines, 'myline');

end

end

to delete the lines when the tabpanel is deselected. Note that in the onTabSelected subfunction showImage

does not need to be called, because BLIM Toolbox already does that for you.

35

Page 38: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

36

Page 39: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

6. Toolbox functions

There are a number of functions that facilitate the input and output between the BLIM Toolbox and otherenvironments, such as the Argus Runtime Environment, image formats, the file system, or a database.These functions can be found in the argusio directory of the BLIM Toolbox installation path. InSect. 4.7.3 a detailed description of the input and output functions for images and blimlines is given.Here, the syntax of those and other functions is given, together with some examples on how to use them.

function varargout = listfiles(varargin)

This function returns a list of files in a directory or file and offers additional functionalities to the stan-dard Matlab dir and ls commands. listfiles takes as input argument the full path to a filename, or adirectory. It is assumed that in case of a filename, the file contains a list of filenames in a one entry perline format. Output arguments are the directory and a list of files relative to that directory (two outputarguments), or a list of full paths to each file (one output argument). listfiles can take wildcards asinput arguments, e.g. listfiles('C:/Matlab/*.m'), or listfiles('*.m'). In case no input argumentis given, the function lists the files in the Matlab working directory. Files in subdirectories are not in-cluded. Additionally, files are sorted by filename. In case the filename starts with a number, the files aresorted by the entire sequence of numbers, not just the first digit (as is done in the Matlab’s standard dir

command). Examples:

listfiles('C:/Matlab/*.m')

[names path] = listfiles('C:/Matlab/list.txt');

function entry = getentryname(location, imgentry, extension)

getentryname returns the entry name or names for a given location and extension. You can use thisfunction to obtain the filename of a blimline file or blimline database entry, given the image filename(imgentry) from which it was derived, the blimline file extension (extension), and the location of theblimline files (location). entry can be a cell of entry names, in which case the entry names of allthe filenames in the list are returned for the corresponding location and extension. You should use thisfunction preferably for finding the blimline file corresponding to an image file, because the right entryname is returned independent of the storage type (database or file system).

The blimline location can be a directory or a database object. In case the location is a directory,getentryname replaces the extension of imgentry with extension. For databases, everything is referredto by the name of the image file, so the extension is not replaced. The extension of a filename is defined asthe part of the filename after the last occurrence of a dot ('.'). For example, if location is a directory,imgentry is C:/Temp/querty.as.df.jpg and extension is .bar, then the extension of the image filenamejpg will be replaced with bar. The output of the function will then be C:/Temp/querty.as.df.bar. Incase the location is a directory and the filename has no extension yet, getentryname adds the extension.The function also eliminates double dots that might result from the process of changing or adding theextension.

function [message blimlines blimsettings] = loadblimline(location, entry, selectedlines)

Loads blimlines and the settings that were used to produce the blimlines from the selected location and

37

Page 40: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

entry. location can be a directory or a database. For full details, enter help loadblimline in theMatlab prompt.

function message = saveblimline(location, entry, linenumber, blimline, blimsettings)

Saves a blimlines and the settings that were used to produce the blimlines to the selected location andentry. location can be a directory or a database. For full details, enter help saveblimline in theMatlab prompt.

Here is an example of how you can use these functions to loop through a number of blimlines in severalblimline files. This might be especially useful if you want to perform a more detailed analysis than BLIMToolbox can offer, or if you want to load blimlines for further processing, for example in a modeling effort.

Example:imgdir = 'D:/Argus/merged/station'; % specify the image input directory

blimdir = 'D:/Argus/blimresults/station'; % specify the blimline input directory

blimext = '.bar'; % the blimline filenames extension

nblimlines = 10; % the default number of blimlines in each file

selectedline = 4; % the number of the blimline that is loaded

% load all jpg files in this directory

[imgfilenames imgdir] = listfiles(fullfile(imgdir, '*.jpg'));

% alternatively, you can specify an input filename:

[imgfilenames imgdir] = listfiles(fullfile(imgdir, 'myselection.txt'));

for ifile = 1:size(imgfilenames, 2) % process each file in the list

imgfilename = imgfilenames{ifile};

blimfilename = getentryname(blimdir, imgfilename, blimext); % get the blimline filename

% load all lines in the blimline file

[message blimlines blimsettings] = loadblimline(blimdir, blimfilename, (1:nblimlines));

% process each blimline

for iblimline = 1:nblimlines

thisblimline = blimlines{iblimline};

thisblimsettings = blimsettings{iblimline};

if ˜isempty(thisblimline) % if this blimline exists

% perform your actions here, e.g.:

blimx = thisblimline(1,:); % horizontal coordinates (pixels!)

blimy = thisblimline(2,:); % vertical coordinates (pixels!)

weightedavg = thisblimsettings.weightedavg;

end

end

% alternatively, if you know which line number you want, you can use:

[message blimlines blimsettings] = loadblimline(blimdir, blimfilename, selectedline);

if ˜isempty(blimlines{selectedline}) % if this blimline is not empty

% perform your actions here, e.g:

38

Page 41: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

blimx = blimlines{selectedline}(1,:); % horizontal coordinates (pixels!)

blimy = blimlines{selectedline}(2,:); % vertical coordinates (pixels!)

weightedavg = blimsettings{selectedline}.weightedavg;

end

end

39

Page 42: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

40

Page 43: BLIM Toolbox Manual - SUPSIpeople.idsia.ch/~pape/papers/pape2008blimtool.pdf1.1 Structure of this manual This document consists of a manual describing all the features of the BLIM

Bibliography

Holland, K. T., Holman, R. A., Lippmann, T. C., Stanley, J., and Plant, N. G. (1997). Practical use ofvideo imagery in nearshore oceanographic field studies. Journal of Oceanic Engineering, 22:81–92.

Holman, R. A. and Stanley, J. (2007). The history and technical capabilities of argus. Coastal Engineering,54:477–491.

Lippmann, T. C. and Holman, R. A. (1989). Quantification of sand bar morphology: a video techniquebased on wave dissipation. Journal of Geophysical Research, 94:995–1011.

van Enckevort, I. M. J. and Ruessink, B. G. (2001). Effects of hydrodynamics and bathymetry on videoestimates of nearshore sandbar position. Journal of Geophysical Research, 106:16969–16979.

41