Introduction to MycoCam5

MycoCam5 is the fifth generation of Richard Shotbolt's program for capturing and processing pictures from webcams or other video capture devices and allowing measurements to be taken directly from them. MycoCam 5 is completely free!

MycoCam is intended primarily for use in conjunction with a microscope, enabling large numbers of formerly tedious measurements can be made very quickly. The program works perfectly with the DCM range of microscope cameras sold by Brunel. The EyeCam, Apex Minigrab, Celestron micro imager and other generic 2MP scopecams work well too. Cameras must support Video for Windows (VfW) to work with MycoCam.

Models which use proprietary drivers and software will generally not work unless they are stated to work with VfW.

You can also make measurements and perform image-processing on image files loaded from digital cameras without webcam capability, or indeed from any source; the maximum image size is limited only by the available memory. The Image Gallery allows you to select files from a specified folder including your still camera's memory card. Files are automatically copied and resized before any modifications.

Changes from MycoCam 4

  • A measuring line is now available in addition to the measuring circle.
  • Choice of color scheme for the measuring line/circle and annotations.
  • Auto Add Annotation added to Options. Freezes the measuring circle/line when L(ength) and W(idth) are clicked.
  • The Image Gallery feature has been fully integrated with the measurement process, allowing easy measurement of folders of still images.
  • A Statistics tab shows full details of spore measurements and comparisons, plus a graph plot of length and width.
  • An Extras tab allows you to run external programs with data from MycoCam.

System Requirements

  • Fast multimedia-capable PC. MycoCam is computationally intensive, especially when real-time image-processing is enabled.
  • At least 2GB of RAM for image-stacking (preferably 4GB +).
  • WindowsTM XP or later.
  • Minimum 800 x 600 display using 24bit or 32bit True Color mode.

Running MycoCam 5

Plug in your camera or other capture device then run MycoCam5. The controls are on the left of the window; you can change this if desired by choosing Options, Align Controls Right.

You will notice that there is a series of tabbed pages which you can select:

  • Preview - choose a video device, set up its operating modes and view full-speed live video.
  • Process - process the live pictures from the camera and adjust them prior to image capture.
  • Stack - review a stack of images and perform focus-stacking.
  • Measure - view the captured image, and measure and annotate objects.
  • Compare - view a comparison image and associated measurements.
  • Statistics - view all the measurement and comparison data in tables and on a graph plot.
  • Gallery - provide thumbnails of all images in a folder and optionally transfer to measurement.

Many of MycoCam's options and features are accessible through popup menus activated by a right-click. Experiment with right-clicking the images, measurement grids and other controls to familiarize yourself with what can be done.

The Preview Page

The Preview Page is where you choose a video device, set it up and view the full-speed live video.

The Cameras and Modes treeview control shows all the connected video devices; clicking the '+' box shows the different modes available for that device. Click a mode to select it, and a live image will appear. The current camera and mode will be shown in the top status bar.

Set up your camera
Depending on the features supported by the video device, various buttons below the treeview will be enabled. The Camera Settings button, if enabled, allows various manufacturer-determined options to be set up for your camera. These include options such as brightness, white balance, sharpness etc.

The camera mode is automatically saved on exit, and will be recalled the next time MycoCam is started.

If your camera does not have a live video mode, you will not be able to use the functions on the Preview and Process pages, but you will be able to make measurements on images from a folder or the camera's memory card via the Gallery [new in version 5].

Focus the picture
Observe the live image while very carefully adjusting the focus for best clarity. In Preview mode, MycoCam will display frames as fast as the video device can deliver them.

The Process Page

The Process page includes many features to enhance your pictures. It can only be used on live video.

Image Size
Enter the size that you want the image to be displayed at. When a width is entered, the height is automatically set to 0.75 times the width. You can change the height afterwards if you want. The maximum size of the processed image is 2592 x 1944 pixels (5MB), and the minimum is 160 x 120. For most purposes a size of 800 x 600 will suffice, and larger sizes will noticeably slow the performance.

