Code covered by the BSD License  

Highlights from
Pad array

5.0

5.0 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 2.55 KB File ID: #7720

Pad array

by Sergei Koptenko

 

25 May 2005 (Updated 26 May 2005)

Pad array or image.

| Watch this File

File Information
Description

This function is an extension of padarray.m. It allows to pad borders of an array (or an image) with variety of tapering functions to reduce artifacts from median filtering, convolution, hilbert transform calc., etc.. For instance, median filtering with medfilt2.m results in distorted edges since this function pad edges with zeros (thus, creating discontinuity jumps). Also, discontinuities can appear in hilbert transform or convolution, since they use circular padding of edges. Using padarray.m not always produce desired results. The current function array_padd.m allows pad edges with data tapering to zero with some windowing function (gaussian, hamming, etc..). This function also allows easily recover resulting array with the same size as the input array.
EXAMPLES:
 data_in = [1 1 1 1 1; 1 2 3 2 1; 1 2 3 2 1; 1 1 1 1 1]
        [data_out, indd] = array_padd(data_in, [3, 5])
        [data_out, indd] = array_padd(data_in, [3, 5], 5)
        [data_out, indd] = array_padd(data_in, [3, 5], 0, 'both')
        [data_out, indd] = array_padd(data_in, [3, 5], 0, 'both', 'replicate')
        [data_out, indd] = array_padd(data_in, [3, 5], 0, 'both', 'symmetric')
        [data_out, indd] = array_padd(data_in, [3, 5], 0, 'both', 'hamming')
        imagesc(data_out); colorbar
  original array size and position within padded array can be recovered as
        data_out = data_out(indd(1):indd(2),indd(3):indd(4));

Required Products Image Processing Toolbox
Signal Processing Toolbox
MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
23 Nov 2005 Anita D

works great, thanks!

30 Jan 2009 Steve

Super, just saved me a heap of time. Thanks

17 Sep 2009 Manushka

This function doesn't work for input arguments of type double?

09 Apr 2010 MatlabUser08

Hi I downloaded padArray file. I have been using this in Matlab Piotr's toolbox. When I run project; I get error messages as follows:-

Maximum recursion limit 0f 500 reached. Use Set(0,RecursionLimit,N) to change the limit.

Error in ==>PadArray

28 Sep 2011 roy

How to do this on matlab?
zero pad the face image with a five‐pixel thick rim around the borders of the
image. show the resulting image.
Must be manual codes on script.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
application Sergei Koptenko 22 Oct 2008 07:49:16
padding array pad borders Sergei Koptenko 22 Oct 2008 07:49:16

Contact us at files@mathworks.com