({{, (RefLink[ArrayResample, paclet:ref/ArrayResample])[array,{(Subscript[n, 1]),(Subscript[n, 2]),…}]
resamples array to have dimensions {(Subscript[n, 1]),(Subscript[n, 2]),…}.}, {, (RefLink[ArrayResample, paclet:ref/ArrayResample])[array,dspec] 
resamples array according to the dimension specification dspec.}, {, (RefLink[ArrayResample, paclet:ref/ArrayResample])[array,dspec,scheme]
specifies resampling scheme, either point or bin based. }, {, (RefLink[ArrayResample, paclet:ref/ArrayResample])[array,dspec,scheme,{{(Subscript[x, min]),(Subscript[x, max])},…}]
resamples only the data in the specified subrange {{(Subscript[x, min]),(Subscript[x, max])},…}.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ArrayResample, paclet:ref/ArrayResample]) can be used for resampling data arrays based on a large selection of interpolation and approximation models.

(RefLink[ArrayResample, paclet:ref/ArrayResample]) works with data arrays of any depth.

The dimension specification dspec can be of the form:

For a multidimensional array, the notation n is taken to be equivalent to {n,(RefLink[Automatic, paclet:ref/Automatic]),…} and {n} equivalent to {n,(RefLink[All, paclet:ref/All]),…}.

The dimension ratios for an array of dimensions {(Subscript[d, 1]),(Subscript[d, 2]),(Subscript[d, 3]),…} is taken to be {1,(Subscript[d, 2])/(Subscript[d, 1]),(Subscript[d, 3])/(Subscript[d, 1]),…}.

The scheme determines the location of sample and resample positions and can be of the form:

For input data of length n the "Point" resampling scheme assumes a data range from 1 to n and the "Bin" scheme assumes a data range from 0 to n with the alignment indicating the sample location within each bin.

Bin alignment alignment can be (RefLink[Left, paclet:ref/Left]), (RefLink[Center, paclet:ref/Center]), (RefLink[Right, paclet:ref/Right]) or any number between -1 ((RefLink[Left, paclet:ref/Left])) and 1 ((RefLink[Right, paclet:ref/Right])).

The data range can be modified using the (RefLink[DataRange, paclet:ref/DataRange]) option.

By default, the data is resampled on the entire data domain, ranging from 1 to n for the "Point" scheme and from 0 to n for the "Bin" scheme. Use the (RefLink[DataRange, paclet:ref/DataRange]) option to modify the coordinates of the data domain.

With a subrange {{(Subscript[x, min]),(Subscript[x, max])},…} specified with respect to the (RefLink[DataRange, paclet:ref/DataRange]), only the data values in the given interval are resampled.  »

The following options can be given:

For possible settings for (RefLink[Padding, paclet:ref/Padding]), see the reference page for (RefLink[ArrayPad, paclet:ref/ArrayPad]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (19)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Subsample an array:

ArrayResample[{1,2,3,4,5},9]

Downsample an array:

ArrayResample[{1,2,3,4,5},3]

Resize a 2D array of data:

ArrayResample[(({{1, 2, 3}, {2, 3, 4}, {3, 4, 5}})),6]//MatrixForm

OpenersExampleSection1(Spacer1)Scope  (8)

OpenersExampleSubsection0(Spacer1)Basic Uses  (4)

Exact computation:

ArrayResample[{1,2,3},4]

Precision of the input is preserved:

ArrayResample[{1.0000000000000000000,2.0000000000000000000,3.0000000000000000000,4.0000000000000000000},6]

Resizing a symbolic array:

ArrayResample[{a,b,c},5]

Resample a subdomain of the input signal:

input=Range[100];

ArrayResample[input,20,"Point",{55,63}]

OpenersExampleSubsection1(Spacer1)Output Dimensions  (1)

With size specified as a scalar, output dimension is selected such that dimension ratio is preserved:

ArrayResample[(({{1, 2, 3}, {4, 5, 6}})),4]//MatrixForm

Dimensions[%]

OpenersExampleSubsection2(Spacer1)Sampling Schemes  (3)

By default, the "Point" sampling scheme is used:

ArrayResample[{1,2,3},7,"Point"]

Use the "Bin" scheme, which uses center alignment by default:

ArrayResample[{1,2,3},6,"Bin"]

Specify the alignment of the bins:

ArrayResample[{1,2,3},6,{"Bin",-1}]

Generate a "Point" resampling with three times the input resolution:

input={2,1,3,4,2,5};
m=Length[input];
s=3;
res1=ArrayResample[input,Scaled[s]]

Compute the sampling positions:

pos=Range[1,m,(m-1)/Round[s (m-1)]]

ListPlot[{Thread[{Range[m],input}],Thread[{pos,res1}]},Joined->{True,False},PlotStyle->{PointSize[.04],Automatic},Mesh->All]

OpenersExampleSection3(Spacer1)Options  (5)

OpenersExampleSubsection3(Spacer1)Antialiasing  (1)

When downsampling, by default no antialiasing is happening:

data = {2,1,2,1,2,1,2};

ArrayResample[data,Scaled[1/2],Padding-> "Reflected"]

With antialiasing, all samples that fall in between new samples are averaged:

ArrayResample[data,Scaled[1/2],Padding-> "Reflected",Antialiasing->True]

OpenersExampleSubsection4(Spacer1)DataRange  (1)

(RefLink[DataRange, paclet:ref/DataRange]) specifies the domain of resampling. Subrange specification is defined with respect to this domain:

data = {0,2,0,1,4,1,9,4,4};

Resample the whole data:

ArrayResample[data,Scaled[2],"Point"]

Resample the first half using default (RefLink[DataRange, paclet:ref/DataRange])->{1,n}, where n is the length of data:

ArrayResample[data,Scaled[2],"Point",{1,5}]

Resample the first half of the data using a {0,1} data range:

ArrayResample[data,Scaled[2],"Point",{0,1/2},DataRange->{0,1}]

OpenersExampleSubsection5(Spacer1)Padding  (2)

The default padding value is "Fixed":

ArrayResample[{1,2,3},9,"Bin"]

Specify a different padding:

ArrayResample[{1,2,3},9,"Bin",Padding->0]

By default, the same padding is used for all dimensions:

ArrayResample[(({{1, 2, 3}, {2, 1, 6}, {3, 6, 2}})),5,Resampling->"Cubic",Padding->0]//N//MatrixForm

Use different paddings for different dimensions:

ArrayResample[(({{1, 2, 3}, {2, 1, 6}, {3, 6, 2}})),5,Resampling->"Cubic",Padding->{0,"Fixed"}]//N//MatrixForm

OpenersExampleSubsection6(Spacer1)Resampling  (1)

By default, "Linear" resampling is used:

ArrayResample[{1,2,3},6]

Use a different resampling scheme:

ArrayResample[{1,2,3},6,Resampling->"Nearest"]

"Nearest" resampling averages the samples if the sampling position is halfway between samples:

ArrayResample[{1,2,3},5,Resampling->"Nearest"]

Use "NearestLeft" or "NearestRight" for a bias to left or right for half-integer sampling positions:

ArrayResample[{1,2,3},5,Resampling->"NearestLeft"]

OpenersExampleSection4(Spacer1)Applications  (1)

Reduce the size of a dataset for faster visualization:

data=Import["http://exampledata.wolfram.com/hailey.dem.gz","Data"];

(data2=ArrayResample[N@data,Scaled[1/5]])//ReliefPlot

AbsoluteTiming[ReliefPlot[#];][[1]]&/@{data,data2}

OpenersExampleSection5(Spacer1)Properties & Relations  (2)

Compare array resampling for a few different kernels:

a={1,3,1,2};
n=25;
xpos=Array[#&,n,{1,Length[a]}];
Table[
result=ArrayResample[a,n,Resampling->ker];
ListPlot[Transpose[{xpos,result}],PlotStyle->PointSize[Medium],Epilog->{Red,Line[Transpose[{Range[Length[a]],a}]]},Axes->{True,False},PlotLabel->ker],
{ker,{"Linear","Cubic","German"}}]

(RefLink[Downsample, paclet:ref/Downsample]) can be used to downsample by an integer factor:

Downsample[Range[9],2]

ArrayResample[Range[9],Scaled[1/2]]

OpenersExampleSection6(Spacer1)Possible Issues  (1)

Exact computations are performed with integer data:

input=Range[100];

AbsoluteTiming[ArrayResample[input,1000,Resampling->"Cubic"];]

Apply (RefLink[N, paclet:ref/N]) to integer data for faster computation:

AbsoluteTiming[ArrayResample[N@input,1000,Resampling->"Cubic"];]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ListInterpolation, paclet:ref/ListInterpolation])  ▪  (RefLink[Interpolation, paclet:ref/Interpolation])  ▪  (RefLink[ImageResize, paclet:ref/ImageResize])  ▪  (RefLink[Upsample, paclet:ref/Upsample])  ▪  (RefLink[Downsample, paclet:ref/Downsample])  ▪  (RefLink[Dimensions, paclet:ref/Dimensions])  ▪  (RefLink[ArrayPad, paclet:ref/ArrayPad])  ▪  (RefLink[ArrayFilter, paclet:ref/ArrayFilter])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Image Processing, paclet:tutorial/ImageProcessing])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Signal Processing, paclet:guide/SignalProcessing])}, {▪(RefLinkPlain[Rearranging & Restructuring Lists, paclet:guide/RearrangingAndRestructuringLists])}, {▪(RefLinkPlain[Structure Matrices & Convolution Kernels, paclet:guide/StructureMatricesAndConvolutionKernels])}})}})