Giter VIP home page Giter VIP logo

imextractor's Introduction

imExtractor

DOI

The goal of imExtractor is to provide a simple and flexible tool to analyze images as binary thresholds. imExtractor functions are wrappers which integrate processing steps of EBImage and as such are not compiled as a stand alone package. However functions can be directly soured into the R workspace with instructions here. Example application of this code is available and is based on an image of blue mussel (mytilus edulis) gonad stored within the vignettes folder.


Example output from image processing where image cellular tissue is quantified relative to the cropped image. In this case the tissue coverage was assigned at 50.3% of the original image.


Requirement: imExtractor requires the installation and availability of the R package 'EBImage' which is available at biocondicutor with example use instructions


Contributions:

imExtractor coded by Ryan Stanley https://github.com/rystanley

  • If you don’t understand something, please let me know: (ryan.stanley at dfo-mpo.gc.ca).
  • Any ideas on how to improve the functionality are very much appreciated.
  • If you spot a typo, feel free to edit and send a pull request.

Pull request how-to:

  • Click the edit this page on the sidebar.
  • Make the changes using github’s in-page editor and save.
  • Submit a pull request and include a brief description of your changes. (e.g. "spelling errors" or "indexing error").

Citation

A Zenodo DOI is also avaiable for the most recent release of imExtractor:

DOI

Stanley, R.R.E. (2017). imExtractor: a simple and flexible tool to analyze images as binary thresholds. DOI:10.5281/zenodo.802877


Installation

imExtractor can be sourced into the workspace by cloning this Github directory or by sourcing directly using the web url.

library(RCurl) # if you do not have the package rcurl installed please load from CRAN.
library(EBImage) # see installation instructions for the EBImage package.

#links for the 'raw' code
Weblinks <- c("https://raw.githubusercontent.com/rystanley/imExtractor/master/Code/ImageBatchProcess.R",
              "https://raw.githubusercontent.com/rystanley/imExtractor/master/Code/ImageProcess_Singular.R")

#source the 'raw' code links into the local environment
for (i in Weblinks){
  
  script <- getURL(i, ssl.verifypeer = FALSE)
  eval(parse(text = script),envir=.GlobalEnv)
  rm(script)  
}

Example use

NOTE this code will create a folder called "Processed images" and store a visual representation of the processed output in '.png' format. This image processing script uses approaches and parameters to augment the processing:

Approach Description
Adaptive thresholding is a technique to account for variation in illumination and cell tissue transparency or binary target colour within each image.
Gaussian blurring is a low-pass filter which effectively blurs the image.
Bottom cropping this is an optional parameter enabling the code to automatically crop the bottom of the image off according to a set number of pixels. This parameter is useful if images have a scale bar added to each.
Parameter Input
path the full or relative file path for the target image.
pix Defines the number of pixels to be used in adaptive thresholding (default: 200). Here a threshold is applied by a locally moving filter.
offset Thresholding offset from the averaged pixel value (default: 0.01). In this case each group of pixels an average will be used to define what is 'target' (e.g. tissue) and what is 'background' this offset will define how far off the average you want to make this delineation.
sigma This parameter repesentes the standard deviation of the Gaussian filter used for blurring (default: 3).
crop Optional bottom cropping parameter (default: no cropping or NA).

##Process single images:

Run image processing script to a single image using default parameters.

setwd("vignettes/")
ImageProcess_single("Example1.tif") # default parameters

Example output from image processing where image cellular tissue is quantified relative to the cropped image. In this case the tissue coverage was assigned at 50.3% of the original image.


Run image processing script to a single image using a smaller (50 px) and larger (500 px) adaptive thresholding window and otherwise default parameters.

setwd("vignettes/")
ImageProcess_single("Example2.tif",pix=50) # default parameters
ImageProcess_single("Example3.tif",pix=400) # default parameters

Example output from image processing with thresholding window adjusted to 50 pixels (tissue coverage = 47.6%).

Example output from image processing with thresholding window adjusted to 400 pixels (tissue coverage = 49.9%).


Run image processing script to a single image using decreased and increased blurring otherwise default parameters.

setwd("vignettes/")
ImageProcess_single("Example4.tif",sigma=0.01) # default parameters
ImageProcess_single("Example5.tif",sigma=10) # default parameters

Example output from image processing with a decreased standard deviation of the Gaussian blurring filter (tissue coverage = 47.1%).

Example output from image processing with an increased standard deviation of the Gaussian blurring filter (tissue coverage = 60.5%).


Run image processing script to a single image using decreased and increased thresholding offsets.

setwd("vignettes/")
ImageProcess_single("Example6.tif",offset=0.001) # default parameters
ImageProcess_single("Example7.tif",offset=0.175) # default parameters

Example output from image processing with a decreased thresholding offset (tissue coverage = 48.5%).

Example output from image processing with an increased standard deviation of the Gaussian blurring filter (tissue coverage = 84.4%).

##Batch process images:

#Batch process all images in the image in the directory. This function applies the ImageProcess_Singular to each image (.tif) in path specified by the folder parameter.

BatchProcessExample <-ImageBatchProcess(folder="Batch/") # default parameters. 

BatchProcessExample # view output

imextractor's People

Contributors

rystanley avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.