Skip to content

Commit 0007ad0

Browse files
committed
Add image cropping to reduce script run time
1 parent 7836ba5 commit 0007ad0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

docs/ops/doc/examples/labeling_mesh.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ In addition to the result tables, the label imdage (also known as an *index imag
8282

8383
The output label image with "3-3-2 RGB" LUTs applied in Fiji.
8484

85-
**Please note that this script can take upwards of 2-3 minutes to run!**
86-
8785
.. tabs::
8886

8987
.. code-tab:: python
@@ -110,7 +108,8 @@ In addition to the result tables, the label imdage (also known as an *index imag
110108

111109
from org.scijava.table import DefaultGenericTable
112110

113-
111+
from jarray import array
112+
114113
def extract_channel(image, ch):
115114
"""Extract a channel from the input image.
116115

@@ -214,10 +213,17 @@ In addition to the result tables, the label imdage (also known as an *index imag
214213

215214
return out
216215

216+
# crop the input data to a 450 x 450 patch
217+
min_arr = array([370, 136, 0, 0], "l")
218+
max_arr = array([819, 585, 2, 59], "l")
219+
img_crop = ops.op("transform.intervalView").input(img, min_arr, max_arr).apply()
220+
img_crop = Views.dropSingletonDimensions(img_crop)
221+
img_crop = ops.op("transform.offsetView").input(img_crop, array([370, 136, 0, 0], "l")).apply()
222+
217223
# extract channels
218-
ch_a_img = extract_channel(img, ch_a)
219-
ch_b_img = extract_channel(img, ch_b)
220-
224+
ch_a_img = extract_channel(img_crop, ch_a)
225+
ch_b_img = extract_channel(img_crop, ch_b)
226+
221227
# customize the following sections below for your own data
222228
# clean up channel "A" and create a mask
223229
ch_a_img = gaussian_subtraction(ch_a_img, 8.0)

0 commit comments

Comments
 (0)