Code covered by the BSD License  

Highlights from
Photo Quadrat Selection Tool

image thumbnail
from Photo Quadrat Selection Tool by Joshua Stough
An interactive tool for manually selecting photo quadrats from a collection of images.

quadratSelection_AllImages(extension, quadratSize)
%%quadratSelection_AllImages(extension, quadratSize): 
%%place quadratSelection_AllImages.m in the
%%current directory containing images, and run this program.  It allows the
%%user to interactively select and save one quadrat per image.  The saved
%%quadrats are stored in a generated subfolder called 'savedQuadrats'. See
%%quadratSelection_OneImage.m for the interactive quadrat selection of one
%%image. This program is simply a top-level that loops through the images
%%to call the individual selection function.
%%quadratSelection_OneImage and quadratSelection_AllImages
%%should both be in the same folder. The two arguments are defaulted, read
%%the code.

%{
Joshua Stough
W&L, Image Group
June 2012
____
Citation is currency. Please see README. Please cite:
Joshua Stough, Matlab quadrat selection tool, 2012. 
http://www.mathworks.com/matlabcentral/fileexchange or 

Joshua Stough, Lisa Greer, William Benson: Texture and Color Distribution-based
Classification for Live Coral Detection. Proceedings of the 12th International 
Coral Reef Symposium, Cairns, Australia, 9-13 July 2012
%}

function [] = quadratSelection_AllImages(extension, quadratSize)

    %The quadrat image can be scaled to any size through the imtransform
    %(see quadratSelection_OneImage), and presumeably you don't want to
    %lose resolution.
    if nargin < 2, quadratSize = 2048; end
    
    %Only certain image types are imread-able, right?  But most good
    %cameras offer non-lossy output too, right?  Anyway, what files to
    %perform the quadrat selection on...
    if nargin < 1, extension = '*.jpg'; end
    
    %Make results directory if it doesn't already exist.
    if ~exist('savedQuadrats', 'dir')
        mkdir('savedQuadrats');
    end
    %Make meta directory if it doesn't already exist.
    if ~exist('savedQuadratMetaData', 'dir')
        mkdir('savedQuadratMetaData');
    end
    
    %Get all files in the current directory that fit the extension
    %expression.
    imFiles = dir(extension);
    
    for i = 1:length(imFiles)
        
        fprintf('Beginning quadrat selection for image %s...\n', imFiles(i).name);
        
        
        %New to matlab GUIs, this is how I revert control back to this
        %process. I instantiate a hidden figure that
        %quadratSelection_OneImage knows to close when the user completes
        %interaction with the one image.
        h = figure('Visible', 'off');
        quadratSelection_OneImage(imFiles(i).name, h, quadratSize);
        waitfor(h);
        %Blocks execution, of this process, until the handle h is
        %destroyed.
        
        fprintf('Done with image %s.\n\n', imFiles(i).name);
    end


end

Contact us