Converting Area Measurement Annotations to Area (For flat-downard facing camera)

Converting Area Measurement Annotations to Area (For flat-downard facing camera)

These notes were prepared by Brian Schlining on 2013-12-18

If you are working with images collected by a camera that is at an angle to the seafloor (such as the Rover or Tripod) then you should refer to the documentation for Canadian Grid Area Measurements instead.

Overview

Once you've spent weeks drawing tiny, tiny little polygons on your images you may decide that they would be more useful as actual area measurements. Or maybe not, who am I to say. VARS stores polygons as x-y pairs followed by a comment description of the measurement. For example, "1 2 20 20 100 200; the area of my most favorite polygon ever!" The x-y pairs define the pixel coordinates of each vertex of the area polygon. The instructions below will patronizingly and pedantically guide you through the steps needed to convert these pixel coordinates to really, really useful planar area valus in real world units like centimeters, angstroms and cubits.

What you WILL Need

How to Generate Areas

There are a few steps to walk. They are the following, and in the following order:
  1. Perform a query using the VARS query for imaging
  2. Save the results of the query to a text file
  3. Put the query results someplace that the computer Seaspray can see them from. Your directory on Tempbox is an excellent choice.
  4. ssh onto Seaspray from a terminal and go to the vars-imaging directory. If you're unfortunate enough to be running Windows, you may need to go and download PuTTY.
                ssh seaspray.shore.mbari.org
                cd /opt/vars-imaging/bin
              
  5. Run the process_area script like so:
    ./gsh ../scripts/groovy/process_simplearea [infile] [outfile]
              
    infile is the file of annotations that you saved earlier. outfile is the file you want to write the results to. Here's an example using a file stored in the tempbox brian
    .gsh ../scripts/groovy/process_simplearea /mbari/Tempbox/brian/my_infile.txt /mbari/Tempbox/brian/my_outfile.txt
              
  6. The resulting area is in pixels. You need to figure out how big an area a pixel represents. If you have the image width and height you can do the following:
    pixelArea = (cmWidth * cmHeight) / (pixelWidth * pixelHeight)
    In this equation we are using cm to represent the area, but you can use whatever units are appropriate.
  7. Once you have the pixel area you can do the conversion from pixel area to actual area in your favorite number crunching tool, such as Excel, Matlab or, for the truly awesome, Scala. Just multiply the area column in your outfile by pixelArea.