1111import numpy as np
1212
1313from cucim .skimage import morphology
14- from cucim .skimage ._shared .utils import deprecate_func
1514
1615# Precomputed ball and disk decompositions were saved as 2D arrays where the
1716# radius of the desired decomposition is used to index into the first axis of
@@ -223,71 +222,6 @@ def partial_footprint(dim, width):
223222 return footprint
224223
225224
226- @deprecate_func (
227- deprecated_version = "25.02" ,
228- removed_version = "25.08" ,
229- hint = "Use `cucim.skimage.morphology.footprint_rectangle` instead." ,
230- )
231- def square (width , dtype = None , * , decomposition = None ):
232- """Generates a flat, square-shaped footprint.
233-
234- Every pixel along the perimeter has a chessboard distance
235- no greater than radius (radius=floor(width/2)) pixels.
236-
237- Parameters
238- ----------
239- width : int
240- The width and height of the square.
241-
242- Other Parameters
243- ----------------
244- dtype : data-type or None, optional
245- The data type of the footprint. When None, a tuple will be returned in
246- place of the actual footprint array. This can be be passed to grayscale
247- and binary morphology functions in place of an explicit array to avoid
248- array allocation overhead.
249- decomposition : {None, 'separable', 'sequence'}, optional
250- If None, a single array is returned. For 'sequence', a tuple of smaller
251- footprints is returned. Applying this series of smaller footprints will
252- give an identical result to a single, larger footprint, but often with
253- better computational performance. See Notes for more details.
254- With 'separable', this function uses separable 1D footprints for each
255- axis. Whether 'sequence' or 'separable' is computationally faster may
256- be architecture-dependent.
257-
258- Returns
259- -------
260- footprint : cupy.ndarray
261- The footprint where elements of the neighborhood are 1 and 0 otherwise.
262- When `decomposition` is None, this is just a numpy.ndarray. Otherwise,
263- this will be a tuple whose length is equal to the number of unique
264- structuring elements to apply (see Notes for more detail)
265-
266- Notes
267- -----
268- When `decomposition` is not None, each element of the `footprint`
269- tuple is a 2-tuple of the form ``(ndarray, num_iter)`` that specifies a
270- footprint array and the number of iterations it is to be applied.
271-
272- For binary morphology, using ``decomposition='sequence'`` or
273- ``decomposition='separable'`` were observed to give better performance than
274- ``decomposition=None``, with the magnitude of the performance increase
275- rapidly increasing with footprint size. For grayscale morphology with
276- square footprints, it is recommended to use ``decomposition=None`` since
277- the internal SciPy functions that are called already have a fast
278- implementation based on separable 1D sliding windows.
279-
280- The 'sequence' decomposition mode only supports odd valued `width`. If
281- `width` is even, the sequence used will be identical to the 'separable'
282- mode.
283-
284- """
285- footprint = footprint_rectangle (
286- shape = (width , width ), dtype = dtype , decomposition = decomposition
287- )
288- return footprint
289-
290-
291225def _decompose_size (size , kernel_size = 3 ):
292226 """Determine number of repeated iterations for a `kernel_size` kernel.
293227
@@ -301,75 +235,6 @@ def _decompose_size(size, kernel_size=3):
301235 return 1 + (size - kernel_size ) // (kernel_size - 1 )
302236
303237
304- @deprecate_func (
305- deprecated_version = "25.02" ,
306- removed_version = "25.08" ,
307- hint = "Use `cucim.skimage.morphology.footprint_rectangle` instead." ,
308- )
309- def rectangle (nrows , ncols , dtype = None , * , decomposition = None ):
310- """Generates a flat, rectangular-shaped footprint.
311-
312- Every pixel in the rectangle generated for a given width and given height
313- belongs to the neighborhood.
314-
315- Parameters
316- ----------
317- nrows : int
318- The number of rows of the rectangle.
319- ncols : int
320- The number of columns of the rectangle.
321-
322- Other Parameters
323- ----------------
324- dtype : data-type or None, optional
325- The data type of the footprint. When None, a tuple will be returned in
326- place of the actual footprint array. This can be be passed to grayscale
327- and binary morphology functions in place of an explicit array to avoid
328- array allocation overhead.
329- decomposition : {None, 'separable', 'sequence'}, optional
330- If None, a single array is returned. For 'sequence', a tuple of smaller
331- footprints is returned. Applying this series of smaller footprints will
332- given an identical result to a single, larger footprint, but often with
333- better computational performance. See Notes for more details.
334- With 'separable', this function uses separable 1D footprints for each
335- axis. Whether 'seqeunce' or 'separable' is computationally faster may
336- be architecture-dependent.
337-
338- Returns
339- -------
340- footprint : cupy.ndarray
341- A footprint consisting only of ones, i.e. every pixel belongs to the
342- neighborhood. When `decomposition` is None, this is just a
343- numpy.ndarray. Otherwise, this will be a tuple whose length is equal to
344- the number of unique structuring elements to apply (see Notes for more
345- detail)
346-
347- Notes
348- -----
349- When `decomposition` is not None, each element of the `footprint`
350- tuple is a 2-tuple of the form ``(ndarray, num_iter)`` that specifies a
351- footprint array and the number of iterations it is to be applied.
352-
353- For binary morphology, using ``decomposition='sequence'``
354- was observed to give better performance, with the magnitude of the
355- performance increase rapidly increasing with footprint size. For grayscale
356- morphology with rectangular footprints, it is recommended to use
357- ``decomposition=None`` since the internal SciPy functions that are called
358- already have a fast implementation based on separable 1D sliding windows.
359-
360- The `sequence` decomposition mode only supports odd valued `nrows` and
361- `ncols`. If either `nrows` or `ncols` is even, the sequence used will be
362- identical to ``decomposition='separable'``.
363-
364- - The use of ``width`` and ``height`` has been deprecated in
365- version 0.18.0. Use ``nrows`` and ``ncols`` instead.
366- """
367- footprint = footprint_rectangle (
368- shape = (nrows , ncols ), dtype = dtype , decomposition = decomposition
369- )
370- return footprint
371-
372-
373238def diamond (radius , dtype = cp .uint8 , * , decomposition = None ):
374239 """Generates a flat, diamond-shaped footprint.
375240
@@ -768,67 +633,6 @@ def ellipse(width, height, dtype=cp.uint8, *, decomposition=None):
768633 return sequence
769634
770635
771- @deprecate_func (
772- deprecated_version = "25.02" ,
773- removed_version = "25.08" ,
774- hint = "Use `cucim.skimage.morphology.footprint_rectangle` instead." ,
775- )
776- def cube (width , dtype = None , * , decomposition = None ):
777- """Generates a cube-shaped footprint.
778-
779- This is the 3D equivalent of a square.
780- Every pixel along the perimeter has a chessboard distance
781- no greater than radius (radius=floor(width/2)) pixels.
782-
783- Parameters
784- ----------
785- width : int
786- The width, height and depth of the cube.
787-
788- Other Parameters
789- ----------------
790- dtype : data-type or None, optional
791- The data type of the footprint. When None, a tuple will be returned in
792- place of the actual footprint array. This can be be passed to grayscale
793- and binary morphology functions in place of an explicit array to avoid
794- array allocation overhead.
795- decomposition : {None, 'separable', 'sequence'}, optional
796- If None, a single array is returned. For 'sequence', a tuple of smaller
797- footprints is returned. Applying this series of smaller footprints will
798- given an identical result to a single, larger footprint, but often with
799- better computational performance. See Notes for more details.
800-
801- Returns
802- -------
803- footprint : cupy.ndarray
804- The footprint where elements of the neighborhood are 1 and 0 otherwise.
805- When `decomposition` is None, this is just a numpy.ndarray. Otherwise,
806- this will be a tuple whose length is equal to the number of unique
807- structuring elements to apply (see Notes for more detail)
808-
809- Notes
810- -----
811- When `decomposition` is not None, each element of the `footprint`
812- tuple is a 2-tuple of the form ``(ndarray, num_iter)`` that specifies a
813- footprint array and the number of iterations it is to be applied.
814-
815- For binary morphology, using ``decomposition='sequence'``
816- was observed to give better performance, with the magnitude of the
817- performance increase rapidly increasing with footprint size. For grayscale
818- morphology with square footprints, it is recommended to use
819- ``decomposition=None`` since the internal SciPy functions that are called
820- already have a fast implementation based on separable 1D sliding windows.
821-
822- The 'sequence' decomposition mode only supports odd valued `width`. If
823- `width` is even, the sequence used will be identical to the 'separable'
824- mode.
825- """
826- footprint = footprint_rectangle (
827- shape = (width , width , width ), dtype = dtype , decomposition = decomposition
828- )
829- return footprint
830-
831-
832636def octahedron (radius , dtype = cp .uint8 , * , decomposition = None ):
833637 """Generates a octahedron-shaped footprint.
834638
0 commit comments