({{, (RefLink[DiskMatrix, paclet:ref/DiskMatrix])[r] 
gives a matrix whose elements are 1 in a disk-shaped region of radius r, and are otherwise 0.}, {, (RefLink[DiskMatrix, paclet:ref/DiskMatrix])[r,w]
gives a w×w matrix containing a disk of 1s with radius r.}, {, (RefLink[DiskMatrix, paclet:ref/DiskMatrix])[{(Subscript[r, 1]),(Subscript[r, 2]),…},…]
yields an array whose elements are 1 in an ellipsoidal region with semiaxis (Subscript[r, i]) in the i(^th) index direction.}})

OpenersNotesSection(Spacer1)Details and Options

The disk of 1s is always at the center of the region.

In (RefLink[DiskMatrix, paclet:ref/DiskMatrix])[r] or (RefLink[DiskMatrix, paclet:ref/DiskMatrix])[{(Subscript[r, 1]),…}] the matrix or array is sized so as to just include all nonzero elements.

The disk-like region is taken to be the best discrete approximation to a circular disk possible given the size of the matrix.

(RefLink[DiskMatrix, paclet:ref/DiskMatrix])[(RefLink[All, paclet:ref/All]),w] gives a w×w matrix containing a disk that is as large as possible.

(RefLink[DiskMatrix, paclet:ref/DiskMatrix])[…,{(Subscript[w, 1]),(Subscript[w, 2]),…}] gives a (Subscript[w, 1])×(Subscript[w, 2])×… array.

(RefLink[DiskMatrix, paclet:ref/DiskMatrix])[{(Subscript[r, 1]),…,(Subscript[r, n])},w] gives a w×…×w array.

(RefLink[DiskMatrix, paclet:ref/DiskMatrix])[(RefLink[All, paclet:ref/All]),{(Subscript[w, 1]),…,(Subscript[w, n])}] gives a (Subscript[w, 1])×…×(Subscript[w, n]) array containing an ellipsoid that is as large as possible.

The radius r need not be an integer; in general elements are 1 if their distance from the center is not more than |r+1/2|.

For integer r, (RefLink[DiskMatrix, paclet:ref/DiskMatrix])[r] yields a (2r+1)×(2r+1) matrix.

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

This computes and plots a square disk-shaped matrix of radius 7:

ArrayPlot[DiskMatrix[7] ,Mesh->All]

OpenersExampleSection1(Spacer1)Scope  (6)

Create a square matrix:

ArrayPlot[DiskMatrix[10] ,Mesh->All]

Create a rectangular ellipse-shaped matrix:

ArrayPlot[DiskMatrix[{5,15}] ,Mesh->All]

Put a disk inside a bigger matrix:

ArrayPlot[DiskMatrix[8,{23,23}],Mesh->All]

Extend the disk to the boundaries of the matrix:

ArrayPlot[DiskMatrix[All, {23,35}],Mesh->All]

Automatically choose an odd width to just fit the disk:

ArrayPlot[DiskMatrix[{5,11},{13,All}],Mesh->All]

Extend the disk to the given width, and automatically choose the height:

ArrayPlot[DiskMatrix[{12,All},{All,36}],Mesh->All]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[DiamondMatrix, paclet:ref/DiamondMatrix])  ▪  (RefLink[CrossMatrix, paclet:ref/CrossMatrix])  ▪  (RefLink[GaussianMatrix, paclet:ref/GaussianMatrix])  ▪  (RefLink[BoxMatrix, paclet:ref/BoxMatrix])  ▪  (RefLink[SparseArray, paclet:ref/SparseArray])  ▪  (RefLink[Norm, paclet:ref/Norm])  ▪  (RefLink[ListConvolve, paclet:ref/ListConvolve])  ▪  (RefLink[ImageConvolve, paclet:ref/ImageConvolve])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Structure Matrices & Convolution Kernels, paclet:guide/StructureMatricesAndConvolutionKernels])}, {▪(RefLinkPlain[Image Filtering & Neighborhood Processing, paclet:guide/ImageFilteringAndNeighborhoodProcessing])}, {▪(RefLinkPlain[Linear and Nonlinear Filters, paclet:guide/LinearAndNonlinearFilters])}, {▪(RefLinkPlain[Constructing Matrices, paclet:guide/ConstructingMatrices])}})}})