mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-06 05:16:40 +08:00
Prefer row/col to r/c when talking about circles
This commit is contained in:
@@ -74,9 +74,11 @@ of same shape as the image (or a shape broadcastable to the image shape).
|
||||
This can be useful to define a region of interest, such as a
|
||||
disk: ::
|
||||
|
||||
>>> l_r, l_c = camera.shape
|
||||
>>> R, C = np.ogrid[:l_r, :l_c]
|
||||
>>> outer_disk_mask = (R - l_r / 2)**2 + (C - l_c / 2)**2 < (l_r / 2)**2
|
||||
>>> nrows, ncols = camera.shape
|
||||
>>> row, col = np.ogrid[:nrows, :ncols]
|
||||
>>> cnt_row, cnt_col = nrows / 2, ncols / 2
|
||||
>>> outer_disk_mask = ((row - cnt_row)**2 + (col - cnt_col)**2 <
|
||||
... (nrows / 2)**2)
|
||||
>>> camera[outer_disk_mask] = 0
|
||||
|
||||
.. image:: ../../_images/plot_camera_numpy_1.png
|
||||
@@ -85,7 +87,7 @@ disk: ::
|
||||
|
||||
Boolean arithmetic can be used to define more complex masks: ::
|
||||
|
||||
>>> lower_half = R > l_r / 2
|
||||
>>> lower_half = row > cnt_row
|
||||
>>> lower_half_disk = np.logical_and(lower_half, outer_disk_mask)
|
||||
>>> camera = data.camera()
|
||||
>>> camera[lower_half_disk] = 0
|
||||
|
||||
Reference in New Issue
Block a user