Picture Processing
MycoCam processes video images in real time. This is computationally very intensive and with large images and/or a slower PC it may appear sluggish. The following effects are provided:

Picture Orientation
Use the FlipX checkbox to flip the picture left-right, and FlipY to flip it up-down. This is very useful if you want to work from the other side of your microscope.

Despeckle
Click the Despeckle check box to apply a Median Cut filter to remove most of the speckles. This will blur the image slightly.

Sharpen
Click the Sharpen check box to sharpen the image. This can be used in conjunction with Despeckle.

Find Edges
Click the Find Edges check box to show where the sharp edges are in the picture.

Negative
Click the Negative check box to show the image as a negative.
This can sometimes appear to improve clarity.

Radial Distortion

The Radial Distortion slider compensates for barrel or pincushion in the lenses, and for perspective. Adjust this to make straight lines near the edges of your image look straight.

Color, Brightness and Contrast
These sliders allow you to adjust the color balance of the picture, and to set its overall brightness and contrast. You can achieve a warmer 'tungsten lamp' effect by moving the red and green sliders up together to increase the yellowness; conversely you can increase the blue slider for a 'daylight' color balance.

Reset All
Click the Reset All button to restore all image-processing defaults.

Flat-Field Correction
MycoCam uses an advanced technique called flat-fielding to remove the effects of dust on lenses, imperfections in camera electronics, uneven lighting etc. A grossly-defocused picture is taken and processed to result in a uniform user-defined color in the final image.

Click anywhere in the preview image and you will notice that the box to the right of the Flat Field Color button changes to the color of the point that you clicked. For the most effective flat-fielding, click on a point that is most representative of the background color of the preview image. Click the Flat Field Color button. After a short pause the preview image should show a uniform shade of color. The corrections are stored and applied to all subsequent images. You can add or remove the flat-field correction by checking or unchecking the Apply Flat Field box.

Image Averaging [new in version 5]
By averaging several frames you can reduce the amount of noise and achieve a clearer image. Enter the number of frames to average. This will not work if the objects you are interested in are moving.

Clear Stack
Deletes all the images from the designated FocusStack folder.

Add to Stack
Adds the current image to the designated FocusStack folder as StackXXXX.jpg, with 100% quality. The image number is auto-incremented.

Pressing the space bar while on the Process page also adds the image to the stack.

Grab Image
When you are happy with the picture as displayed in the Process page, click Image -> Measure and you will be taken to the Measure page where the captured image awaits your measurements.

As a shortcut, you can grab an image by pressing Enter, or from a right-click option on the image.

Focus Stacking

This is a technique for greatly improving depth of field by taking a series of snapshots, moving the focus knob very slightly between frames. MycoCam allows you to take a series of pictures which are added to the designated FocusStack folder as Stack0001.jpg, Stack0002.jpg etc. at 100% quality. This folder is by default in \MycoCam\Images\FocusStack, but you can change this with the Options, Paths menu.

Snapshots are taken using the Add to Stack button on the Process page, or by pressing the Space Bar when on the Process page. The current stack can be deleted with the Clear Stack button.

You can review the stack of images by clicking on the files in the list. You can also select and deselect them individually via their checkboxes, and delete unchecked files permanently.

Once a set of images is captured, you can either use one of the several free focus-stacking programs to process them, or you can use the very simple built-in functions accessed from the Focus Stack tab. MycoCam extracts from each image the area of greatest change, which represents the part in best focus. No image alignment or other sophisticated algorithms are used, so the built-in option is most suitable for single small features which do not move between frames.

Sample Matrix
MycoCam can either use the changes around a single pixel (Nearest Neighbor) or in a block of 9 pixels (3x3). Use trial and error to see which gives the best result for any given set of frames.

Despeckle Frames
Noise spots, bad camera pixels etc. are removed using a 3x3 median filter prior to processing the frames, with the disadvantage of blurring the image slightly.

Gaussian Smooth
A theoretically ideal smoothing filter to remove artifacts of the frame selection process.

