GPG related links

I have recently been drawn back to mutt. Along with the migration, I would like to start signing my mails again. I was using the gmail web mail and did not spend time figuring out how to sign mails. This post is to remind me of cool gpg links that I found along the way. Feel free to comment if you know of a link that is not here :)

General gpg information

gpg and mutt

Moving gpg keys

Posted in Uncategorized | Tagged , , , | Leave a comment

PDF word statistics in one “looong” line

The paper that I am writing requires some background information about how digital imaging has been related to phenology. For this I have decided to implement an SLR. I am at the point in the SLR process where I have to “Define or elicit search string”. I chose to do this by counting the repeated words in my initial list of papers (Denominated “Quasi Gold Standard” in Pablo’s paper).

The linux Journal got me started with this interesting article from Dave Taylor. The article got most of the work done, but it lacked the part where I change all my pdf files into text files. So here is the revised version of the Dave’s really cool one liner :

find . -name *.pdf -exec pdftotext '{}' - \; |tr ' ' '\
' |tr '[:upper:]' '[:lower:]' | tr -d '[:punct:]' | grep -v '[^a-z]' |sort | uniq -c | sort -rn > output.txt

I just added the initial part where I find all the pdf and execute `pdftotext`. Hope this is useful :)

Posted in commands | Tagged , , , , , , , , , , , , | Leave a comment

Some out of the box thinking. How we see.

This ted video is really cool Optical illusions. It has some interesting insight on ways to approach flower detection.

Things to think about:

“… it means that the same image could have an infinite number of possible real world sources…”

“… the light that falls on to your eye -sensory information- is literary meaningless, because it could be literary anything…”

“… because in the statistics of your past experience it would have been useful to do so, so you do so again…”

“… the brain didn’t actually evolve to see the world the way it is, we can’t. Instead the brain evolved to see the world the way it was useful to see in the past…”

“… the way we see is by continually redefining normality…”

Hats off to the ppl at TED….

Posted in PhD | Tagged , , , | Leave a comment

R. create a plot with non overlapping labels

The X axis labels were a bit long and they were having trouble fitting into the plot correctly. I tried various solutions: R’s default and maptool’s pointLabel. The first did not really allow me to turn the labels 90 deg (I know I can do it with text, but that is not R’s default for creating the X axis). The second did not really work that well with my long labels.

The trick that I applied is contained in this commit. This is the steps that the algorithm follows explained in “human” terms:

  • I found the plot X axis increment. This means that the plot will increment INC amount of units for every point in the X axis.
INC = ( par("fin")[1]/abs(abs(par("usr")[1])-abs(par("usr")[2]))
  • I found the size of the resulting font. Notice that in the commit that I linked there is an additional CEX variable. I use it because text allows further font size control. Further notice that all the variables I’m using have the same units.
FS = (par("cin")[1]*CEX)
  • The relation between FS and INC is the minimum space in X axis units that needs to exist between two labels.
MagicNumber = FS/INC
  • Finally its a matter of constructing the “at” and “label” vectors being careful that adjacent elements don’t have a distance < MagicNumber
for ( i in 1:(length(AT)-1) )
  dist = abs(ATtmp[length(ATtmp)] - AT[i+1])
  if ( dist > MagicNumber )
   ATtmp = c(ATtmp, AT[i+1])
   Ltmp = c(Ltmp, labls[i+1])

I could have probably coded this more efficiently, but I am lazy by nature :)

Posted in commands, R | Tagged , , , , , , | Leave a comment

Interesting annotation app.

One of the next steps within my Ph.D. is to create an annotation tool that can annotate a series of images. This will require capabilities like propagating annotations through time, propagating changes through time and facilitating pan/zoom actions.

I recently came across imageJ. It is an image processing program that does more things than I am comfortable with. I had a look at the class hierarchy and it has “spare parts” potential. It seems that there is code to handle the upload of images, annotations with different polygons, it handles image series (it calls them “stacks”).

I’ll have to run it and see how fast it is. One of the major aspects of whatever we use is that it needs to handle large images very fast.

Posted in annotation, PhD | Tagged , , , | Leave a comment

The Flower counting algorithm lives

I recently finished a flower counting algorithm and am very happy with the results. While the test was done with an easy set of images (yellow flowers over brown ground), I wanted to celebrate an important milestone in the project with a post:).

I created a video that has the result of the Naive Bayesian Model applied to some pictures. Notice how the model displays each flower and gives it a number. In this way we have detected and counted the occurrence of an ecological event!!!!

For further information on the application used to create this video and how it works, please go to the project page.

Posted in annotation, PhD | Tagged , , , , , , | Leave a comment

R: How to suppress package startup messages


And you can still test the result of the `library` or `require` calls:

