({{, (RefLink[BoxMatrix, paclet:ref/BoxMatrix])[r] 
gives a (2 r+1)×(2r+1) matrix of 1s.}, {, (RefLink[BoxMatrix, paclet:ref/BoxMatrix])[r,w]
gives a (2 r+1)×(2r+1) block of 1s centered in a w×w matrix of 0s.}, {, (RefLink[BoxMatrix, paclet:ref/BoxMatrix])[{(Subscript[r, 1]),(Subscript[r, 2]),…},…]
gives a (2 (Subscript[r, 1])+1)× (2 (Subscript[r, 2])+1) ×… array of 1s.}})

OpenersNotesSection(Spacer1)Details

(RefLink[BoxMatrix, paclet:ref/BoxMatrix])[r] gives a square pattern of 1s extending r positions from the center.

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

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

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

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

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

This computes and plots a box:

ArrayPlot[BoxMatrix[3],Mesh->All]

OpenersExampleSection1(Spacer1)Scope  (4)

Put a box inside a bigger matrix:

ArrayPlot[BoxMatrix[2,{9,9}],Mesh->All]

Extend the box to the boundaries of the matrix:

ArrayPlot[BoxMatrix[All,{8,8}],Mesh->All]

Automatically choose a width to just fit the box matrix:

ArrayPlot[BoxMatrix[{1,1},{5,All}],Mesh->All]

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

ArrayPlot[BoxMatrix[{2,All},{All,6}],Mesh->All]

OpenersExampleSection3(Spacer1)Neat Examples  (1)

Graphics3D[Cuboid/@Position[BoxMatrix[All,{5,5,5}],1]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ConstantArray, paclet:ref/ConstantArray])  ▪  (RefLink[CenterArray, paclet:ref/CenterArray])  ▪  (RefLink[DiamondMatrix, paclet:ref/DiamondMatrix])  ▪  (RefLink[CrossMatrix, paclet:ref/CrossMatrix])  ▪  (RefLink[DiskMatrix, paclet:ref/DiskMatrix])  ▪  (RefLink[CornerNeighbors, paclet:ref/CornerNeighbors])  ▪  (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])}})}})