I have a project of segmenting a metal bead and I have done all the image processing using the following codes in R (with imager library) and end up with the results as shown at