cellprofiler-library-nightly 5.0.0.dev411__tar.gz → 5.0.0.dev413__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/PKG-INFO +1 -1
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/_version.py +3 -3
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/functions/image_processing.py +156 -1
- cellprofiler_library_nightly-5.0.0.dev413/cellprofiler_library/modules/_resize.py +50 -0
- cellprofiler_library_nightly-5.0.0.dev413/cellprofiler_library/opts/resize.py +22 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library_nightly.egg-info/PKG-INFO +1 -1
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library_nightly.egg-info/SOURCES.txt +2 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/LICENSE +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/README.md +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/__init__.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/functions/__init__.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/functions/file_processing.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/functions/measurement.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/functions/object_processing.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/functions/segmentation.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/__init__.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_closing.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_colortogray.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_combineobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_convertimagetoobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_convertobjectstoimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_correctilluminationapply.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_crop.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_dilateimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_dilateobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_enhanceedges.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_enhanceorsuppressfeatures.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_erodeimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_erodeobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_expandorshrinkobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_fillobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_gaussianfilter.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_measureimageoverlap.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_measureobjectsizeshape.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_medialaxis.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_medianfilter.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_morph.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_morphologicalskeleton.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_opening.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_overlayobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_overlayoutlines.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_reducenoise.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_removeholes.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_savecroppedobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_threshold.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/modules/_watershed.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/__init__.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/colortogray.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/convertimagetoobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/convertobjectstoimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/correctilluminationapply.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/crop.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/dilateimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/dilateobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/enhanceorsuppressfeatures.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/erodeimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/erodeobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/measureimageoverlap.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/morph.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/objectsizeshapefeatures.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/overlayoutlines.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/removeholes.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/structuring_elements.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/opts/threshold.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/py.typed +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library/types.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library_nightly.egg-info/dependency_links.txt +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library_nightly.egg-info/requires.txt +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/cellprofiler_library_nightly.egg-info/top_level.txt +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/environment.yml +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/pyproject.toml +0 -0
- {cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/setup.cfg +0 -0
{cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cellprofiler-library-nightly
|
|
3
|
-
Version: 5.0.0.
|
|
3
|
+
Version: 5.0.0.dev413
|
|
4
4
|
Summary: cellprofiler-library implements CellProfiler's image processing and mathematical code, and is usable as a standalone library
|
|
5
5
|
Author: Anne Carpenter, Thouis (Ray) Jones, Lee Kamentsky, Vebjorn Ljosa, David Logan, Mark Bray, Madison Swain-Bowden, Allen Goodman, Claire McQuinn, Alice Lucas, Callum Tromans-Coia
|
|
6
6
|
Author-email: Beth Cimini <bcimini@broadinstitute.org>, David Stirling <dstirling@glencoesoftware.com>, Nodar Gogoberidze <ngogober@broadinstitute.org>
|
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '5.0.0.
|
|
32
|
-
__version_tuple__ = version_tuple = (5, 0, 0, '
|
|
31
|
+
__version__ = version = '5.0.0.dev413'
|
|
32
|
+
__version_tuple__ = version_tuple = (5, 0, 0, 'dev413')
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'gd6becfb42'
|
|
@@ -3,21 +3,26 @@ import skimage.color
|
|
|
3
3
|
import skimage.morphology
|
|
4
4
|
import skimage.segmentation
|
|
5
5
|
import skimage.util
|
|
6
|
+
import skimage.transform
|
|
7
|
+
import skimage
|
|
8
|
+
import skimage.restoration
|
|
6
9
|
import centrosome
|
|
7
10
|
import centrosome.threshold
|
|
8
11
|
import centrosome.filter
|
|
9
12
|
import scipy
|
|
13
|
+
import scipy.interpolate
|
|
10
14
|
import matplotlib
|
|
11
15
|
import math
|
|
12
16
|
from numpy.typing import NDArray
|
|
13
17
|
import centrosome.filter
|
|
14
18
|
from typing import Any, Optional, Tuple, Callable, Union, List, TypeVar
|
|
15
|
-
from cellprofiler_library.types import ImageGrayscale, ImageGrayscaleMask, Image2DColor, Image2DGrayscale, ImageAny, ImageAnyMask, ObjectSegmentation, Image2D, Image2DMask, StructuringElement, ObjectLabelSet, ImageColor
|
|
19
|
+
from cellprofiler_library.types import ImageGrayscale, ImageGrayscaleMask, Image2DColor, Image2DGrayscale, ImageAny, ImageAnyMask, ObjectSegmentation, Image2D, Image2DMask, StructuringElement, ObjectLabelSet, ImageColor, ImageBinaryMask
|
|
16
20
|
from cellprofiler_library.opts import threshold as Threshold
|
|
17
21
|
from cellprofiler_library.opts.enhanceorsuppressfeatures import SpeckleAccuracy, NeuriteMethod
|
|
18
22
|
from cellprofiler_library.opts.overlayoutlines import BrightnessMode
|
|
19
23
|
from cellprofiler_library.opts.crop import RemovalMethod
|
|
20
24
|
from cellprofiler_library.opts.structuring_elements import StructuringElementShape2D, StructuringElementShape3D
|
|
25
|
+
from ..opts.resize import ResizingMethod, DimensionMethod, InterpolationMethod
|
|
21
26
|
|
|
22
27
|
T = TypeVar("T", bound=ImageAny)
|
|
23
28
|
MorphImageT = TypeVar("Union[ImageGrayscale, ImageGrayscaleMask]", bound=Union[ImageGrayscale, ImageGrayscaleMask])
|
|
@@ -221,6 +226,156 @@ def reduce_noise(image, patch_size, patch_distance, cutoff_distance, channel_axi
|
|
|
221
226
|
return denoised
|
|
222
227
|
|
|
223
228
|
|
|
229
|
+
################################################################################
|
|
230
|
+
# Resize Functions
|
|
231
|
+
################################################################################
|
|
232
|
+
|
|
233
|
+
def resized_shape(
|
|
234
|
+
im_pixel_data: ImageAny,
|
|
235
|
+
im_dimensions: int,
|
|
236
|
+
size_method: str,
|
|
237
|
+
resizing_factor_x: float,
|
|
238
|
+
resizing_factor_y: float,
|
|
239
|
+
resizing_factor_z: Optional[float],
|
|
240
|
+
use_manual_or_image: DimensionMethod,
|
|
241
|
+
specific_width: Optional[int],
|
|
242
|
+
specific_height: Optional[int],
|
|
243
|
+
specific_planes: Optional[int],
|
|
244
|
+
reference_image_shape: Optional[Tuple[int, ...]] = None,
|
|
245
|
+
) -> NDArray[numpy.int_]:
|
|
246
|
+
"""Calculate target dimensions based on resize method."""
|
|
247
|
+
im_volumetric = True if im_dimensions == 3 else False
|
|
248
|
+
im_multichannel = True if im_pixel_data.ndim > im_dimensions else False
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
shape = numpy.array(im_pixel_data.shape).astype(float)
|
|
252
|
+
|
|
253
|
+
if size_method == ResizingMethod.BY_FACTOR:
|
|
254
|
+
factor_x = resizing_factor_x
|
|
255
|
+
factor_y = resizing_factor_y
|
|
256
|
+
|
|
257
|
+
if im_volumetric:
|
|
258
|
+
assert resizing_factor_z is not None, "Z-axis scaling factor must be specified when resizing by factor"
|
|
259
|
+
factor_z = resizing_factor_z
|
|
260
|
+
height, width = shape[1:3]
|
|
261
|
+
planes = shape[0]
|
|
262
|
+
planes = numpy.round(planes * factor_z)
|
|
263
|
+
else:
|
|
264
|
+
height, width = shape[:2]
|
|
265
|
+
|
|
266
|
+
height = numpy.round(height * factor_y)
|
|
267
|
+
width = numpy.round(width * factor_x)
|
|
268
|
+
|
|
269
|
+
else:
|
|
270
|
+
if use_manual_or_image == DimensionMethod.MANUAL:
|
|
271
|
+
assert specific_height is not None, "Specific height must be specified when using manual dimensions"
|
|
272
|
+
assert specific_width is not None, "Specific width must be specified when using manual dimensions"
|
|
273
|
+
height = specific_height
|
|
274
|
+
width = specific_width
|
|
275
|
+
if im_volumetric:
|
|
276
|
+
assert specific_planes is not None, "Specific planes must be specified when using manual dimensions"
|
|
277
|
+
planes = specific_planes
|
|
278
|
+
else:
|
|
279
|
+
assert reference_image_shape is not None, "Reference image shape must be provided when using image-based dimensions"
|
|
280
|
+
|
|
281
|
+
if im_volumetric:
|
|
282
|
+
planes, height, width = reference_image_shape[:3]
|
|
283
|
+
else:
|
|
284
|
+
height, width = reference_image_shape[:2]
|
|
285
|
+
|
|
286
|
+
new_shape = []
|
|
287
|
+
|
|
288
|
+
if im_volumetric:
|
|
289
|
+
new_shape += [planes]
|
|
290
|
+
|
|
291
|
+
new_shape += [height, width]
|
|
292
|
+
|
|
293
|
+
if im_multichannel:
|
|
294
|
+
new_shape += [shape[-1]]
|
|
295
|
+
|
|
296
|
+
return numpy.asarray(new_shape)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def spline_order(interpolation_method: str) -> int:
|
|
300
|
+
"""Determine interpolation order from method."""
|
|
301
|
+
|
|
302
|
+
if interpolation_method == InterpolationMethod.NEAREST_NEIGHBOR:
|
|
303
|
+
return 0
|
|
304
|
+
|
|
305
|
+
if interpolation_method == InterpolationMethod.BILINEAR:
|
|
306
|
+
return 1
|
|
307
|
+
|
|
308
|
+
return 3
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def apply_resize(
|
|
312
|
+
im_pixel_data: ImageAny,
|
|
313
|
+
im_mask: ImageGrayscaleMask,
|
|
314
|
+
im_dimensions: int,
|
|
315
|
+
im_crop_mask: Optional[ImageGrayscaleMask],
|
|
316
|
+
size_method: str,
|
|
317
|
+
resizing_factor_x: float,
|
|
318
|
+
resizing_factor_y: float,
|
|
319
|
+
resizing_factor_z: Optional[float],
|
|
320
|
+
use_manual_or_image: DimensionMethod,
|
|
321
|
+
specific_width: Optional[int],
|
|
322
|
+
specific_height: Optional[int],
|
|
323
|
+
specific_planes: Optional[int],
|
|
324
|
+
reference_image_shape: Optional[Tuple[int, ...]] = None,
|
|
325
|
+
interpolation_method: str = "bilinear",
|
|
326
|
+
) -> Tuple[ImageAny, ImageGrayscaleMask, Optional[ImageBinaryMask]]:
|
|
327
|
+
|
|
328
|
+
new_shape = resized_shape(
|
|
329
|
+
im_pixel_data,
|
|
330
|
+
im_dimensions,
|
|
331
|
+
size_method,
|
|
332
|
+
resizing_factor_x,
|
|
333
|
+
resizing_factor_y,
|
|
334
|
+
resizing_factor_z,
|
|
335
|
+
use_manual_or_image,
|
|
336
|
+
specific_width,
|
|
337
|
+
specific_height,
|
|
338
|
+
specific_planes,
|
|
339
|
+
reference_image_shape,
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
order = spline_order(interpolation_method)
|
|
343
|
+
im_volumetric = True if im_dimensions == 3 else False
|
|
344
|
+
im_multichannel = True if im_pixel_data.ndim > im_dimensions else False
|
|
345
|
+
if im_volumetric and im_multichannel:
|
|
346
|
+
output_pixels = numpy.zeros(new_shape.astype(int), dtype=im_pixel_data.dtype)
|
|
347
|
+
|
|
348
|
+
for idx in range(int(new_shape[-1])):
|
|
349
|
+
output_pixels[:, :, :, idx] = skimage.transform.resize(
|
|
350
|
+
im_pixel_data[:, :, :, idx],
|
|
351
|
+
new_shape[:-1],
|
|
352
|
+
order=order,
|
|
353
|
+
mode="symmetric",
|
|
354
|
+
)
|
|
355
|
+
else:
|
|
356
|
+
output_pixels = skimage.transform.resize(
|
|
357
|
+
im_pixel_data, new_shape, order=order, mode="symmetric"
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
if im_multichannel and len(new_shape) > im_dimensions:
|
|
361
|
+
new_shape = new_shape[:-1]
|
|
362
|
+
|
|
363
|
+
mask = skimage.transform.resize(im_mask, new_shape, order=0, mode="constant")
|
|
364
|
+
|
|
365
|
+
mask = skimage.img_as_bool(mask)
|
|
366
|
+
|
|
367
|
+
if im_crop_mask is not None:
|
|
368
|
+
cropping = skimage.transform.resize(
|
|
369
|
+
im_crop_mask, new_shape, order=0, mode="constant"
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
cropping = skimage.img_as_bool(cropping)
|
|
373
|
+
else:
|
|
374
|
+
cropping = None
|
|
375
|
+
|
|
376
|
+
return output_pixels, mask, cropping
|
|
377
|
+
|
|
378
|
+
|
|
224
379
|
def get_threshold_robust_background(
|
|
225
380
|
image: ImageGrayscale,
|
|
226
381
|
lower_outlier_fraction: float = 0.05,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Resize module core functionality.
|
|
2
|
+
|
|
3
|
+
This module contains the extracted resize functions that implement
|
|
4
|
+
the core image resizing algorithms.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Annotated, Optional, Tuple
|
|
8
|
+
from pydantic import Field, validate_call, ConfigDict
|
|
9
|
+
|
|
10
|
+
from cellprofiler_library.types import ImageGrayscaleMask, ImageAny, ImageBinary
|
|
11
|
+
from cellprofiler_library.functions.image_processing import apply_resize
|
|
12
|
+
from cellprofiler_library.opts.resize import ResizingMethod, DimensionMethod, InterpolationMethod
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
|
|
16
|
+
def resize_image(
|
|
17
|
+
im_pixel_data: Annotated[ImageAny, Field(description="Input image pixel data array")],
|
|
18
|
+
im_mask: Annotated[ImageGrayscaleMask, Field(description="Input image mask")],
|
|
19
|
+
im_dimensions: Annotated[int, Field(description="Number of spatial dimensions in the image", ge=2, le=3)],
|
|
20
|
+
im_crop_mask: Annotated[Optional[ImageBinary], Field(description="Image crop mask")],
|
|
21
|
+
size_method: Annotated[ResizingMethod, Field(description="Method for determining resize dimensions")],
|
|
22
|
+
resizing_factor_x: Annotated[float, Field(description="X-axis scaling factor", gt=0)],
|
|
23
|
+
resizing_factor_y: Annotated[float, Field(description="Y-axis scaling factor", gt=0)],
|
|
24
|
+
resizing_factor_z: Annotated[Optional[float], Field(description="Z-axis scaling factor", gt=0)],
|
|
25
|
+
use_manual_or_image: Annotated[DimensionMethod, Field(description="Method for specifying dimensions")],
|
|
26
|
+
specific_width: Annotated[Optional[int], Field(description="Specific width in pixels", ge=1)],
|
|
27
|
+
specific_height: Annotated[Optional[int], Field(description="Specific height in pixels", ge=1)],
|
|
28
|
+
specific_planes: Annotated[Optional[int], Field(description="Specific number of planes", ge=1)],
|
|
29
|
+
reference_image_shape: Annotated[Optional[Tuple[int, ...]], Field(description="Shape of reference image for dimensions")],
|
|
30
|
+
interpolation_method: Annotated[InterpolationMethod, Field(description="Interpolation method for resizing")],
|
|
31
|
+
) -> Tuple[ImageAny, ImageGrayscaleMask, Optional[ImageBinary]]:
|
|
32
|
+
# Apply the resize operation using library
|
|
33
|
+
return apply_resize(
|
|
34
|
+
im_pixel_data,
|
|
35
|
+
im_mask,
|
|
36
|
+
im_dimensions,
|
|
37
|
+
im_crop_mask,
|
|
38
|
+
size_method,
|
|
39
|
+
resizing_factor_x,
|
|
40
|
+
resizing_factor_y,
|
|
41
|
+
resizing_factor_z,
|
|
42
|
+
use_manual_or_image,
|
|
43
|
+
specific_width,
|
|
44
|
+
specific_height,
|
|
45
|
+
specific_planes,
|
|
46
|
+
reference_image_shape,
|
|
47
|
+
interpolation_method,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Resize module enums and configuration options."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ResizingMethod(str, Enum):
|
|
7
|
+
"""Method for specifying resize dimensions."""
|
|
8
|
+
BY_FACTOR = "Resize by a fraction or multiple of the original size"
|
|
9
|
+
TO_SIZE = "Resize by specifying desired final dimensions"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DimensionMethod(str, Enum):
|
|
13
|
+
"""Method for specifying target dimensions when resizing to size."""
|
|
14
|
+
MANUAL = "Manual"
|
|
15
|
+
IMAGE = "Image"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class InterpolationMethod(str, Enum):
|
|
19
|
+
"""Interpolation method for resize operation."""
|
|
20
|
+
NEAREST_NEIGHBOR = "Nearest Neighbor"
|
|
21
|
+
BILINEAR = "Bilinear"
|
|
22
|
+
BICUBIC = "Bicubic"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cellprofiler-library-nightly
|
|
3
|
-
Version: 5.0.0.
|
|
3
|
+
Version: 5.0.0.dev413
|
|
4
4
|
Summary: cellprofiler-library implements CellProfiler's image processing and mathematical code, and is usable as a standalone library
|
|
5
5
|
Author: Anne Carpenter, Thouis (Ray) Jones, Lee Kamentsky, Vebjorn Ljosa, David Logan, Mark Bray, Madison Swain-Bowden, Allen Goodman, Claire McQuinn, Alice Lucas, Callum Tromans-Coia
|
|
6
6
|
Author-email: Beth Cimini <bcimini@broadinstitute.org>, David Stirling <dstirling@glencoesoftware.com>, Nodar Gogoberidze <ngogober@broadinstitute.org>
|
|
@@ -40,6 +40,7 @@ cellprofiler_library/modules/_overlayobjects.py
|
|
|
40
40
|
cellprofiler_library/modules/_overlayoutlines.py
|
|
41
41
|
cellprofiler_library/modules/_reducenoise.py
|
|
42
42
|
cellprofiler_library/modules/_removeholes.py
|
|
43
|
+
cellprofiler_library/modules/_resize.py
|
|
43
44
|
cellprofiler_library/modules/_savecroppedobjects.py
|
|
44
45
|
cellprofiler_library/modules/_threshold.py
|
|
45
46
|
cellprofiler_library/modules/_watershed.py
|
|
@@ -59,6 +60,7 @@ cellprofiler_library/opts/morph.py
|
|
|
59
60
|
cellprofiler_library/opts/objectsizeshapefeatures.py
|
|
60
61
|
cellprofiler_library/opts/overlayoutlines.py
|
|
61
62
|
cellprofiler_library/opts/removeholes.py
|
|
63
|
+
cellprofiler_library/opts/resize.py
|
|
62
64
|
cellprofiler_library/opts/structuring_elements.py
|
|
63
65
|
cellprofiler_library/opts/threshold.py
|
|
64
66
|
cellprofiler_library_nightly.egg-info/PKG-INFO
|
{cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/LICENSE
RENAMED
|
File without changes
|
{cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/README.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cellprofiler_library_nightly-5.0.0.dev411 → cellprofiler_library_nightly-5.0.0.dev413}/setup.cfg
RENAMED
|
File without changes
|