Gaussian Sharpen
A theoretically ideal sharpening filter to remove some of the blurring caused by despeckling and smoothing, although it cannot recover all the fine detail.

Perform Focus Stacking
Click to begin processing. The processed image will appear at the end.

Transfer to Measure
Click to transfer the stacked image to the Measure page ready for measurements to be made.

Making Measurements

The Measure page provides tools for taking accurate measurements from the captured image and analyzing the results. Many of the features are accessed from a popup menu launched by right-clicking the picture.

Measuring with MycoCam
Left-click any point within the Measure image. Notice that an annotation in the form of a number appears immediately to the left of the pointer. Repeat, this time holding the left mouse button down while dragging the mouse. A circle will appear. One point of the circle (the first point you clicked) remains fixed while the other follows the mouse pointer. When you are taking measurements for real, these two points represent the extents (length, width or depth) of the object you are measuring.

Release the left mouse button. Notice that the circle size now remains fixed, while the center of the circle moves with the mouse pointer. You can now change the size of the circle with the mouse wheel or cursor keys.

Change the measuring circle to a line [new in version 5]
Right-click the picture and select Toggle Annotation Circle/Line [A]. The circle will change to a line. Repeat to return to a circle. Press A for a shortcut.

Change the measuring circle/line color [more options in version 5]

Right-click the picture and select Toggle Measuring Circle/Line Color [C]. The circle outline will toggle between a range of color combinations. Press C for a shortcut.

The measuring line/circle choice and color scheme are saved when you exit MycoCam.

Calibrate the measuring circle/line
Before taking measurements, it is necessary to calibrate the measuring circle/line. Go back to the Process page and capture a clear image of a measuring slide ("stage micrometer"), ruler or other object of known size. Left-click the object on the Measure page and drag the circle/line until it represents the dimension you want to use for calibration. Now right-click and choose Set Circle/Line Size [S] from the popup menu. Enter the actual dimensions of the object when prompted then click OK.

You will now be prompted to save the scale factor in a lens file. [new in version 5] If you want to do this, choose a short filename which describes the lens and the current image size, e.g. "x40 800x600". If you cancel, you can continue to make measurements with the new scale but only for the duration of your MycoCam session.

The circle/line can now be used for accurate measurements. Experiment with clicking, dragging and resizing it until you are familiar with the measurement process.

Save calibration to a lens file [legacy]
To avoid having to repeatedly set the scale factor, you can save the calibration to disk. In the main menu, choose Calibrate, Save Lens File. Enter a brief description of the lens e.g. "x40 800x600" then click OK. You will then be prompted for a filename, with the description as the default. Click OK to accept, and the scale factor and picture size will be saved.

Load calibration from a lens file [legacy]
To use the predetermined calibration settings for a particular lens, choose Calibrate, Load Lens File from the main menu. Select the correct calibration file then click OK to accept. The scale factor and picture size will be loaded.

Load lens file from drop-down menu [new in version 5]

Choose the lens and image size from the Lens File dropdown box below the table on the Measure page.

Accurately measure objects
Go to the Process page and take a good picture. On the Measure page, right-click the picture and choose New Measurement [N] from the popup menu. Select an object and use the left-click and drag to measure the longest dimension of the object. Use the mouse wheel or cursor keys to adjust the circle/line size if necessary.

To log the length in the measurement table, right-click the picture and select Update Length [L]. Now measure the width of the object and log it by selecting Update Width [W]. If the nature of the objects allows you to determine the depth as well, select Update Depth [D].

You will probably find that the keyboard shortcuts N, L, W, D are much more convenient.

Note: If the width is greater than the length, the two measurements will be automatically transposed by default. You can turn off this feature by unchecking the menu item Options, Auto Swap if W > L. Spore length is taken as the dimension through the apiculus, and rarely some spores may be wider than long!

  • To measure another object, right-click the picture and choose New Measurement [N].
  • To delete the current measurement, right-click the grid and choose Delete Measurement [Del].
  • You can also delete a specified measurement from the table by clicking its row first before right-clicking the grid and selecting Delete Measurement.
  • To undo the last change to the measurement table, right-click the grid and select Undo Measurement Change [U].

