RRtoolbox.tools package

Submodules

RRtoolbox.tools.lens module

RRtoolbox.tools.lens.drawCircle(array, cnt, color=0)[source]

project circle over array.

Parameters:
  • array – array to draw circle
  • cnt – contours of segmentation to fit circle
  • color – color of lens
Returns:

array

RRtoolbox.tools.lens.drawEllipse(array, cnt, color=0)[source]

project ellipse over array.

Parameters:
  • array – array to draw ellipse
  • cnt – contours of segmentation to fit ellipse
  • color – color of lens
Returns:

array

RRtoolbox.tools.lens.fitLens(img, mask, color=0, asEllipse=False, addmask=False)[source]

Place lens-like object in image.

Parameters:
  • img – image to place lens
  • mask – mask to fit lens
  • color – color of the lens
  • asEllipse – True to fit lens as a ellipse, False to fit circle.
  • addmask – return additional mask parameter
Returns:

image with simulated lens

RRtoolbox.tools.lens.simulateLens(img, threshfunc=None, pshape=(300, 300), color=0, asEllipse=True)[source]

Place lens-like object in image.

Parameters:
  • img – image to place lens.
  • threshfunc – function to segment retinal area and get its mask.
  • pshape – shape to resize processing image to increase performance.
  • color – color of the lens.
  • asEllipse – True to fit lens as a ellipse, False to fit circle.
Returns:

image with simulated lens.

RRtoolbox.tools.segmentation module

RRtoolbox.tools.segmentation.find_optic_disc_watershed(img, P)[source]

Find optic disk in image using a watershed method.

Parameters:
  • img – BGR image
  • P – gray image
Returns:

optic_disc, Crs, markers, watershed

RRtoolbox.tools.segmentation.get_beta_params_Otsu(P)[source]

Automatically find parameters for alpha masks using Otsu threshold value.

Parameters:P – gray image
Returns:beta1 for minimum histogram value, beta2 for Otsu value
RRtoolbox.tools.segmentation.get_beta_params_hist(P)[source]

Automatically find parameters for bright alpha masks using a histogram analysis method.

Parameters:P – gray image
Returns:beta1 for minimum valley left of body, beta2 for brightest valley right of body where the body starts at the tallest peak in the histogram.
RRtoolbox.tools.segmentation.get_bright_alpha(backgray, foregray, window=None)[source]

Get alpha transparency for merging foreground to background gray image according to brightness.

Parameters:
  • backgray – background image. (as float)
  • foregray – foreground image. (as float)
  • window – window used to customizing alfa. It can be a binary or alpha mask, values go from 0 for transparency to any value where the maximum is visible i.e a window with all the same values does nothing. A binary mask can be used, where 0 is transparent and 1 is visible. If not window is given alfa is not altered and the intended alpha is returned.
Returns:

alfa mask

RRtoolbox.tools.segmentation.get_layered_alpha(back, fore)[source]

Get bright alpha mask (using Otsu method)

Parameters:
  • back – BGR background image
  • fore – BGR foreground image
Returns:

alpha mask

RRtoolbox.tools.segmentation.layeredfloods(img, gray=None, backmask=None, step=1, connectivity=4, weight=False)[source]

Create an alpha mask from an image using a weighted layered flooding algorithm,

Parameters:
  • img – BGR image
  • gray – Gray image
  • backmask – background mask
  • step – step to increase upDiff in the floodFill algorithm. If weight is True step also increases the weight of the layers.
  • connectivity – pixel connectivity of 4 or 8 to use in the floodFill algorithm
  • weight – Increase progressively the weight of the layers using the step parameter.
Returns:

alpha mask

RRtoolbox.tools.segmentation.retina_markers_thresh(P)[source]

Retinal markers thresholds to find background, retinal area and optic disc with flares based in the histogram.

Parameters:P – gray image
Returns:min,b1,b2,max

where:

black background < min b1 > retina < b2 flares > max
RRtoolbox.tools.segmentation.retinal_mask(img, biggest=False, addalpha=False)[source]

Obtain the mask of the retinal area in an image. For a simpler and lightweight algorithm see retinal_mask_watershed().

Parameters:
  • img – BGR or gray image
  • biggest – True to return only biggest object
  • addalpha – True to add additional alpha mask parameter
Returns:

if addalpha:

binary mask, alpha mask

else:

binary mask

RRtoolbox.tools.segmentation.retinal_mask_watershed(img, parameters=(10, 30, None), addMarkers=False)[source]

Quick and simple watershed method to obtain the mask of the retinal area in an image. For a more robust algorithm see retinal_mask().

Parameters:
  • img – BGR or gray image
  • parameters – tuple of parameters to pass to filterFactory()
  • addMarkers – True to add additional Marker mask. It contains 0 for unknown areas, 1 for background and 2 for retinal area.
Returns:

if addMarkers:

binary mask, Markers mask

else:

binary mask

RRtoolbox.tools.selectors module

class RRtoolbox.tools.selectors.EntropyPlot(images, win='Entropy tests', func=None)[source]

Bases: RRtoolbox.lib.plotter.Plotim

Plot entropy test

getData(im)[source]
getImage(im)[source]
keyfunc()[source]
nextim()[source]
previousim()[source]
selectlist(imlist)[source]
RRtoolbox.tools.selectors.entropy(imlist, loadfunc=None, invert=False)[source]

Entropy function modified from:

Yan Liu, Feihong Yu, An automatic image fusion algorithm for unregistered multiply multi-focus images, Optics Communications, Volume 341, 15 April 2015, Pages 101-113, ISSN 0030-4018, http://dx.doi.org/10.1016/j.optcom.2014.12.015. (http://www.sciencedirect.com/science/article/pii/S0030401814011559)

Parameters:imlist – list of path to images or arrays
Returns:sortedD,sortedImlist,D,fns
where sortedD is the ranking of the Entropy test, D = [D0,...,DN] D0>DN
sortedImlist is fns sorted to match sortedD, D is the list of the absolute difference between entropy and the root mean square, D = ||E-RMS||
RRtoolbox.tools.selectors.hist_comp(imlist, loadfunc=None, method='correlation')[source]

Histogram comparison

Parameters:imlist – list of path to images or arrays
Returns:comparison

RRtoolbox.tools.sticher module

RRtoolbox.tools.sticher.stich(**opts)[source]

Module contents