a = suppressPackageStartupMessages(require(fields))

Variable ‘a’ will be TRUE if it was successful, FALSE otherwise.

Posted in R | Tagged , , , | 2 Comments

Using Matlab was a mistake.

Because it is not free.

I think its awesome. Image processing, handling really large matrices, creating GUIs… It’s a very well-rounded tool and the learning curve is almost non-existent (you start doing really crazy stuff with no effort). There is tons of documentation, there are lots of users and user-created content. There are tons of forums and places you can get help. You can pay mathworks for help… Its fast if you take advantage of matrix calculations (Don’t touch a for loop, it will take for ever). It does have some downsides, but overall it’s an excellent tool to work with.

The problem is that it’s not free. Please don’t misunderstand me. I’m not going to start a movement that might eventually coerce Mathworks into releasing a GPL version of Matlab. I’m not interested in creating a new interpreter that will run Matlab scripts (It has already been done: Octave). I’m not mad at Mathworks. As far as I know they have all the right to charge some money for their cool product. Now that I think of it, I indirectly payed for the license through my taxes to the Danish government that ultimately ended up paying for the campus license that I am using.

No, I’m not mad at all those things. What pisses me off is that there is one more reason NOT to use my code. It’s actually a pretty big deterrent for prospective users. Think of it this way: If someone wants to use my code (In a legal manner), they have to pay a Matlab license. In their mind, my code will cost them whatever the Matlab licence costs (which depends on specific situations). Moreover there is no easy way that the user can “try out” my code. They would have to know that there is a possibility of getting Matlab for 15 trial, they would have to know where to go to get it and they would have to be willing to go through the pain of filling out forms (Its possible, but they need to jump through hoops).

It would be much easier if it were just free and open.

Posted in annotation | Tagged , , , | 12 Comments

Very Painful EBImage install on Windows

Short Version

  1. Follow this to install EBImage
  2. Go here to get GTK+. I used this one.
  3. Make sure you add the GTK+ “bin” directory to the path.
  4. If you have zlib1.dll problems, or any problems regarding the specific dll that is being loaded: you can use Process Explorer to find out which dll is being loaded.
  5. Install ImageMagick from here. I used this one.

Long Version

To the ones that think that everything is easier on windows, I must strongly disagree. I have some R code that is pretty handy for handling plant image series. As I am a Linux user, I created it and tested it on Linux. I have gotten to a point were I needed to test it in windows. So I got a windows box from a colleague and started what I thought would be an easy installation process. Note that I have not even gotten to testing my code. What is contained in this post is the troubles I went through to install EBImage, an R package that my code needs.

Installing EBImage in R is not very painful. You just need to follow these instructions. But when you try to import EBImage it says that you don’t have GTK+ installed. Logically I go to this site to get me some GTK+. I find that they don’t have a windows installer but they do have a zipped file that you can put on your “Program Files” directory. I download this file and put it on my “Program Files” directory. You can actually put it wherever you want, but I wanted it to go where all the programs where (didn’t want it to feel lonely). But when I tried to import EBImage in the RGui, it didn’t work.

Aha. The path. For the stuff that you have just “installed” to be found by applications, you have to add the installation directory to the path. I have learned that it is a bit different in every windows. I followed this link to change the path. But when I tried to import EBImage in the RGui, it didn’t work. The error message changed (that is always a good sign that you are doing the right thing). The error message read something like “The procedure entry point deflateSetHeader could not be located in the dynamic link zlib1.dll”.

I thought im might be some versioning issue with the zlib1.dll that came with the GTK+ installation, but the GTK+ tests worked just fine. I tried to put the GTK+ directory first in the path, but that did not work either. I turned to google and found that someone had the same issues and ultimately had to hunt for the zlib1.dll that was getting loaded and replace it with the one that GTK+ provided. But how to do this? I downloaded the Process Explorer tool to see if I could use it in an “strace” kinda way. This tool provided a way to debug processes and this is where I got the output of the libraries that EBImage was bringing in. It turned out that there was another zlib1.dll library in c:/WINDOWS/system. After I replaced that it still did not work :)

But it was because I had not installed imageMagick. Once I installed it from this link, the EBImage import finally worked. Yes. I’m no windows expert. But I still it was more painful than I expected.

Posted in commands, R | Tagged , , , , , , , , , | Leave a comment

sshfs: where were you all along :)

Did you know that you could mount a remote directory (any directory accessible to you) through an ssh command? I was reading 16 ultimate ssh hacks by Carla Schroder and found out this little piece of heaven. The command is sshfs. You use it in the following way:


There are also some really cool comments on slashdot about further ssh candy.

Posted in commands | Tagged , , , , | Leave a comment