If the menu item Options, Auto New After Width is checked, MycoCam will automatically start a new measurement after the width has been entered.

Measure objects larger than the circle/line will allow, or replace a previous measurement with a new one
Measure part of the dimension in question, log the measurement and note where the circle finishes. Start a new circle and extend the measurement. Now log the measurement again without choosing New Measurement. MycoCam will give you three options:

  • Click Yes to add the new measurement to the previous one.
  • Click No to replace the old measurement with the new one.
  • Click Cancel to ignore the new measurement (useful if you intended to start a new set of measurements but forgot to select New Measurement!)

When using the measuring line, you can use this feature to measure the distance around a curve with a set of line segments [new in version 5].

Keyboard shortcuts

The letter after each popup menu item represents the shortcut key you can press as an alternative to right-clicking: It is worth memorizing these as they speed up data entry considerably:

  • N - New measurement
  • L - Update length
  • W - Update width
  • D - Update depth
  • Del - Delete measurement
  • Ctrl-Del - Delete all measurements
  • U - Undo measurement change
  • A - Toggle measuring circle/line
  • C - Toggle annotation color scheme

Length/width ratio (Q)
The fourth column in the measurement table represents the ratio of length to width, often called Q. This ratio is very well defined for certain organisms e.g. fungus spores, and can prove a useful aid to identification in conjunction with the length and width.

Annotate the picture
Right-click the picture and select Freeze Annotation [F]. The measurement circle and its associated annotation will become part of the picture. Choose Toggle Annotation Mode [M] to switch the annotation between the circle size and a comment typed into the Notes box above the picture. To undo an annotation, choose Undo Last Annotation [Ctrl-Z]. To remove all annotations and other picture changes, choose Undo All Picture Changes [Ctrl-A].

Auto freeze annotation [new in version 5]
When using the measuring line especially, it can be useful to add annotations to every object as it is measured. Choose Options, Auto Freeze Annotation and the annotation will be frozen every time you press L or W. When entering depth (D) you will need to freeze the annotation yourself.

Additional table fields with web color option [new in version 5]
In addition to the L, W ,D and Q
columns, there are four free-text fields E, F, G, H which you can use to store any additional information about the associated measurement. Click the horizontal scrollbars on the measurements table to access these fields. These could be spore shape, ornamentation, angularity or a chemical reaction for example. You can also store a color in the table by entering it as a six-digit web color preceded with a hash in the format #RRGGBB, e.g. #00FF00 will cause the cell to be displayed in lime green when you finish editing and click away from the cell.

Capture a color from the Measure image [new in version 5]
When you left-click on a point in the image, its color is displayed in a box under the measurements, complete with its 6-digit web color. You can copy this text and paste it into one of the user-defined cells in the table. When you finish editing and click away from the cell, the color will change.

Zoom in on the picture
MycoCam provides the means to zoom in closer on areas of interest. Use the click and drag method to produce a measurement circle centered on the area of interest. Before you release the left mouse button, press and hold the Ctrl key. Release the left mouse button and the area encompassed by the circle will expand to fill the picture. The circle scale will change accordingly so that accurate measurements can be made on the enlarged area. To restore the picture to its original size, right-click and select Undo All Picture Changes [Ctrl-A]. All annotation will be lost as well.

Save pictures, measurements and settings
Click the Save File button. A dialog box will prompt you for the name of the .cam file. Enter a filename and click OK, and the picture and all the program settings and measurements will be saved, including the Lens file [new in version 5].

For example, if you save a picture as spores.cam, a file called spores.cam containing all the settings is created, plus a JPEG image file of the actual picture called spores.jpg. You can view and edit the JPEG file using image-editing programs, but you must not resize it or MycoCam will not display it properly.

As an alternative to the button, you can right-click the picture and select Save File.

Load pictures, measurements and settings
Click the Open File button and choose the .cam file that you want to review. The picture will be loaded and the program will adopt all the settings (image size, lens file etc.) which were saved with the picture. The associated measurements will be shown in the grid and their statistics will be calculated.

