RRtoolbox.tools package¶
Submodules¶
RRtoolbox.tools.lens module¶
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