DipCoatImage-FiniteDepth-IFD documentation#

API reference#

Finite depth dip coating uniformity measurement using integral Fréchet distance.

To reproduce the examples, run the following code first:

import cv2
from finitedepth import *
from finitedepth_ifd import *
class finitedepth_ifd.IfdRoughnessBase(image, substrate, roughness_type, delta, *, tempmatch=None)[source]#

Base class to measure layer surface roughness with integral Fréchet distance.

The following types of roughness are supported:

  • Arithmetic roughness \(R_a\)

  • Quadratic mean roughness \(R_q\)

Parameters:
image, substrate

See CoatingLayerBase.

roughness_type{‘arithmetic’, ‘quadratic’}
deltadouble

The maximum distance between the Steiner points to compute the roughness. Refer to roughness() for more explanation.

Other Parameters:
tempmatchtuple, optional

See CoatingLayerBase.

abstract surface()[source]#

Coating layer surface points.

Returns:
ndarray

An \(N\) by \(2\) array containing the \(xy\)-coordinates of \(N\) points which constitute the coating layer surface profile.

abstract uniform_layer()[source]#

Imaginary uniform layer points.

Returns:
thicknessdouble

Thickness of the uniform layer.

ndarray

An \(M\) by \(2\) array containing the \(xy\)-coordinates of \(M\) points which constitute the uniform layer profile.

roughness()[source]#

Surface roughness of the coating layer.

Returns:
roughnessdouble

Roughness value.

pathndarray

An \(P\) by \(2\) array representing the optimal warping path in the parameter space.

See also

curvesimilarities.averagefrechet.afd

Average Fréchet distance.

curvesimilarities.averagefrechet.qafd

Quadratic average Fréchet distance.

Notes

The roughness is acquired by computing the similarity between surface() and uniform_layer().

class finitedepth_ifd.RectIfdRoughness(image, substrate, roughness_type, delta, opening_ksize, reconstruct_radius, *, tempmatch=None)[source]#

Measure layer surface roughness over rectangular substrate.

Parameters:
image

See CoatingLayerBase.

substrateRectSubstrate.

Substrate instance.

roughness_type, delta

See IfdRoughnessBase.

opening_ksizetuple of int

Kernel size for morphological opening operation. Must be zero or odd.

reconstruct_radiusint

Radius of the safe zone for noise removal. Two imaginary circles with this radius are drawn on bottom corners of the substrate. When extracting the coating layer, connected components not spanning over any of these circles are regarded as noise.

Other Parameters:
tempmatchtuple, optional

See CoatingLayerBase.

Examples

Construct the substrate instance first.

>>> ref_img = cv2.imread(get_sample_path("ref.png"), cv2.IMREAD_GRAYSCALE)
>>> ref = Reference(
...     cv2.threshold(ref_img, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1],
...     (10, 10, 1250, 200),
...     (100, 100, 1200, 500),
... )
>>> subst = RectSubstrate(ref, 3.0, 1.0, 0.01)

Construct the coating layer instance.

>>> target_img = cv2.imread(get_sample_path("coat.png"), cv2.IMREAD_GRAYSCALE)
>>> coat = RectIfdRoughness(
...     cv2.threshold(target_img, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1],
...     subst,
...     "arithmetic",
...     5.0,
...     (1, 1),
...     50,
... )

Visualize the coating layer.

>>> import matplotlib.pyplot as plt 
>>> plt.imshow(coat.draw()) 

(Source code, png, hires.png, pdf)

_images/index-1.png
DataType#

alias of RectIfdRoughnessData

valid()[source]#

Check if the coating layer is valid.

The coating layer is invalid if the capillary bridge is not ruptured.

Returns:
bool
extract_layer()[source]#

Extract the coating layer region from the target image.

Returns:
ndarray of bool

An array where the coating layer region is True. Has the same shape as image.

Notes

The following operations are performed to remove the error pixels:

  • Image opening with opening_ksize attribute.

  • Reconstruct connected components using reconstruct_radius and and substrate vertices.

substrate_contour()[source]#

Return substrate’s contour in image.

interface_indices()[source]#

Return indices of the substrate contour for the solid-liquid interface.

The interface points can be retrieved by slicing the substrate contour with there indices.

Returns:
ndarray

Starting and ending indices for the solid-liquid interface, empty if the interface does not exist.

See also

substrate_contour

The substrate contour which can be sliced.

Notes

The interface is detected by finding the points on the substrate contour which are adjacent to the points in extract_layer().

surface()[source]#

See IfdRoughnessBase.surface().

uniform_layer()[source]#

See IfdRoughnessBase.uniform_layer().

analyze()[source]#

Return analysis result.

Returns:
RectIfdRoughnessData
draw(pairs_dist=20.0)[source]#

Visualize the analysis result.

Draws the surface, the uniform layer, and the roughness pairs.

Parameters:
pairs_distfloat

Distance between the roughness pairs in the IFD parameter space. Decreasing this value increases the density of pairs.

class finitedepth_ifd.RectIfdRoughnessData(Roughness)[source]#

Analysis data for RectIfdRoughness.

Attributes:
Roughnessfloat

Coating layer roughness.

Indices and tables#