You can also load .jpg  image files by changing the file type in the dialog. A copy of the jpg file will be created in the camfiles folder and resized to the current image size. A .cam file will be created to hold the associated settings.

As an alternative to the button, you can right-click the picture and select Open File.

Grab an image from the Measure page and save to file
Right-click the picture and select Save Image File [J]. The picture with any annotations added will be saved to the chosen image file format. You can choose either JPG, GIF, PNG or BMP file formats.

Go back to the Preview or Process page, or forward to the Statistics page
In addition to clicking the tabs, you can navigate with a right-click option on the picture. Pressing Enter will take you to Process page.

Making Comparisons

The Compare page allows you to compare an image and its measurements with a second, stored image and its measurements. Start by either capturing an image and making a set of measurements, or by loading a previously-measured image on the Measure page.

Load pictures, measurements and settings for comparison
Click Open File and choose the .cam file that you want to use for comparison. The picture will be loaded into the Compare page and the associated measurements will be shown in the Comparison table. The statistics are calculated. No changes to image size or scale factor are made.

As an alternative to the button, you can right-click the image and select Open File.

Once you have both files open, you can compare them on the Statistics page. [new in version 5]

Capture a color from the Compare image [new in version 5]
When you left-click on a point in the image, its color is displayed in a box under the measurements, complete with its 6-digit web color.
You can flip between Measure and Compare pages to compare the two colors.

Correlation [improved in version 5]
An estimate is made of the correlation between the two sets of measurements, and displayed in the Correlation box. The proportion of values for length, width and Q for the first set of data between 95% of the lower quartile and 105% of the upper quartile of the second set is calculated. Anything over 50% represents 100% correlation. Anything less than 50% is multiplied by 2. The three values are multiplied together and divided by 10000 to get the final correlation figure.

Individual correlations for L, W, D and Q are displayed on the Statistics page.

Statistics and Graph Plot [new in version 5]

This page shows all the statistical information for the data from the Measure and Compare pages in the form of two tables and a graph plot. The parameters for each set are:

Parameters:

  • Minimum
  • Average - arithmetic mean of all values
  • Maximum
  • Lower Quartile - the value exceeded by 75% of the data
  • Median - the central value of the sorted data (or the average of the two central values for even numbers)
  • Upper Quartile - the value exceeded by 25% of the data
  • n - the number of samples
  • Mode - the value that occurs most frequently
  • Standard Deviation - the variability around the average value

Open & Plot
Opens a file and displays the associated measurements and graph plot. Also available on right-click.

Plot
Displays the associated measurements and graph plot for the data currently in the Measure or Compare page. Also available on right-click.

Graph Plot
This shows length along the X axis and width along the Y axis as a set of dots. When the same value occurs multiple times, the dot increases in size up to a maximum of 12 times.The best fit line is plotted between the points, and if there is sufficient data, an ellipse is plotted to give an indication of the shape of the variability.

Bear in mind that in some instances the longest objects can also be the narrowest!

Median and Clicked Values
When a graph is plotted, the median values for length, width and Q are shown in boxes above the graph. The median value is used rather than the average as it tends to exclude outliers or data entry errors.

If you click on any point on the graph, the values for L, W and Q for that spot are displayed instead.

Summary
The minimum, maximum and quartile values for L, W and Q for the associated data are shown in a box above the graph. The exact format depends on the variation in values, and is presented in a form frequently used in the literature for fungus spores:

(MinL)Lower quartile-Upper quartile(MaxL) x (MinW)Lower quartile-Upper quartile(MaxW), Q=(MinQ)Lower quartile-Upper quartile(MaxQ)

Plot Both
When you click Plot Both, or select the option from the right-click menu, the Measure and Compare values are plotted on the same graph.

Correlation
The individual correlation values for L, W, D and Q are displayed in four boxes. The proportion of values for the first set of data between 95% of the lower quartile and 105% of the upper quartile of the second set is calculated. Anything over 50% represents 100% correlation. Anything less than 50% is multiplied by 2.

