:mod:`neuron_morphology.snap_polygons.image_outputter` ====================================================== .. py:module:: neuron_morphology.snap_polygons.image_outputter .. autoapi-nested-parse:: Utilites for writing diagnostic overlay images .. !! processed by numpydoc !! Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: neuron_morphology.snap_polygons.image_outputter.ImageOutputter Functions ~~~~~~~~~ .. autoapisummary:: neuron_morphology.snap_polygons.image_outputter.write_figure neuron_morphology.snap_polygons.image_outputter.read_image neuron_morphology.snap_polygons.image_outputter.read_with_ndimage neuron_morphology.snap_polygons.image_outputter.read_jp2 neuron_morphology.snap_polygons.image_outputter.fname_suffix neuron_morphology.snap_polygons.image_outputter.make_pathpatch .. py:class:: ImageOutputter(native_geo: Geometries, result_geo: Geometries, image_specs: Optional[Sequence[Dict]], alpha: float = 0.4, color_cycle: Optional[Sequence] = None, savefig_kwargs: Optional[Dict] = None) Overlays polygons and surfaces on provided images. Writes the results to files. :Parameters: **native_geo** : Layer geometries before gaps are filled .. **result_geo** : Layer geometries after gaps are filled .. **image_specs** : Each is a dictionary defining a single image. Must provide string keys: - input_path : read from here - output_path : write to (siblings of) this path - downsample : the image will be scaled by this factor in each dimension - overlay_types : produce these kinds of overlay for this image **alpha** : of the transparent overlays .. **color_cycle** : as polygon fills are drawn, cycle through these colors .. **savefig_kwargs** : Passed directly to pyplot's savefig, use to specify e.g dpi. .. !! processed by numpydoc !! .. attribute:: DEFAULT_COLOR_CYCLE :annotation: = ['c', 'm', 'y', 'k', 'r', 'g', 'b'] .. attribute:: OVERLAY_TYPES .. method:: _draw_geometries(self, geometries: Geometries, image: np.ndarray) Utility for overlaying polygons and surfaces on an image. See draw_before and draw_after for more details. .. !! processed by numpydoc !! .. method:: draw_before(self, image: np.ndarray, scale: float = 1.0) Display the pre-fill polygons and surfaces overlaid on an image. :Parameters: **image** : onto which objects will be drawn .. **scale** : required to transform from object space to image space .. :Returns: A matplotlib figure containing the overlay .. .. !! processed by numpydoc !! .. method:: draw_after(self, image: np.ndarray, scale: float = 1.0) Display the post-fill polygons and surfaces overlaid on an image. :Parameters: **image** : onto which objects will be drawn .. **scale** : required to transform from object space to image space .. :Returns: A matplotlib figure containing the overlay .. .. !! processed by numpydoc !! .. method:: write_images(self) For each image specified in this outputter and each overlay type requested for that image, produce and save an overlay. .. !! processed by numpydoc !! .. function:: write_figure(fig: plt.Figure, *args, **kwargs) Write a matplotlib figure without respect to the current figure. :Parameters: **fig** : the figure to be writter .. **\*args, **kwargs** : passed to plt.savefig .. .. !! processed by numpydoc !! .. function:: read_image(path: str, decimate: int = 1) Read an image. Dispatch to an appropriate library based on that image's extension. :Parameters: **path** : to the image .. **decimate** : apply a decimation of this factor along each axis of the image .. .. !! processed by numpydoc !! .. function:: read_with_ndimage(path: str, decimate: int) Read (and symmetrically decimate) an image file into a numpy array .. !! processed by numpydoc !! .. function:: read_jp2(path: str, decimate: int) Read (and symmetrically decimate) a jp2 file into a numpy array .. !! processed by numpydoc !! .. function:: fname_suffix(path: str, suffix: str) Utility for adding a suffix to a path string. The suffix will be inserted before the extension. .. !! processed by numpydoc !! .. function:: make_pathpatch(vertices: Sequence[Tuple[float, float]], **patch_kwargs) -> mpl.patches.PathPatch Utility for building a matplotlib pathpatch from an array of vertices :Parameters: **vertices** : Defines the path. May be closed or open .. **\*\*patch_kwargs** : passed directly to pathpatch constructor .. .. !! processed by numpydoc !!