Categories

Authors

Perfecting the X-ray image: EBImage package in R

Hi all! Stuart and I are in the process of figuring out the best way to edit our x-ray images of Echinacea achenes so that it is easy to classify them:

  • Are all achenes (full and empty) visible?
  • Is it easy to tell between full and empty achenes?
  • Can achenes within clumps be identified individually?

Example x-ray image with achenes, before edited

Here is an example of an x-ray image that is tricky to classify. All of these achenes are empty, so they are more translucent and harder to see. Also, many of these achenes are in clumps, so getting the correct count of empty achenes is a challenge.

Example x-ray image before edits, with circled clump

A single clump has been circled in green in this image. This clump has 3 empty achenes, but we want that to be more obvious. To edit our images, we have been working with the EBImage package in R. Here are a few examples.

Edited example #1

This edit is helpful because it makes the background darker so that it’s easier to pick out achenes. The 3 in the clump are still kind of hard to pick out, though. Here is the code we used:

library(EBImage)

x <- readImage('http://echinaceaproject.org/wp-content/uploads/2018/04/x2mid.jpg')
display(x)

kern = 2000*makeBrush(99, shape = 'Gaussian', sigma = 5)
display(whiteTopHat(x, kern))

This example is blurred a bit, which is helpful for seeing achenes in their entirety. This is the code we used:

library(EBImage)

x <- readImage('http://echinaceaproject.org/wp-content/uploads/2018/04/x2mid.jpg')
display(x)

display(gblur(x, sigma=0.8))

There are endless possibilities if using multiple EBImage functions on one image, and we are looking for some guidance. If you have experience with EBImage, what do you think are the best combinations of functions for reaching our goals? Thanks for the help!

 

Facebooktwittergoogle_pluspinterestmail

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>