----- Forwarded message from Sam Brown <s_d_j_br...@hotmail.com> -----

Date: Sun, 24 Mar 2013 21:18:53 -0400
From: Sam Brown <s_d_j_br...@hotmail.com>
Reply-To: Sam Brown <s_d_j_br...@hotmail.com>
Subject: RE: Digitizing Multiple Images in Geomorph
To: morphmet@morphometrics.org, kfet...@live.unc.edu, eotarolacasti...@fas.harvard.edu

>> Date: Fri, 22 Mar 2013 11:09:01 -0400
>> From: "Fetter, Karl" <kfet...@live.unc.edu>
>> Subject: Digitizing Multiple Images in Geomorph
>>
>> Hello, I have a folder of multiple images that I want to digitize landmarks using geomorph in R. I made on object using list.files() (called images.2.dig) that contains the names of all of the .jpg images that I want to digitize. I supplied R w/ this command: digitize2d(images.2.dig, 10, scale=1). I am able to set the scale and digitize landmarks on the first image, but after that, I'm unable to progress to the subsequent images.
>>
>> How can I change to the next image? Is there a way to "save" my progress? Or should I just supply a new object that contains the name of the images I haven't yet digitized?
>>
>> Thanks for the help,
>>
>> Karl Fetter


> Hi Karl,
>
> As of right now geomorph's digitize2d() only proceeds one specimen at a time. Thus in the filename argument you might want to add the specimen number within a bracket, e.g., images.2.dig[1], images.2.dig[2], images.2.dig[3], etc. Your code will look more like this:  
>
> digitize2d(images.2.dig[1], 10, scale=1).
>
> That said, Dr. Adams and I are working on an improved digitizing "workflow" system for geomorph, and hope to get it updated by the next version (in the following few months). Hope that helps!
>
> Cheers,
>
> Erik


Hi Karl

One method for automating Erik's suggestion, is to place the digitize2d() function into an lapply() function like so:

images.2.dig <- list.files()
imagesDigged <- lapply(images.2.dig, function(xx) digitize2d(xx, 10, scale=1))

imagesDigged[[1]] will contain the coordinates for the first image, imagesDigged[[2]] the coordinates of the second, etc...
    
The "apply" family of functions are extremely powerful once one has some familiarity with them. A good introduction is available at this website: http://nsaunders.wordpress.com/2010/08/20/a-brief-introduction-to-apply-in-r/

Some self-contained examples of lapply() follow:

aa <- seq(1, 10, by = 2)
lapply(aa, function(xx) xx * 3)
lapply(aa, function(xx) rep(xx, 10))
lapply(aa, function(xx) runif(xx, min = 1, max = 10))

I hope this helps!

Sam


Samuel Brown
Postgraduate Student
Bio-Protection Research Centre
PO Box 84
Lincoln University
Lincoln 7647
Canterbury
New Zealand
sam.br...@lincoln.ac.nz
http://www.the-praise-of-insects.blogspot.com



----- End forwarded message -----



Reply via email to