Prefer row/col to r/c when talking about circles

This commit is contained in:
Juan Nunez-Iglesias
2014-12-31 15:16:00 +11:00
parent ad2b02b865
commit 9c770dbdf2
+6 -4
View File
@@ -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