The total correlation figure is (CorrL x CorrW x CorrQ) / 10000 and is shown separately on the Compare page.

Image Gallery [enhanced in version 5]

The Image Gallery allows you to continually monitor a folder and builds a list of all the image files it finds with thumbnails.

To specify the folder, click Options, Paths, Gallery Path. This can include USB drives and your camera's memory card. Be aware however that the process of updating the gallery can take a long time with many images or large files.

Once complete, the image thumbnails are placed in a box where you can click them to display the image.

Deleting images
You can permanently delete either a single image, or all the images in the gallery, with right-click options. You will be asked for confirmation.

Live video
Click Live Video or select it from the right-click menu. The live image on the Process page will be displayed. Press SPACE BAR or choose Grab Image from the right-click menu to grab the image and copy it to the Gallery folder. The file will be named Zxxxx.jpg where xxxx is at least a four-figure number and one greater than the highest number currently in the Gallery folder.

Transfer to Measure
This very useful feature available on a right-click allows you to copy the file you have just selected in the Gallery to the Measure page. You can then make measurements on it and save it as a .cam file. This is the easiest way to use MycoCam to measure images taken on a still camera. Whatever the size of the original file, the copy is resized to the width and height currently specified on the Process page.

Open CAM File
This right-click option is enabled whenever a .cam file with the same name as the current gallery file is present in the CamFiles folder. Clicking Open CAM File will open the specified file on the Measure page.

Extras [new in version 5]

Quick Launch
This feature allows you to run up to ten external programs, optionally passing them parameters from MycoCam. The programs are run in their own windows and MycoCam does not pause while this is happening.

If the file you want to run is registered, i.e. Windows knows how to run it, simply enter the parameters in the box next to the button. You could enter folder names or web pages for instance. The author has a local web page on his laptop which accesses his library of scanned mycology documents.

If you need to specify an executable file, place it at the start, followed by a comma, then the parameters. The editboxes are saved when you exit MycoCam.

Macros
The following macros are available. When the program is run, they are converted to the value they currently represent. This allows you to pass MycoCam folder names, measurement and comparison .cam file names and data summaries to external programs. You could launch an image stacker on the contents of the stack folder.

Folders (trailing backslash included)

  • %CamFiles%
  • %Images%
  • %Stack%
  • %Gallery%
  • %MyDocuments%
  • %MyPictures%

Files

  • %Measure%
  • %Compare%

Data

  • %Measurements%
  • %Comparison%

Examples

  • Launch My Pictures folder in Explorer: %MyPicturess%
  • Launch a webpage in the browser: www.mywebpage.com/mypage.html
  • Open example.cam in Notepad: notepad.exe,%CamFiles%example.cam
  • Pass the stack folder to a stacker program: mystacker.exe,%Stack
  • Pass the comparison summary to a program: myprog.exe,%Comparison%

Copying to the Clipboard

You can copy the MycoCam form or any of the displayed images to the Windows Clipboard for pasting into other applications. When copying, ensure that no other windows are overlapping the one you want to copy, unless you want this included in the copy!

Copying the form
Select Copy Form from the main menu. An image of the whole form excluding title bar will be copied to the clipboard.

Copying pictures
Right-click a picture and select Copy Image. Depending on which page you are viewing, a copy of the relevant image or plot will be placed on the clipboard.

Copying colors [new in version 5]
Select the web color in the text box and press Ctrl + C to copy it.

Printing

MycoCam will print the complete form with whatever page is currently visible. When printing, ensure that no other windows are overlapping the one you want to copy.

Setting printer properties
Select Print Setup from the main menu. The standard Windows print setup dialog will appear. Choose the Landscape option for your printer if the paper size is less than 9” (25cm) wide.

Printing the form
Select Print Form from the main menu. An image of the whole form including picture and measurements but excluding the title bar will be sent to the printer.

Contacting the Author

Please send requests for advice, bug reports, suggestions for improvement etc. to the author at the following address:

richard@rshotbolt.f2s.com