22Common Utilities
33================
44
5- Define the common utilities objects that don't fall in any specific category .
5+ Define common utility objects that support colour checker detection algorithms .
66
77References
88----------
180180
181181def as_int32_array (a : ArrayLike ) -> NDArrayInt :
182182 """
183- Convert given variable :math:`a` to :class:`numpy.ndarray` using
183+ Convert specified variable :math:`a` to :class:`numpy.ndarray` using
184184 `np.int32` :class:`numpy.dtype`.
185185
186186 Parameters
@@ -205,7 +205,7 @@ def as_int32_array(a: ArrayLike) -> NDArrayInt:
205205
206206def as_float32_array (a : ArrayLike ) -> NDArrayFloat :
207207 """
208- Convert given variable :math:`a` to :class:`numpy.ndarray` using
208+ Convert specified variable :math:`a` to :class:`numpy.ndarray` using
209209 `np.float32` :class:`numpy.dtype`.
210210
211211 Parameters
@@ -236,7 +236,7 @@ def swatch_masks(
236236 samples : int ,
237237) -> NDArrayInt :
238238 """
239- Return swatch masks for given image width and height and swatches count.
239+ Return swatch masks for specified image width and height and swatches count.
240240
241241 Parameters
242242 ----------
@@ -293,7 +293,7 @@ def swatch_masks(
293293
294294def swatch_colours (image : ArrayLike , masks : ArrayLike ) -> NDArrayFloat :
295295 """
296- Extract the swatch colours from given image using given masks.
296+ Extract the swatch colours from specified image using specified masks.
297297
298298 Parameters
299299 ----------
@@ -356,8 +356,8 @@ def reformat_image(
356356 ] = cv2 .INTER_CUBIC ,
357357) -> NDArrayReal :
358358 """
359- Reformat given image so that it is horizontal and resizes it to given target
360- width.
359+ Reformat specified image so that it is horizontal and resizes it to specified
360+ target width.
361361
362362 Parameters
363363 ----------
@@ -452,7 +452,7 @@ def transform_image(
452452 ] = cv2 .INTER_CUBIC ,
453453) -> NDArrayReal :
454454 """
455- Transform given image using given translation, rotation and scale values.
455+ Transform specified image using specified translation, rotation and scale values.
456456
457457 The transformation is performed relatively to the image center and in the
458458 following order:
@@ -552,7 +552,7 @@ def transform_image(
552552 transform += as_float32_array ([[0 , 0 , t_x ], [0 , 0 , t_y ]])
553553
554554 return cast (
555- NDArrayReal ,
555+ " NDArrayReal" ,
556556 cv2 .warpAffine (
557557 image ,
558558 transform ,
@@ -567,7 +567,7 @@ def detect_contours(
567567 image : ArrayLike , additional_data : bool = False , ** kwargs : Any
568568) -> Tuple [NDArrayInt ] | Tuple [Tuple [NDArrayInt ], NDArrayReal ]:
569569 """
570- Detect the contours of given image using given settings.
570+ Detect the contours of specified image using specified settings.
571571
572572 The process is a follows:
573573
@@ -650,14 +650,14 @@ def detect_contours(
650650 iterations = settings .convolution_iterations ,
651651 )
652652
653- image_k = cast (NDArrayReal , image_k )
653+ image_k = cast (" NDArrayReal" , image_k )
654654
655655 # Detecting contours.
656656 contours , _hierarchy = cv2 .findContours (
657657 image_k , cv2 .RETR_TREE , cv2 .CHAIN_APPROX_NONE
658658 )
659659
660- contours = cast (Tuple [NDArrayInt ], contours )
660+ contours = cast (" Tuple[NDArrayInt]" , contours )
661661
662662 if additional_data :
663663 return contours , image_k
@@ -666,7 +666,7 @@ def detect_contours(
666666
667667def is_square (contour : ArrayLike , tolerance : float = 0.015 ) -> bool :
668668 """
669- Return if given contour is a square.
669+ Return if specified contour is a square.
670670
671671 Parameters
672672 ----------
@@ -678,7 +678,7 @@ def is_square(contour: ArrayLike, tolerance: float = 0.015) -> bool:
678678 Returns
679679 -------
680680 :class:`bool`
681- Whether given contour is a square.
681+ Whether specified contour is a square.
682682
683683 Examples
684684 --------
@@ -703,7 +703,7 @@ def is_square(contour: ArrayLike, tolerance: float = 0.015) -> bool:
703703
704704def contour_centroid (contour : ArrayLike ) -> Tuple [float , float ]:
705705 """
706- Return the centroid of given contour.
706+ Return the centroid of specified contour.
707707
708708 Parameters
709709 ----------
@@ -739,7 +739,7 @@ def contour_centroid(contour: ArrayLike) -> Tuple[float, float]:
739739
740740def scale_contour (contour : ArrayLike , factor : ArrayLike ) -> NDArrayFloat :
741741 """
742- Scale given contour by given scale factor.
742+ Scale specified contour by specified scale factor.
743743
744744 Parameters
745745 ----------
@@ -779,7 +779,7 @@ def approximate_contour(
779779 contour : ArrayLike , points : int = 4 , iterations : int = 100
780780) -> NDArrayInt :
781781 """
782- Approximate given contour to have given number of points.
782+ Approximate specified contour to have specified number of points.
783783
784784 The process uses binary search to find the best *epsilon* value
785785 producing a contour approximation with exactly ``points``.
@@ -827,7 +827,7 @@ def approximate_contour(
827827 contour , center * cv2 .arcLength (contour , True ), True
828828 )
829829
830- approximation = cast (NDArrayInt , approximation )
830+ approximation = cast (" NDArrayInt" , approximation )
831831
832832 if len (approximation ) > points :
833833 low = (low + high ) / 2
@@ -839,7 +839,7 @@ def approximate_contour(
839839
840840def quadrilateralise_contours (contours : ArrayLike ) -> Tuple [NDArrayInt , ...]:
841841 """
842- Convert given to quadrilaterals.
842+ Convert specified contours to quadrilaterals.
843843
844844 Parameters
845845 ----------
@@ -880,7 +880,7 @@ def remove_stacked_contours(
880880 contours : ArrayLike , keep_smallest : bool = True
881881) -> Tuple [NDArrayInt , ...]:
882882 """
883- Remove amd filter out the stacked contours from given contours keeping
883+ Remove and filter out the stacked contours from specified contours keeping
884884 either the smallest or the largest ones.
885885
886886 Parameters
@@ -999,8 +999,8 @@ def sample_colour_checker(
999999 ** kwargs : Any ,
10001000) -> DataDetectionColourChecker :
10011001 """
1002- Sample the colour checker using the given source quadrilateral, i.e.,
1003- detected colour checker in the image, and the given target rectangle.
1002+ Sample the colour checker using the specified source quadrilateral, i.e.,
1003+ detected colour checker in the image, and the specified target rectangle.
10041004
10051005 Parameters
10061006 ----------
@@ -1155,7 +1155,7 @@ def sample_colour_checker(
11551155 colour_checker = colour_checker_candidate
11561156 quadrilateral = candidate_quadrilateral
11571157
1158- colour_checker = cast (NDArrayFloat , colour_checker )
1158+ colour_checker = cast (" NDArrayFloat" , colour_checker )
11591159
11601160 return DataDetectionColourChecker (
11611161 sampled_colours , masks , colour_checker , quadrilateral
0 commit comments