Last data update: 2014.03.03

R: Finding the optimal cutoff value for segmentation
cutoffR Documentation

Finding the optimal cutoff value for segmentation

Description

This function reads the picture provided in a path and performs image segmentation in a gray scale version of the picture at different values of color between 0 and 1 depending of the background color. If the background is black the function will segment the picture at values of 0.01 to 0.12 and if a white background is used values 0.5 to 0.8 will be used in order to determine the optimal value of segmentation, such values can be modified by the user in the argument 'prefs'. The resulting images at different cutoff values will be stored in a folder created with the name 'cutoff_vals' in the same folder provided by the user.

Usage

cutoff(folder, cores = 1, prefs = NULL)

Arguments

folder

A path where the sample pictures are located.

cores

A scalar value indicating the number of cores that you want to use for parallelizing the function, default is 1

prefs

a vector containing the values of the cutoffvalues to be used in the analysis.

Details

In image analysis segmentation can be done based on different parameters, the most common way to do it is by maximizing the contrast of a background with the object of study (i.e. fruits). Most software uses white or black backgrounds to maximize the contrast with the objects, but a cuttoff value needs to be set in order to get accurate estimates of the objects in the pictures. GiNA has been optimized to be used with any background but an initial cutoff value needs to be provided to the core function scanCRAN. The purpose of this function is to try different cutoff values and decide the optimal.

Value

If parameters are indicated correctly the function returns:

$pics

pictures in a folder named "cutoff_vals" with different values for segmentation to help the user define the optimum cutoff value for the crop.

References

We have spent valuable time developing this package, please cite it in your publication:

Diaz-Garcia L, Covarrubias-Pazaran G, Schlautman B, Zalapa J. GiNA: A flexible high throughput phenotyping tool. http://horticulture.wisc.edu/cggl/ZalapaLab/People.html. 2015.

Examples


library(GiNA)

data(GINA.sample) # RUN
display(GINA.sample)
writeImage(GINA.sample, "gina_cran.JPG") # RUN
folder <- getwd() # RUN
?cutoff
cutoff(folder, cores=1) # RUN

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(GiNA)
Loading required package: EBImage
Loading required package: png
Loading required package: parallel
Loading required package: doParallel
Loading required package: foreach
Loading required package: iterators
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GiNA/cutoff.Rd_%03d_medium.png", width=480, height=480)
> ### Name: cutoff
> ### Title: Finding the optimal cutoff value for segmentation
> ### Aliases: cutoff
> 
> ### ** Examples
> 
> 
> library(GiNA)
> 
> data(GINA.sample) # RUN
> display(GINA.sample)
> writeImage(GINA.sample, "gina_cran.JPG") # RUN
> folder <- getwd() # RUN
> ?cutoff
cutoff                  package:GiNA                   R Documentation

_F_i_n_d_i_n_g _t_h_e _o_p_t_i_m_a_l _c_u_t_o_f_f _v_a_l_u_e _f_o_r _s_e_g_m_e_n_t_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     This function reads the picture provided in a path and performs
     image segmentation in a gray scale version of the picture at
     different values of color between 0 and 1 depending of the
     background color. If the background is black the function will
     segment the picture at values of 0.01 to 0.12 and if a white
     background is used values 0.5 to 0.8 will be used in order to
     determine the optimal value of segmentation, such values can be
     modified by the user in the argument `prefs`. The resulting images
     at different cutoff values will be stored in a folder created with
     the name `cutoff_vals` in the same folder provided by the user.

_U_s_a_g_e:

     cutoff(folder, cores = 1, prefs = NULL)
     
_A_r_g_u_m_e_n_t_s:

  folder: A path where the sample pictures are located.

   cores: A scalar value indicating the number of cores that you want
          to use for parallelizing the function, default is 1

   prefs: a vector containing the values of the cutoffvalues to be used
          in the analysis.

_D_e_t_a_i_l_s:

     In image analysis segmentation can be done based on different
     parameters, the most common way to do it is by maximizing the
     contrast of a background with the object of study (i.e. fruits).
     Most software uses white or black backgrounds to maximize the
     contrast with the objects, but a cuttoff value needs to be set in
     order to get accurate estimates of the objects in the pictures.
     GiNA has been optimized to be used with any background but an
     initial cutoff value needs to be provided to the core function
     'scanCRAN'. The purpose of this function is to try different
     cutoff values and decide the optimal.

_V_a_l_u_e:

     If parameters are indicated correctly the function returns:

     $pics pictures in a folder named "cutoff_vals" with different
          values for segmentation to help the user define the optimum
          cutoff value for the crop.

_R_e_f_e_r_e_n_c_e_s:

     We have spent valuable time developing this package, please cite
     it in your publication:

     Diaz-Garcia L, Covarrubias-Pazaran G, Schlautman B, Zalapa J.
     GiNA: A flexible high throughput phenotyping tool.
     http://horticulture.wisc.edu/cggl/ZalapaLab/People.html. 2015.

_E_x_a_m_p_l_e_s:

     library(GiNA)
     
     data(GINA.sample) # RUN
     display(GINA.sample)
     writeImage(GINA.sample, "gina_cran.JPG") # RUN
     folder <- getwd() # RUN
     ?cutoff
     cutoff(folder, cores=1) # RUN
     

> cutoff(folder, cores=1) # RUN

You are using 1 core(s) out of 4 available

Please monitor the progress of the segmentation for the different values of color threshold at the folder:
/home/ddbj/DataUpdator-rgm3/target/cutoff_vals2

You selected to test the following values:

 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8 if background is white, or
 0.01, 0.03, 0.05, 0.07, 0.09, 0.11 if background is black. 

Please check the segmentation pictures and decide the best value of segmentation for posterior analysis


Please remember to use the optimum cutoff value we have found for the posterior functions 

See the results in the folder: 

 /home/ddbj/DataUpdator-rgm3/target/cutoff_vals2 

> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>