({{, (RefLink[CrossMatrix, paclet:ref/CrossMatrix])[r]
gives a matrix whose elements are 1 in a centered cross-shaped region that extends r positions along each index direction, and are 0 otherwise.}, {, (RefLink[CrossMatrix, paclet:ref/CrossMatrix])[r,w]
gives a w×w matrix containing a cross-shaped region of 1s.}, {, (RefLink[CrossMatrix, paclet:ref/CrossMatrix])[{(Subscript[r, 1]),(Subscript[r, 2]),…},…]
yields an array whose elements are 1 in a centered cross-shaped region that extends (Subscript[r, i]) positions in the i(^th) index direction.}})

OpenersNotesSection(Spacer1)Details

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

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

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

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

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

(RefLink[CrossMatrix, paclet:ref/CrossMatrix])[(RefLink[All, paclet:ref/All]),{(Subscript[w, 1]),…,(Subscript[w, n])}] gives a (Subscript[w, 1])×…×(Subscript[w, n]) array containing a cross-shaped region that is as large as possible.

Elements of (RefLink[CrossMatrix, paclet:ref/CrossMatrix])[r] are 1 if their edit distance from the center is not more than 1.

The parameter r need not be an integer; in an odd-dimensional array, the cross extends (RefLink[Floor, paclet:ref/Floor])[(RefLink[Abs, paclet:ref/Abs])[r+1/2]] pixels from the origin.

The lines of the cross have width 1 if the corresponding dimension is odd and width 2 otherwise.

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

This computes and plots a cross matrix:

ArrayPlot[CrossMatrix[5],Mesh->All]

OpenersExampleSection1(Spacer1)Scope  (5)

Create a rectangular cross matrix:

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

Specify the matrix size:

ArrayPlot[CrossMatrix[3,{11,11}],Mesh->All]

Extend the cross to the boundaries of the matrix:

ArrayPlot[CrossMatrix[All, {7,7}],Mesh->All]

Automatically choose an odd width to just fit the cross:

ArrayPlot[CrossMatrix[{5,5},{7,All}],Mesh->All]

Extend the cross to the given width and automatically choose the height:

ArrayPlot[CrossMatrix[{3,All},{All,8}],Mesh->All]

OpenersExampleSection3(Spacer1)Neat Examples  (1)

Graphics3D[Cuboid/@Position[CrossMatrix[All,{10,10,10}],1]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[DiamondMatrix, paclet:ref/DiamondMatrix])  ▪  (RefLink[DiskMatrix, paclet:ref/DiskMatrix])  ▪  (RefLink[BoxMatrix, paclet:ref/BoxMatrix])  ▪  (RefLink[SparseArray, paclet:ref/SparseArray])  ▪  (RefLink[Band, paclet:ref/Band])  ▪  (RefLink[EditDistance, paclet:ref/EditDistance])  ▪  (RefLink[ListConvolve, paclet:ref/ListConvolve])  ▪  (RefLink[ImageConvolve, paclet:ref/ImageConvolve])}})}})

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