({{, (RefLink[Upsample, paclet:ref/Upsample])[array,n] 
returns an upsampled version of the array by inserting n-1 zeros between array elements.}, {, (RefLink[Upsample, paclet:ref/Upsample])[array,n,offset]
shifts array so that its first element moves to the position offset in the resulting array.}, {, (RefLink[Upsample, paclet:ref/Upsample])[array,n,offset,val]
inserts n-1 elements of value val between array elements.}, {, (RefLink[Upsample, paclet:ref/Upsample])[image,…]
upsamples an image.}})

OpenersNotesSection(Spacer1)Details

In (RefLink[Upsample, paclet:ref/Upsample])[array,…], array can be an array of any rank.

(RefLink[Upsample, paclet:ref/Upsample]) works with arrays of any rank and 2D and 3D images.

(RefLink[Upsample, paclet:ref/Upsample])[array,{(Subscript[n, 1]),(Subscript[n, 2]),…}] inserts (Subscript[n, i]) zeros between elements in the i(^th) dimension.

(RefLink[Upsample, paclet:ref/Upsample])[array,n] is equivalent to (RefLink[Upsample, paclet:ref/Upsample])[array,n,1].

In (RefLink[Upsample, paclet:ref/Upsample])[array,n,offset], the offset has to be an integer between 1 and n.

OpenersPrimaryExamplesSection(Spacer1)Examples  (9)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Upsample a list by a factor of 3:

Upsample[{1,2,3},3]

Use an offset:

Upsample[{1,2,3},3,2]

Specify the value to be inserted:

Upsample[{1,2,3},3,2,-1]

Upsample a 2D array:

Upsample[(({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}})),2]//MatrixForm

Upsample an image by a factor of 2:

Upsample[,2]

OpenersExampleSection1(Spacer1)Scope  (3)

Use a different upsampling factor in each dimension:

Upsample[(({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}})),{2,3}]//MatrixForm

Upsample a symbolic array:

Upsample[{a,b,c},2]

Upsample an image by a factor of 2:

Upsample[,2]

By default, using offset equal to 1, no shifting is performed:

Upsample[,2,1]

Use a larger offset:

Upsample[,2,2]

Use a different offset in each dimension:

Upsample[,2,{1,2}]

Specify the insertion value:

Upsample[,2,{1,2},LightBlue]

OpenersExampleSection3(Spacer1)Applications  (3)

Create a Nyquist filter of length 7:

q=LeastSquaresFilterKernel[{"Lowpass",π/2},7]

Upsample by a factor of 2 using the smoothing filter:

list=Sin[2π/8Range[0,7]]

res=ListConvolve[q,Upsample[list,2],4]

ListLinePlot[res]

Linear interpolation using upsampling and convolution:

h={1/2,1,1/2};
x=Range[10];

ListConvolve[h,Upsample[x,2],1,0]

This implementation is not very efficient:

x2=N@Range[1000000];
AbsoluteTiming[res1=ListConvolve[h,Upsample[x2,2],1,0];]

A faster implementation would merge convolutions of the signal with odd and even samples of the filter:

AbsoluteTiming[res2=Flatten[Transpose[Map[ListConvolve[#1,x2,1,0]&,Transpose[Partition[h,2,2,{1,1},0]]]]];]

res1==res2

Linear interpolation by a factor k:

k=4;
h=Array[BartlettWindow,2k+1,{-1/2,1/2}];
x=Sin[2π/8Range[0,7]];

res=Flatten[Transpose[Map[ListConvolve[#1,x,Floor[k/2],0]&,Transpose[Partition[h,k,k,{1,1},0]]]]];

ListPlot[{Transpose[{Range[1,32,4],x}],res},PlotStyle->{PointSize[Large],Automatic}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Downsample, paclet:ref/Downsample])  ▪  (RefLink[ArrayResample, paclet:ref/ArrayResample])  ▪  (RefLink[Riffle, paclet:ref/Riffle])  ▪  (RefLink[ImageResize, paclet:ref/ImageResize])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Signal Processing, paclet:guide/SignalProcessing])}})}})