plateform stringclasses 1
value | repo_name stringlengths 13 113 | name stringlengths 3 74 | ext stringclasses 1
value | path stringlengths 12 229 | size int64 23 843k | source_encoding stringclasses 9
values | md5 stringlengths 32 32 | text stringlengths 23 843k |
|---|---|---|---|---|---|---|---|---|
github | jbhuang0604/LapSRN-master | mkImpulse.m | .m | LapSRN-master/utils/matlabPyrTools/mkImpulse.m | 529 | utf_8 | cf6f3809cb123791501bb0e92845a0c6 | % IM = mkImpulse(SIZE, ORIGIN, AMPLITUDE)
%
% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar)
% containing a single non-zero entry, at position ORIGIN (defaults to
% ceil(size/2)), of value AMPLITUDE (defaults to 1).
% Eero Simoncelli, 6/96.
function [res] = mkImpulse(sz, origin, amplitude)
sz = s... |
github | jbhuang0604/LapSRN-master | rconv2.m | .m | LapSRN-master/utils/matlabPyrTools/rconv2.m | 1,435 | utf_8 | da3a54d6c7b1ac17c78eab0a4a7648d9 | % RES = RCONV2(MTX1, MTX2, CTR)
%
% Convolution of two matrices, with boundaries handled via reflection
% about the edge pixels. Result will be of size of LARGER matrix.
%
% The origin of the smaller matrix is assumed to be its center.
% For even dimensions, the origin is determined by the CTR (optional)
% argument:... |
github | jbhuang0604/LapSRN-master | mkR.m | .m | LapSRN-master/utils/matlabPyrTools/mkR.m | 775 | utf_8 | 504bc90f67c72730edc4a9d86630bdf2 | % IM = mkR(SIZE, EXPT, ORIGIN)
%
% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar)
% containing samples of a radial ramp function, raised to power EXPT
% (default = 1), with given ORIGIN (default = (size+1)/2, [1 1] =
% upper left). All but the first argument are optional.
% Eero Simoncelli, 6/96.... |
github | jbhuang0604/LapSRN-master | blur.m | .m | LapSRN-master/utils/matlabPyrTools/blur.m | 1,731 | utf_8 | a2dc57fdfe85f98549b2f7ddf721c298 | % RES = blur(IM, LEVELS, FILT)
%
% Blur an image, by filtering and downsampling LEVELS times
% (default=1), followed by upsampling and filtering LEVELS times. The
% blurring is done with filter kernel specified by FILT (default =
% 'binom5'), which can be a string (to be passed to namedFilter), a
% vector (applied sep... |
github | jbhuang0604/LapSRN-master | pyrBand.m | .m | LapSRN-master/utils/matlabPyrTools/pyrBand.m | 395 | utf_8 | 39c1e3772426a1362119d302d9767a24 | % RES = pyrBand(PYR, INDICES, BAND_NUM)
%
% Access a subband from a pyramid (gaussian, laplacian, QMF/wavelet,
% or steerable). Subbands are numbered consecutively, from finest
% (highest spatial frequency) to coarsest (lowest spatial frequency).
% Eero Simoncelli, 6/96.
function res = pyrBand(pyr, pind, band)
re... |
github | jbhuang0604/LapSRN-master | kurt2.m | .m | LapSRN-master/utils/matlabPyrTools/kurt2.m | 551 | utf_8 | cd20c1a5155cba8de454011552ec4f2a | % K = KURT2(MTX,MEAN,VAR)
%
% Sample kurtosis (fourth moment divided by squared variance)
% of a matrix. Kurtosis of a Gaussian distribution is 3.
% MEAN (optional) and VAR (optional) make the computation faster.
% Eero Simoncelli, 6/96.
function res = kurt2(mtx, mn, v)
if (exist('mn') ~= 1)
mn = mean(mean(mtx)... |
github | jbhuang0604/LapSRN-master | buildSpyr.m | .m | LapSRN-master/utils/matlabPyrTools/buildSpyr.m | 2,064 | utf_8 | b0caf60e63a52aa734956dd74ea39f95 | % [PYR, INDICES, STEERMTX, HARMONICS] = buildSpyr(IM, HEIGHT, FILTFILE, EDGES)
%
% Construct a steerable pyramid on matrix IM. Convolutions are
% done with spatial filters.
%
% HEIGHT (optional) specifies the number of pyramid levels to build. Default
% is maxPyrHt(size(IM),size(FILT)).
% You can also specify 'auto' ... |
github | jbhuang0604/LapSRN-master | setPyrBand.m | .m | LapSRN-master/utils/matlabPyrTools/setPyrBand.m | 1,049 | utf_8 | 76554eb735e969097a4723a508facd37 | % NEWPYR = setPyrBand(PYR, INDICES, NEWBAND, BAND_NUM)
%
% Insert an image (BAND) into a pyramid (gaussian, laplacian, QMF/wavelet,
% or steerable). Subbands are numbered consecutively, from finest
% (highest spatial frequency) to coarsest (lowest spatial frequency).
% Eero Simoncelli, 1/03.
function pyr = setPyrB... |
github | jbhuang0604/LapSRN-master | var2.m | .m | LapSRN-master/utils/matlabPyrTools/var2.m | 390 | utf_8 | de26727e055081aa670024c273f0e885 | % V = VAR2(MTX,MEAN)
%
% Sample variance of a matrix.
% Passing MEAN (optional) makes the calculation faster.
function res = var2(mtx, mn)
if (exist('mn') ~= 1)
mn = mean2(mtx);
end
if (isreal(mtx))
res = sum(sum(abs(mtx-mn).^2)) / max((prod(size(mtx)) - 1),1);
else
res = sum(sum(real(mtx-mn).^2)) + i*sum(su... |
github | jbhuang0604/LapSRN-master | reconSFpyrLevs.m | .m | LapSRN-master/utils/matlabPyrTools/reconSFpyrLevs.m | 2,016 | utf_8 | ff83a4f3d2f0927dcaa8851535e6b20a | % RESDFT = reconSFpyrLevs(PYR,INDICES,LOGRAD,XRCOS,YRCOS,ANGLE,NBANDS,LEVS,BANDS)
%
% Recursive function for reconstructing levels of a steerable pyramid
% representation. This is called by reconSFpyr, and is not usually
% called directly.
% Eero Simoncelli, 5/97.
function resdft = reconSFpyrLevs(pyr,pind,log_rad,Xr... |
github | jbhuang0604/LapSRN-master | rcosFn.m | .m | LapSRN-master/utils/matlabPyrTools/rcosFn.m | 1,122 | utf_8 | 36283e0a34f1baf7ea2c5e6cb23aab89 | % [X, Y] = rcosFn(WIDTH, POSITION, VALUES)
%
% Return a lookup table (suitable for use by INTERP1)
% containing a "raised cosine" soft threshold function:
%
% Y = VALUES(1) + (VALUES(2)-VALUES(1)) *
% cos^2( PI/2 * (X - POSITION + WIDTH)/WIDTH )
%
% WIDTH is the width of the region over which the tra... |
github | jbhuang0604/LapSRN-master | wpyrLev.m | .m | LapSRN-master/utils/matlabPyrTools/wpyrLev.m | 729 | utf_8 | 77f309b76f98f3421e786fde4fe2d429 | % [LEV,IND] = wpyrLev(PYR,INDICES,LEVEL)
%
% Access a level from a separable QMF/wavelet pyramid.
% Return as an SxB matrix, B = number of bands, S = total size of a band.
% Also returns an Bx2 matrix containing dimensions of the subbands.
% Eero Simoncelli, 6/96.
function [lev,ind] = wpyrLev(pyr,pind,level)
if ((p... |
github | jbhuang0604/LapSRN-master | binomialFilter.m | .m | LapSRN-master/utils/matlabPyrTools/binomialFilter.m | 309 | utf_8 | 47b67219b2519bd65a435f3df318d41a | % KERNEL = binomialFilter(size)
%
% Returns a vector of binomial coefficients of order (size-1) .
% Eero Simoncelli, 2/97.
function [kernel] = binomialFilter(sz)
if (sz < 2)
error('size argument must be larger than 1');
end
kernel = [0.5 0.5]';
for n=1:sz-2
kernel = conv([0.5 0.5]', kernel);
end
|
github | jbhuang0604/LapSRN-master | cconv2.m | .m | LapSRN-master/utils/matlabPyrTools/cconv2.m | 1,325 | utf_8 | 8e564b623ba5cebd51e585eac6c66ba8 | % RES = CCONV2(MTX1, MTX2, CTR)
%
% Circular convolution of two matrices. Result will be of size of
% LARGER vector.
%
% The origin of the smaller matrix is assumed to be its center.
% For even dimensions, the origin is determined by the CTR (optional)
% argument:
% CTR origin
% 0 DIM/2 (defaul... |
github | jbhuang0604/LapSRN-master | reconSCFpyr.m | .m | LapSRN-master/utils/matlabPyrTools/reconSCFpyr.m | 4,475 | utf_8 | a0a6a06af4b5c9f7aa195bb8188fc754 | % RES = reconSCFpyr(PYR, INDICES, LEVS, BANDS, TWIDTH)
%
% The inverse of buildSCFpyr: Reconstruct image from its complex steerable pyramid representation,
% in the Fourier domain.
%
% The image is reconstructed by forcing the complex subbands to be analytic
% (zero on half of the 2D Fourier plane, as they are supossed... |
github | jbhuang0604/LapSRN-master | buildSCFpyr.m | .m | LapSRN-master/utils/matlabPyrTools/buildSCFpyr.m | 2,713 | utf_8 | d94b4004138b50b6651511e8ba6ccb93 | % [PYR, INDICES, STEERMTX, HARMONICS] = buildSCFpyr(IM, HEIGHT, ORDER, TWIDTH)
%
% This is a modified version of buildSFpyr, that constructs a
% complex-valued steerable pyramid using Hilbert-transform pairs
% of filters. Note that the imaginary parts will *not* be steerable.
%
% To reconstruct from this representati... |
github | jbhuang0604/LapSRN-master | showIm.m | .m | LapSRN-master/utils/matlabPyrTools/showIm.m | 6,111 | utf_8 | 15fbbf55e2fd54e3f48ca936e23c3f32 | % RANGE = showIm (MATRIX, RANGE, ZOOM, LABEL, NSHADES )
%
% Display a MatLab MATRIX as a grayscale image in the current figure,
% inside the current axes. If MATRIX is complex, the real and imaginary
% parts are shown side-by-side, with the same grayscale mapping.
%
% If MATRIX is a string, it should be the name of... |
github | jbhuang0604/LapSRN-master | pyrLow.m | .m | LapSRN-master/utils/matlabPyrTools/pyrLow.m | 287 | utf_8 | b3514ec06e2e106d7b61e534cac20a8e | % RES = pyrLow(PYR, INDICES)
%
% Access the lowpass subband from a pyramid
% (gaussian, laplacian, QMF/wavelet, steerable).
% Eero Simoncelli, 6/96.
function res = pyrLow(pyr,pind)
band = size(pind,1);
res = reshape( pyr(pyrBandIndices(pind,band)), pind(band,1), pind(band,2) );
|
github | jbhuang0604/LapSRN-master | pgmRead.m | .m | LapSRN-master/utils/matlabPyrTools/pgmRead.m | 1,259 | utf_8 | 6f07c13cf0f5d8930a46ac0d778bf86f | % IM = pgmRead( FILENAME )
%
% Load a pgm image into a MatLab matrix.
% This format is accessible from the XV image browsing utility.
% Only works for 8bit gray images (raw or ascii)
% Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96.
function im = pgmRead( fname );
[fid,msg] = fopen( fname, 'r' );
... |
github | jbhuang0604/LapSRN-master | upConv.m | .m | LapSRN-master/utils/matlabPyrTools/upConv.m | 2,779 | utf_8 | 34137e966f38700416bfb0ebb72663ee | % RES = upConv(IM, FILT, EDGES, STEP, START, STOP, RES)
%
% Upsample matrix IM, followed by convolution with matrix FILT. These
% arguments should be 1D or 2D matrices, and IM must be larger (in
% both dimensions) than FILT. The origin of filt
% is assumed to be floor(size(filt)/2)+1.
%
% EDGES is a string determinin... |
github | jbhuang0604/LapSRN-master | mean2.m | .m | LapSRN-master/utils/matlabPyrTools/mean2.m | 97 | utf_8 | cacc007ef6e32ba40a1e0da3b3d80a0e | % M = MEAN2(MTX)
%
% Sample mean of a matrix.
function res = mean2(mtx)
res = mean(mean(mtx));
|
github | jbhuang0604/LapSRN-master | range2.m | .m | LapSRN-master/utils/matlabPyrTools/range2.m | 523 | utf_8 | b9f23c3a4f73bf568a1b5793f516aa80 | % [MIN, MAX] = range2(MTX)
%
% Compute minimum and maximum values of MTX, returning them as a 2-vector.
% Eero Simoncelli, 3/97.
function [mn, mx] = range2(mtx)
%% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD)
fprintf(1,'WARNING: You should compile the MEX version of "range2.c",\n found... |
github | jbhuang0604/LapSRN-master | buildSCFpyrLevs.m | .m | LapSRN-master/utils/matlabPyrTools/buildSCFpyrLevs.m | 2,187 | utf_8 | 26747285064a0eaa2f3db75013e80849 | % [PYR, INDICES] = buildSCFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS)
%
% Recursive function for constructing levels of a steerable pyramid. This
% is called by buildSCFpyr, and is not usually called directly.
% Original code: Eero Simoncelli, 5/97.
% Modified by Javier Portilla to generate complex b... |
github | jbhuang0604/LapSRN-master | clip.m | .m | LapSRN-master/utils/matlabPyrTools/clip.m | 814 | utf_8 | 13c82937ba69d5bc8c94b2ccca783e1b | % [RES] = clip(IM, MINVALorRANGE, MAXVAL)
%
% Clip values of matrix IM to lie between minVal and maxVal:
% RES = max(min(IM,MAXVAL),MINVAL)
% The first argument can also specify both min and max, as a 2-vector.
% If only one argument is passed, the range defaults to [0,1].
function res = clip(im, minValOrRange, m... |
github | jbhuang0604/LapSRN-master | upBlur.m | .m | LapSRN-master/utils/matlabPyrTools/upBlur.m | 1,213 | utf_8 | 7b07d26940520537edb6e8dc25b72242 | % RES = upBlur(IM, LEVELS, FILT)
%
% Upsample and blur an image. The blurring is done with filter
% kernel specified by FILT (default = 'binom5'), which can be a string
% (to be passed to namedFilter), a vector (applied separably as a 1D
% convolution kernel in X and Y), or a matrix (applied as a 2D
% convolution kern... |
github | jbhuang0604/LapSRN-master | nextFig.m | .m | LapSRN-master/utils/matlabPyrTools/nextFig.m | 363 | utf_8 | 94a66b00983cd3840ff1cc88f118a022 | % nextFig (MAXFIGS, SKIP)
%
% Make figure number mod((GCF+SKIP), MAXFIGS) the current figure.
% MAXFIGS is optional, and defaults to 2.
% SKIP is optional, and defaults to 1.
% Eero Simoncelli, 2/97.
function nextFig(maxfigs, skip)
if (exist('maxfigs') ~= 1)
maxfigs = 2;
end
if (exist('skip') ~= 1)
skip = 1;... |
github | jbhuang0604/LapSRN-master | zconv2.m | .m | LapSRN-master/utils/matlabPyrTools/zconv2.m | 1,164 | utf_8 | cd266795530db4cb146c1038383316f3 | % RES = ZCONV2(MTX1, MTX2, CTR)
%
% Convolution of two matrices, with boundaries handled as if the larger mtx
% lies in a sea of zeros. Result will be of size of LARGER vector.
%
% The origin of the smaller matrix is assumed to be its center.
% For even dimensions, the origin is determined by the CTR (optional)
% arg... |
github | jbhuang0604/LapSRN-master | mkZonePlate.m | .m | LapSRN-master/utils/matlabPyrTools/mkZonePlate.m | 633 | utf_8 | d88329c8d374e54e124222c825679768 | % IM = mkZonePlate(SIZE, AMPL, PHASE)
%
% Make a "zone plate" image:
% AMPL * cos( r^2 + PHASE)
% SIZE specifies the matrix size, as for zeros().
% AMPL (default = 1) and PHASE (default = 0) are optional.
% Eero Simoncelli, 6/96.
function [res] = mkZonePlate(sz, ampl, ph)
sz = sz(:);
if (size(sz,1) == 1)
sz ... |
github | jbhuang0604/LapSRN-master | steer2HarmMtx.m | .m | LapSRN-master/utils/matlabPyrTools/steer2HarmMtx.m | 1,803 | utf_8 | 35816be985c308717168260dc97419d8 | % MTX = steer2HarmMtx(HARMONICS, ANGLES, REL_PHASES)
%
% Compute a steering matrix (maps a directional basis set onto the
% angular Fourier harmonics). HARMONICS is a vector specifying the
% angular harmonics contained in the steerable basis/filters. ANGLES
% (optional) is a vector specifying the angular position of... |
github | jbhuang0604/LapSRN-master | mkAngularSine.m | .m | LapSRN-master/utils/matlabPyrTools/mkAngularSine.m | 845 | utf_8 | 78a5e0afe3fef5c42804516e2ea1ccc8 | % IM = mkAngularSine(SIZE, HARMONIC, AMPL, PHASE, ORIGIN)
%
% Make an angular sinusoidal image:
% AMPL * sin( HARMONIC*theta + PHASE),
% where theta is the angle about the origin.
% SIZE specifies the matrix size, as for zeros().
% AMPL (default = 1) and PHASE (default = 0) are optional.
% Eero Simoncelli, 2/97.... |
github | jbhuang0604/LapSRN-master | mkRamp.m | .m | LapSRN-master/utils/matlabPyrTools/mkRamp.m | 1,110 | utf_8 | 28989822e19c604a816a287a4bee873d | % IM = mkRamp(SIZE, DIRECTION, SLOPE, INTERCEPT, ORIGIN)
%
% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar)
% containing samples of a ramp function, with given gradient DIRECTION
% (radians, CW from X-axis, default = 0), SLOPE (per pixel, default =
% 1), and a value of INTERCEPT (default = 0) at the... |
github | jbhuang0604/LapSRN-master | histoMatch.m | .m | LapSRN-master/utils/matlabPyrTools/histoMatch.m | 858 | utf_8 | 8936fc2eadacc591ecdffe5967726780 | % RES = histoMatch(MTX, N, X)
%
% Modify elements of MTX so that normalized histogram matches that
% specified by vectors X and N, where N contains the histogram counts
% and X the histogram bin positions (see histo).
% Eero Simoncelli, 7/96.
function res = histoMatch(mtx, N, X)
if ( exist('histo') == 3 )
[oN, oX]... |
github | jbhuang0604/LapSRN-master | subMtx.m | .m | LapSRN-master/utils/matlabPyrTools/subMtx.m | 420 | utf_8 | c660029ce728dcb8c540c9cf419fa7bc | % MTX = subMtx(VEC, DIMENSIONS, START_INDEX)
%
% Reshape a portion of VEC starting from START_INDEX (optional,
% default=1) to the given dimensions.
% Eero Simoncelli, 6/96.
function mtx = subMtx(vec, sz, offset)
if (exist('offset') ~= 1)
offset = 1;
end
vec = vec(:);
sz = sz(:);
if (size(sz,1) ~= 2)
error('D... |
github | jbhuang0604/LapSRN-master | showLpyr.m | .m | LapSRN-master/utils/matlabPyrTools/showLpyr.m | 5,421 | utf_8 | 0646b94ae144cf6160a44f50e67f8dd5 | % RANGE = showLpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR)
%
% Display a Laplacian (or Gaussian) pyramid, specified by PYR and
% INDICES (see buildLpyr), in the current figure.
%
% RANGE is a 2-vector specifying the values that map to black and
% white, respectively. These values are scaled by
% LEVEL_SCALE_F... |
github | jbhuang0604/LapSRN-master | sp1Filters.m | .m | LapSRN-master/utils/matlabPyrTools/sp1Filters.m | 9,435 | utf_8 | 81cfbf726744492bee2374b9b564ebdf | % Steerable pyramid filters. Transform described in:
%
% @INPROCEEDINGS{Simoncelli95b,
% TITLE = "The Steerable Pyramid: A Flexible Architecture for
% Multi-Scale Derivative Computation",
% AUTHOR = "E P Simoncelli and W T Freeman",
% BOOKTITLE = "Second Int'l Conf on Image Processing",
% ADDRESS = "Washington, DC"... |
github | jbhuang0604/LapSRN-master | spyrHt.m | .m | LapSRN-master/utils/matlabPyrTools/spyrHt.m | 305 | utf_8 | 06e83c1f45c1a99e242fa7ea37093a11 | % [HEIGHT] = spyrHt(INDICES)
%
% Compute height of steerable pyramid with given index matrix.
% Eero Simoncelli, 6/96.
function [ht] = spyrHt(pind)
nbands = spyrNumBands(pind);
% Don't count lowpass, or highpass residual bands
if (size(pind,1) > 2)
ht = (size(pind,1)-2)/nbands;
else
ht = 0;
end
|
github | jbhuang0604/LapSRN-master | spyrBand.m | .m | LapSRN-master/utils/matlabPyrTools/spyrBand.m | 819 | utf_8 | 7d15b24244e521c9e85c68b3037f569b | % [LEV,IND] = spyrBand(PYR,INDICES,LEVEL,BAND)
%
% Access a band from a steerable pyramid.
%
% LEVEL indicates the scale (finest = 1, coarsest = spyrHt(INDICES)).
%
% BAND (optional, default=1) indicates which subband
% (1 = vertical, rest proceeding anti-clockwise).
% Eero Simoncelli, 6/96.
function res =... |
github | jbhuang0604/LapSRN-master | wpyrBand.m | .m | LapSRN-master/utils/matlabPyrTools/wpyrBand.m | 873 | utf_8 | 12e08d90ccd6261b737e2d3c5ac5b1e7 | % RES = wpyrBand(PYR, INDICES, LEVEL, BAND)
%
% Access a subband from a separable QMF/wavelet pyramid.
%
% LEVEL (optional, default=1) indicates the scale (finest = 1,
% coarsest = wpyrHt(INDICES)).
%
% BAND (optional, default=1) indicates which subband (1=horizontal,
% 2=vertical, 3=diagonal).
% Eero Simoncelli... |
github | jbhuang0604/LapSRN-master | skew2.m | .m | LapSRN-master/utils/matlabPyrTools/skew2.m | 478 | utf_8 | b304767117ab43e408c5757ab9e3402d | % S = SKEW2(MTX,MEAN,VAR)
%
% Sample skew (third moment divided by variance^3/2) of a matrix.
% MEAN (optional) and VAR (optional) make the computation faster.
function res = skew2(mtx, mn, v)
if (exist('mn') ~= 1)
mn = mean2(mtx);
end
if (exist('v') ~= 1)
v = var2(mtx,mn);
end
if (isreal(mtx))
res = mean(... |
github | jbhuang0604/LapSRN-master | imStats.m | .m | LapSRN-master/utils/matlabPyrTools/imStats.m | 1,217 | utf_8 | aab8c3264c5939806bbca5657c925734 | % imStats(IM1,IM2)
%
% Report image (matrix) statistics.
% When called on a single image IM1, report min, max, mean, stdev, skew,
% and kurtosis (4th moment about the mean, divided by squared variance)
%
% When called on two images (IM1 and IM2), report min, max, mean,
% stdev of the difference, and also SNR (relative... |
github | jbhuang0604/LapSRN-master | innerProd.m | .m | LapSRN-master/utils/matlabPyrTools/innerProd.m | 314 | utf_8 | e2ea166f9b3ddbc08cb54ef697343d06 | % RES = innerProd(MTX)
%
% Compute (MTX' * MTX) efficiently (i.e., without copying the matrix)
%
% NOTE: This function used to call a MEX function (C code) to avoid copying, but
% newer versions of matlab have eliminated the overhead of the
% simpler form below.
function res = innerProd(mtx)
res = mtx' * mtx;
|
github | jbhuang0604/LapSRN-master | reconSFpyr.m | .m | LapSRN-master/utils/matlabPyrTools/reconSFpyr.m | 3,114 | utf_8 | ebb08817efc597692b9026a84e2a6906 | % RES = reconSFpyr(PYR, INDICES, LEVS, BANDS, TWIDTH)
%
% Reconstruct image from its steerable pyramid representation, in the Fourier
% domain, as created by buildSFpyr.
%
% PYR is a vector containing the N pyramid subbands, ordered from fine
% to coarse. INDICES is an Nx2 matrix containing the sizes of
% each subband... |
github | jbhuang0604/LapSRN-master | corrDn.m | .m | LapSRN-master/utils/matlabPyrTools/corrDn.m | 2,273 | utf_8 | 22bd1475092a492cb03a6e4134332d24 | % RES = corrDn(IM, FILT, EDGES, STEP, START, STOP)
%
% Compute correlation of matrices IM with FILT, followed by
% downsampling. These arguments should be 1D or 2D matrices, and IM
% must be larger (in both dimensions) than FILT. The origin of filt
% is assumed to be floor(size(filt)/2)+1.
%
% EDGES is a string dete... |
github | jbhuang0604/LapSRN-master | vectify.m | .m | LapSRN-master/utils/matlabPyrTools/vectify.m | 186 | utf_8 | 1da0e519af06d6baaff1decc40dc3702 | % [VEC] = columnize(MTX)
%
% Pack elements of MTX into a column vector. Just provides a
% function-call notatoin for the operation MTX(:)
function vec = columnize(mtx)
vec = mtx(:);
|
github | jbhuang0604/LapSRN-master | maxPyrHt.m | .m | LapSRN-master/utils/matlabPyrTools/maxPyrHt.m | 603 | utf_8 | 019e5ce9d036a893ec979c63f51ff54a | % HEIGHT = maxPyrHt(IMSIZE, FILTSIZE)
%
% Compute maximum pyramid height for given image and filter sizes.
% Specifically: the number of corrDn operations that can be sequentially
% performed when subsampling by a factor of 2.
% Eero Simoncelli, 6/96.
function height = maxPyrHt(imsz, filtsz)
imsz = imsz(:);
filtsz =... |
github | jbhuang0604/LapSRN-master | buildSpyrLevs.m | .m | LapSRN-master/utils/matlabPyrTools/buildSpyrLevs.m | 861 | utf_8 | a5fa1e98161a8137e666c1406c28a748 | % [PYR, INDICES] = buildSpyrLevs(LOIM, HEIGHT, LOFILT, BFILTS, EDGES)
%
% Recursive function for constructing levels of a steerable pyramid. This
% is called by buildSpyr, and is not usually called directly.
% Eero Simoncelli, 6/96.
function [pyr,pind] = buildSpyrLevs(lo0,ht,lofilt,bfilts,edges);
if (ht <= 0)
py... |
github | jbhuang0604/LapSRN-master | showSpyr.m | .m | LapSRN-master/utils/matlabPyrTools/showSpyr.m | 5,213 | utf_8 | bc643d88c491a55c0a0abb5e86c91757 | % RANGE = showSpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR)
%
% Display a steerable pyramid, specified by PYR and INDICES
% (see buildSpyr), in the current figure. The highpass band is not shown.
%
% RANGE is a 2-vector specifying the values that map to black and
% white, respectively. These values are scaled... |
github | jbhuang0604/LapSRN-master | histo.m | .m | LapSRN-master/utils/matlabPyrTools/histo.m | 1,835 | utf_8 | e76d8956cd1d59f518a8146dc5145f9b | % [N,X] = histo(MTX, nbinsOrBinsize, binCenter);
%
% Compute a histogram of (all) elements of MTX. N contains the histogram
% counts, X is a vector containg the centers of the histogram bins.
%
% nbinsOrBinsize (optional, default = 101) specifies either
% the number of histogram bins, or the negative of the binsize.
%... |
github | jbhuang0604/LapSRN-master | lplot.m | .m | LapSRN-master/utils/matlabPyrTools/lplot.m | 1,009 | utf_8 | 87c83936af0b318d55077862065b56df | % lplot(VEC, XRANGE)
%
% Plot VEC, a vector, in "lollipop" format.
% XRANGE (optional, default = [1,length(VEC)]), should be a 2-vector
% specifying the X positions (for labeling purposes) of the first and
% last sample of VEC.
% Mark Liberman, Linguistics Dept, UPenn, 1994.
function lplot(x,xrange)
if (exist('... |
github | jbhuang0604/LapSRN-master | blurDn.m | .m | LapSRN-master/utils/matlabPyrTools/blurDn.m | 1,364 | utf_8 | d528010bfd2b4c50e7dbb2aede757214 | % RES = blurDn(IM, LEVELS, FILT)
%
% Blur and downsample an image. The blurring is done with filter
% kernel specified by FILT (default = 'binom5'), which can be a string
% (to be passed to namedFilter), a vector (applied separably as a 1D
% convolution kernel in X and Y), or a matrix (applied as a 2D
% convolution ke... |
github | jbhuang0604/LapSRN-master | reconSpyrLevs.m | .m | LapSRN-master/utils/matlabPyrTools/reconSpyrLevs.m | 1,126 | utf_8 | 1f10e3cea5d79a4f4a30d979f3bb1298 | % RES = reconSpyrLevs(PYR,INDICES,LOFILT,BFILTS,EDGES,LEVS,BANDS)
%
% Recursive function for reconstructing levels of a steerable pyramid
% representation. This is called by reconSpyr, and is not usually
% called directly.
% Eero Simoncelli, 6/96.
function res = reconSpyrLevs(pyr,pind,lofilt,bfilts,edges,levs,bands)... |
github | jbhuang0604/LapSRN-master | mkSine.m | .m | LapSRN-master/utils/matlabPyrTools/mkSine.m | 1,725 | utf_8 | 35c6d83f70860ab6defcbdcf7366d89e | % IM = mkSine(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN)
% or
% IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN)
%
% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar)
% containing samples of a 2D sinusoid, with given PERIOD (in pixels),
% DIRECTION (radians, CW from X-axis, default = 0),... |
github | jbhuang0604/LapSRN-master | buildSFpyrLevs.m | .m | LapSRN-master/utils/matlabPyrTools/buildSFpyrLevs.m | 1,891 | utf_8 | 52ab858761411b2a5a75e7de641259cf | % [PYR, INDICES] = buildSFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS)
%
% Recursive function for constructing levels of a steerable pyramid. This
% is called by buildSFpyr, and is not usually called directly.
% Eero Simoncelli, 5/97.
function [pyr,pind] = buildSFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angl... |
github | jbhuang0604/LapSRN-master | pixelAxes.m | .m | LapSRN-master/utils/matlabPyrTools/pixelAxes.m | 1,983 | utf_8 | 1b2a2bfddd425fee2ccd276f3948cec7 | % [ZOOM] = pixelAxes(DIMS, ZOOM)
%
% Set the axes of the current plot to cover a multiple of DIMS pixels,
% thereby eliminating screen aliasing artifacts when displaying an
% image of size DIMS.
%
% ZOOM (optional, default='same') expresses the desired number of
% samples displayed per screen pixel. It should be a ... |
github | jbhuang0604/LapSRN-master | pyrBandIndices.m | .m | LapSRN-master/utils/matlabPyrTools/pyrBandIndices.m | 589 | utf_8 | 28f90484526c294bdb24bdbf8014012d | % RES = pyrBandIndices(INDICES, BAND_NUM)
%
% Return indices for accessing a subband from a pyramid
% (gaussian, laplacian, QMF/wavelet, steerable).
% Eero Simoncelli, 6/96.
function indices = pyrBandIndices(pind,band)
if ((band > size(pind,1)) | (band < 1))
error(sprintf('BAND_NUM must be between 1 and number o... |
github | jbhuang0604/LapSRN-master | pointOp.m | .m | LapSRN-master/utils/matlabPyrTools/pointOp.m | 1,209 | utf_8 | 537b70083d9e7d7ffe4810e966c047f9 | % RES = pointOp(IM, LUT, ORIGIN, INCREMENT, WARNINGS)
%
% Apply a point operation, specified by lookup table LUT, to image IM.
% LUT must be a row or column vector, and is assumed to contain
% (equi-spaced) samples of the function. ORIGIN specifies the
% abscissa associated with the first sample, and INCREMENT specifi... |
github | jbhuang0604/LapSRN-master | reconWpyr.m | .m | LapSRN-master/utils/matlabPyrTools/reconWpyr.m | 3,992 | utf_8 | 859a606f214bce204ce3c9ea18c0fc87 | % RES = reconWpyr(PYR, INDICES, FILT, EDGES, LEVS, BANDS)
%
% Reconstruct image from its separable orthonormal QMF/wavelet pyramid
% representation, as created by buildWpyr.
%
% PYR is a vector containing the N pyramid subbands, ordered from fine
% to coarse. INDICES is an Nx2 matrix containing the sizes of
% each sub... |
github | jbhuang0604/LapSRN-master | showWpyr.m | .m | LapSRN-master/utils/matlabPyrTools/showWpyr.m | 5,491 | utf_8 | 4bc0b260425f553810ae04afced17fda | % RANGE = showWpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR)
%
% Display a separable QMF/wavelet pyramid, specified by PYR and INDICES
% (see buildWpyr), in the current figure.
%
% RANGE is a 2-vector specifying the values that map to black and
% white, respectively. These values are scaled by
% LEVEL_SCALE_FAC... |
github | jbhuang0604/LapSRN-master | imGradient.m | .m | LapSRN-master/utils/matlabPyrTools/imGradient.m | 1,547 | utf_8 | b13a85bea09c3f4e0c1e6140c9a31f7a | % [dx, dy] = imGradient(im, edges)
%
% Compute the gradient of the image using smooth derivative filters
% optimized for accurate direction estimation. Coordinate system
% corresponds to standard pixel indexing: X axis points rightward. Y
% axis points downward. EDGES specify boundary handling (see corrDn
% for opt... |
github | jbhuang0604/LapSRN-master | lpyrHt.m | .m | LapSRN-master/utils/matlabPyrTools/lpyrHt.m | 233 | utf_8 | dd0b45926abda2b3fe9aaec0a4f4d214 | % [HEIGHT] = lpyrHt(INDICES)
%
% Compute height of Laplacian pyramid with given its INDICES matrix.
% See buildLpyr.m
% Eero Simoncelli, 6/96.
function [ht] = lpyrHt(pind)
% Don't count lowpass residual band
ht = size(pind,1)-1;
|
github | jbhuang0604/LapSRN-master | buildGpyr.m | .m | LapSRN-master/utils/matlabPyrTools/buildGpyr.m | 1,931 | utf_8 | 3f1cfe5507fe34b51d71a87d955abbf5 | % [PYR, INDICES] = buildGpyr(IM, HEIGHT, FILT, EDGES)
%
% Construct a Gaussian pyramid on matrix IM.
%
% HEIGHT (optional) specifies the number of pyramid levels to build. Default
% is 1+maxPyrHt(size(IM),size(FILT)).
% You can also specify 'auto' to use this value.
%
% FILT (optional) can be a string naming a standar... |
github | jbhuang0604/LapSRN-master | shift.m | .m | LapSRN-master/utils/matlabPyrTools/shift.m | 438 | utf_8 | 2ac42b171e4ca683ef1d361eaf331870 | % [RES] = shift(MTX, OFFSET)
%
% Circular shift 2D matrix samples by OFFSET (a [Y,X] 2-vector),
% such that RES(POS) = MTX(POS-OFFSET).
function res = shift(mtx, offset)
dims = size(mtx);
offset = mod(-offset,dims);
res = [ mtx(offset(1)+1:dims(1), offset(2)+1:dims(2)), ...
mtx(offset(1)+1:dims(1), 1:o... |
github | jbhuang0604/LapSRN-master | namedFilter.m | .m | LapSRN-master/utils/matlabPyrTools/namedFilter.m | 3,207 | utf_8 | 8f45ef65fca60f53e0f734c4f1ae01bf | % KERNEL = NAMED_FILTER(NAME)
%
% Some standard 1D filter kernels. These are scaled such that
% their L2-norm is 1.0.
%
% binomN - binomial coefficient filter of order N-1
% haar: - Haar wavelet.
% qmf8, qmf12, qmf16 - Symmetric Quadrature Mirror Filters [Johnston80]
% daub2,daub3,daub4 -... |
github | jbhuang0604/LapSRN-master | buildLpyr.m | .m | LapSRN-master/utils/matlabPyrTools/buildLpyr.m | 2,632 | utf_8 | b62aad457634fd598b373448741860cd | % [PYR, INDICES] = buildLpyr(IM, HEIGHT, FILT1, FILT2, EDGES)
%
% Construct a Laplacian pyramid on matrix (or vector) IM.
%
% HEIGHT (optional) specifies the number of pyramid levels to build. Default
% is 1+maxPyrHt(size(IM),size(FILT)). You can also specify 'auto' to
% use this value.
%
% FILT1 (optional) can be a s... |
github | jbhuang0604/LapSRN-master | mkAngle.m | .m | LapSRN-master/utils/matlabPyrTools/mkAngle.m | 788 | utf_8 | 126297224256c6e9077dc58f4094c39a | % IM = mkAngle(SIZE, PHASE, ORIGIN)
%
% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar)
% containing samples of the polar angle (in radians, CW from the
% X-axis, ranging from -pi to pi), relative to angle PHASE (default =
% 0), about ORIGIN pixel (default = (size+1)/2).
% Eero Simoncelli, 6/96.
fu... |
github | jbhuang0604/LapSRN-master | wpyrHt.m | .m | LapSRN-master/utils/matlabPyrTools/wpyrHt.m | 270 | utf_8 | 18e1a724afee99389db70484333eb05a | % [HEIGHT] = wpyrHt(INDICES)
%
% Compute height of separable QMF/wavelet pyramid with given index matrix.
% Eero Simoncelli, 6/96.
function [ht] = wpyrHt(pind)
if ((pind(1,1) == 1) | (pind(1,2) ==1))
nbands = 1;
else
nbands = 3;
end
ht = (size(pind,1)-1)/nbands;
|
github | jbhuang0604/LapSRN-master | sp0Filters.m | .m | LapSRN-master/utils/matlabPyrTools/sp0Filters.m | 6,140 | utf_8 | 0c5cd7bafff21efacd2a8ec71af90f49 | % Steerable pyramid filters. Transform described in:
%
% @INPROCEEDINGS{Simoncelli95b,
% TITLE = "The Steerable Pyramid: A Flexible Architecture for
% Multi-Scale Derivative Computation",
% AUTHOR = "E P Simoncelli and W T Freeman",
% BOOKTITLE = "Second Int'l Conf on Image Processing",
% ADDRESS = "Washington, DC"... |
github | jbhuang0604/LapSRN-master | sp5Filters.m | .m | LapSRN-master/utils/matlabPyrTools/sp5Filters.m | 6,949 | utf_8 | 305fb0c0ca0709fc34ca6c5b4bb91712 | % Steerable pyramid filters. Transform described in:
%
% @INPROCEEDINGS{Simoncelli95b,
% TITLE = "The Steerable Pyramid: A Flexible Architecture for
% Multi-Scale Derivative Computation",
% AUTHOR = "E P Simoncelli and W T Freeman",
% BOOKTITLE = "Second Int'l Conf on Image Processing",
% ADDRESS = "Washington, DC"... |
github | jbhuang0604/LapSRN-master | steer.m | .m | LapSRN-master/utils/matlabPyrTools/steer.m | 1,990 | utf_8 | 3db4dd948e0ece7c7237330b7d4f191e | % RES = STEER(BASIS, ANGLE, HARMONICS, STEERMTX)
%
% Steer BASIS to the specfied ANGLE.
%
% BASIS should be a matrix whose columns are vectorized rotated copies of a
% steerable function, or the responses of a set of steerable filters.
%
% ANGLE can be a scalar, or a column vector the size of the basis.
%
% HARMO... |
github | jbhuang0604/LapSRN-master | mkGaussian.m | .m | LapSRN-master/utils/matlabPyrTools/mkGaussian.m | 1,565 | utf_8 | 1f55e73fbc9155a38607b0667da2d7f3 | % IM = mkGaussian(SIZE, COVARIANCE, MEAN, AMPLITUDE)
%
% Compute a matrix with dimensions SIZE (a [Y X] 2-vector, or a
% scalar) containing a Gaussian function, centered at pixel position
% specified by MEAN (default = (size+1)/2), with given COVARIANCE (can
% be a scalar, 2-vector, or 2x2 matrix. Default = (min(size... |
github | jbhuang0604/LapSRN-master | factorial.m | .m | LapSRN-master/utils/matlabPyrTools/factorial.m | 273 | utf_8 | 370971eae7a2351704973c452848d194 | %% RES = factorial(NUM)
%
% Factorial function that works on matrices (matlab's does not).
% EPS, 11/02
function res = factorial(num)
res = ones(size(num));
ind = find(num > 0);
if ( ~isempty(ind) )
subNum = num(ind);
res(ind) = subNum .* factorial(subNum-1);
end
|
github | jbhuang0604/LapSRN-master | entropy2.m | .m | LapSRN-master/utils/matlabPyrTools/entropy2.m | 693 | utf_8 | c637630f7ac8912e5cb30f67551aece7 | % E = ENTROPY2(MTX,BINSIZE)
%
% Compute the first-order sample entropy of MTX. Samples of VEC are
% first discretized. Optional argument BINSIZE controls the
% discretization, and defaults to 256/(max(VEC)-min(VEC)).
%
% NOTE: This is a heavily biased estimate of entropy (it is too
% small) when you don't have much... |
github | jbhuang0604/LapSRN-master | buildSFpyr.m | .m | LapSRN-master/utils/matlabPyrTools/buildSFpyr.m | 3,256 | utf_8 | 84c0a17ac90df74f317c29833c54ffa3 | % [PYR, INDICES, STEERMTX, HARMONICS] = buildSFpyr(IM, HEIGHT, ORDER, TWIDTH)
%
% Construct a steerable pyramid on matrix IM, in the Fourier domain.
% This is similar to buildSpyr, except that:
%
% + Reconstruction is exact (within floating point errors)
% + It can produce any number of orientation bands.
% - ... |
github | jbhuang0604/LapSRN-master | spyrLev.m | .m | LapSRN-master/utils/matlabPyrTools/spyrLev.m | 668 | utf_8 | 8d25ccc2790a62ab21a20cc3d0772706 | % [LEV,IND] = spyrLev(PYR,INDICES,LEVEL)
%
% Access a level from a steerable pyramid.
% Return as an SxB matrix, B = number of bands, S = total size of a band.
% Also returns an Bx2 matrix containing dimensions of the subbands.
% Eero Simoncelli, 6/96.
function [lev,ind] = spyrLev(pyr,pind,level)
nbands = spyrNumBa... |
github | jbhuang0604/LapSRN-master | pgmWrite.m | .m | LapSRN-master/utils/matlabPyrTools/pgmWrite.m | 3,119 | utf_8 | 6425008296069df51c5c30ee1c011850 | % RANGE = pgmWrite(MTX, FILENAME, RANGE, TYPE, COMMENT)
%
% Write a MatLab matrix to a pgm (graylevel image) file.
% This format is accessible from the XV image browsing utility.
%
% RANGE (optional) is a 2-vector specifying the values that map to
% black and white, respectively. Passing a value of 'auto' (default)
% ... |
github | jbhuang0604/LapSRN-master | modulateFlip.m | .m | LapSRN-master/utils/matlabPyrTools/modulateFlip.m | 461 | utf_8 | 92f12f8068fcf49b9863851f106a5aa3 | % [HFILT] = modulateFlipShift(LFILT)
%
% QMF/Wavelet highpass filter construction: modulate by (-1)^n,
% reverse order (and shift by one, which is handled by the convolution
% routines). This is an extension of the original definition of QMF's
% (e.g., see Simoncelli90).
% Eero Simoncelli, 7/96.
function [hfilt] = m... |
github | jbhuang0604/LapSRN-master | mkFract.m | .m | LapSRN-master/utils/matlabPyrTools/mkFract.m | 843 | utf_8 | f0d97e35133978ade3a5fe34dea5d08a | % IM = mkFract(SIZE, FRACT_DIM)
%
% Make a matrix of dimensions SIZE (a [Y X] 2-vector, or a scalar)
% containing fractal (pink) noise with power spectral density of the
% form: 1/f^(5-2*FRACT_DIM). Image variance is normalized to 1.0.
% FRACT_DIM defaults to 1.0
% Eero Simoncelli, 6/96.
%% TODO: Verify that this m... |
github | jbhuang0604/LapSRN-master | mkSquare.m | .m | LapSRN-master/utils/matlabPyrTools/mkSquare.m | 2,344 | utf_8 | 7d9553e391552cd91cdd6d81348404e2 | % IM = mkSquare(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN, TWIDTH)
% or
% IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN, TWIDTH)
%
% Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar)
% containing samples of a 2D square wave, with given PERIOD (in
% pixels), DIRECTION (radians, CW from ... |
github | jbhuang0604/LapSRN-master | spyrNumBands.m | .m | LapSRN-master/utils/matlabPyrTools/spyrNumBands.m | 480 | utf_8 | 4a10cb68438c7dfc197ec00066f48fd4 | % [NBANDS] = spyrNumBands(INDICES)
%
% Compute number of orientation bands in a steerable pyramid with
% given index matrix. If the pyramid contains only the highpass and
% lowpass bands (i.e., zero levels), returns 0.
% Eero Simoncelli, 2/97.
function [nbands] = spyrNumBands(pind)
if (size(pind,1) == 2)
nbands ... |
github | jbhuang0604/LapSRN-master | reconSpyr.m | .m | LapSRN-master/utils/matlabPyrTools/reconSpyr.m | 2,671 | utf_8 | ea9e71a5f8a76eadbe8c1a2472d89344 | % RES = reconSpyr(PYR, INDICES, FILTFILE, EDGES, LEVS, BANDS)
%
% Reconstruct image from its steerable pyramid representation, as created
% by buildSpyr.
%
% PYR is a vector containing the N pyramid subbands, ordered from fine
% to coarse. INDICES is an Nx2 matrix containing the sizes of
% each subband. This is compa... |
github | phresher/MATLAB_Notes-master | ExtraSafePrimes.m | .m | MATLAB_Notes-master/exercises/Cody/ExtraSafePrimes.m | 896 | utf_8 | d32b789b4f5d2865d2c620d0ae30d2ae | % https://cn.mathworks.com/matlabcentral/cody/problems/44385-extra-safe-primes
% Did you know that the number 5 is the first safe prime? A safe prime is
% a prime number that can be expressed as 2p+1, where p is also a prime.
% To celebrate Cody's Five-Year Anniversary, write a function to determine
% if a posi... |
github | phresher/MATLAB_Notes-master | RecamanSequenceII.m | .m | MATLAB_Notes-master/exercises/Cody/RecamanSequenceII.m | 611 | utf_8 | 1ed66c596c6214396ba8f7547ea0f04b | %% https://cn.mathworks.com/matlabcentral/cody/problems/44339-recaman-sequence-ii
%%
x = 0;
y_correct = 2;
assert(isequal(RecamanII(x),y_correct))
%%
x = 90;
y_correct = 35;
assert(isequal(RecamanII(x),y_correct))
%%
x = 123456789;
y_correct = 46633;
assert(isequal(RecamanII(x),y_correct))
%%
function y =... |
github | phresher/MATLAB_Notes-master | IsReal5.m | .m | MATLAB_Notes-master/exercises/Cody/IsReal5.m | 774 | utf_8 | 1705021c5e95d7d3e2c9e48dd2e2590d | %%
n = 5;
assert(isequal(is_it_really_a_5(n),1))
%%
n = 15;
assert(isequal(is_it_really_a_5(n),0))
%%
function tf = is_it_really_a_5(n)
tf = 0;
n = num2str(n);
lengthN = length(n);
bit = mod(lengthN,3);
group = fix(lengthN/3);
switch bit
case 1
if n(1) == '5'
tf = 1;
... |
github | phresher/MATLAB_Notes-master | TheGlassHalfFull.m | .m | MATLAB_Notes-master/exercises/Cody/TheGlassHalfFull.m | 1,299 | utf_8 | 6f9c6adf0c03b42b52ea8829bb667c75 | % https://cn.mathworks.com/matlabcentral/cody/problems/44307-the-glass-half-full
% Identical glasses are placed in a triangular tower structure, such that the top level (L = 1) comprises one glass, the next level down (L = 2) comprises three glasses, the next level down (L = 3) comprises six glasses, and so on.
% Fol... |
github | phresher/MATLAB_Notes-master | PerniciousAnniversaryProblem.m | .m | MATLAB_Notes-master/exercises/Cody/PerniciousAnniversaryProblem.m | 527 | utf_8 | 5f09facb34d0a82ae2227d96a6a0f6a9 | % https://cn.mathworks.com/matlabcentral/cody/problems/2736
% Since Cody is 5 years old, it's pernicious. A Pernicious number is an
% integer whose population count is a prime. Check if the given number is pernicious.
%%
x = 5;
y_correct = true;
assert(isequal(isPernicious(x),y_correct))
%%
x = 17;
y_correct ... |
github | phresher/MATLAB_Notes-master | AsciiBirthdayCake.m | .m | MATLAB_Notes-master/exercises/Cody/AsciiBirthdayCake.m | 1,628 | utf_8 | ac0c52660ae1d91290b837348175b6fa | % https://cn.mathworks.com/matlabcentral/cody/problems/44380-ascii-birthday-cake
% Given an age and a name, give draw an ASCII birthday cake. For example,
% given the name "CODY" and the age 5, return a string with the following (no trailing spaces)
%
% 6 6 6 6 6
% | | | | |
% __|_|_|_|_|__
% { ... |
github | phresher/MATLAB_Notes-master | MissingFive.m | .m | MATLAB_Notes-master/exercises/Cody/MissingFive.m | 371 | utf_8 | a954322b0ec7d307deebf3e5adad0fd5 | assert(isequal(regexprep(char(string(dec2missing5(3))),'^0*',''),'3'))
assert(isequal(regexprep(char(string(dec2missing5(9541))),'^0*',''),'14081'))
function y = dec2missing5(x)
y = [];
while true
remainder = rem(x, 9);
remainder(remainder>=5)=remainder+1;
y = [num2str(remainder) y];
x = fix(x/9... |
github | phresher/MATLAB_Notes-master | PentagonalNumbers.m | .m | MATLAB_Notes-master/exercises/Cody/PentagonalNumbers.m | 951 | utf_8 | c46e8cf02090c73476fa7593e2b2fa58 | % https://cn.mathworks.com/matlabcentral/cody/problems/44360-pentagonal-numbers
% Your function will receive a lower and upper bound.
% It should return all pentagonal numbers within that
% inclusive range in ascending order. Additionally,
% it should return an array that indicates those numbers
% that are divisib... |
github | phresher/MATLAB_Notes-master | FivePrimeNumbers.m | .m | MATLAB_Notes-master/exercises/Cody/FivePrimeNumbers.m | 850 | utf_8 | 9b3593f73de2b951dc4aa1b653585400 | % https://cn.mathworks.com/matlabcentral/cody/problems/44305-5-prime-numbers
% Your function will be given lower and upper integer bounds. Your task is
% to return a vector containing the first five prime numbers in that range
% that contain the number five. But, if you can't find at least five such
% numbers, t... |
github | phresher/MATLAB_Notes-master | cubicAndSquare.m | .m | MATLAB_Notes-master/exercises/Cody/cubicAndSquare.m | 619 | utf_8 | 6fb23d0b54a90be335f4191bf7617aec | c = 5;
y_correct = [2 11; 5 10];
y = sumoftwosquares(c);
assert(isequal(y,y_correct))
function y = sumoftwosquares(c)
cubic = c^3;
y = [];
first = 0;
while true
first = first + 1;
second = 0;
while true
second = second + 1;
squareSum = first^2... |
github | phresher/MATLAB_Notes-master | EnergyOfAPhoton.m | .m | MATLAB_Notes-master/exercises/Cody/EnergyOfAPhoton.m | 576 | utf_8 | 6bfbcb1464e56d52379ed3c894f825b5 | % https://cn.mathworks.com/matlabcentral/cody/problems/361-energy-of-a-photon
% ? ? ? ? ? ? ?
%
% Given the frequency F of a photon in giga hertz.
%
% Find energy E of this photon in giga electron volts.
%
% Assume h, Planck's constant is about 4 femto electron-volt-second.
%
% To maximize benefits, it may... |
github | phresher/MATLAB_Notes-master | IsWin.m | .m | MATLAB_Notes-master/exercises/Cody/IsWin.m | 561 | utf_8 | b8fd6230e078941ae006656b0c966586 |
%%
x = [1 1 1
0 0 0
0 0 0];
y_correct = 1;
assert(isequal(your_fcn_name(x),y_correct))
%%
function flagWin = your_fcn_name(M)
flagWin = false;
sum1 = abs(sum(M,1));
sum1 = sum1(sum1==3);
if ~isempty(sum1)
flagWin = true;
return
end
sum2 = abs(sum(M,2));
sum2 = sum2... |
github | phresher/MATLAB_Notes-master | mySort.m | .m | MATLAB_Notes-master/1_2/homework/sort/mySort.m | 1,918 | utf_8 | 48df6a98d6971c4b3dd4d3abda1c14d7 | function A = mySort(A, algorithm)
% Practice several sort algorithms in one function.
L=length(A);
switch algorithm
% insert sort
case 'insert'
for i=2:L
for j=i:-1:2
if A(j)<A(j-1)
[A(j), A(j-1)] = swap(A(j), A(j-1));
els... |
github | Roboy/roboy_darkroom-master | multi_lighthouse_pose_estimator.m | .m | roboy_darkroom-master/darkroom/scripts/multi_lighthouse_pose_estimator.m | 3,296 | utf_8 | e416582690c4abd06209336b785baa5e | %% load the data and parse into per sensor per lighthouse
clear
M = csvread('record_simulated_lighthouse0_calibration.log',1);
[sensor_entries,asort] = sort(M(:,2));
b = M(asort,2:end);
s = unique(sensor_entries);
global sensors
sensors = cell(2,length(s));
for i=1:length(s)
temp = b(sensor_entries==i-1,:);
[~,... |
github | Roboy/roboy_darkroom-master | mergeimports.m | .m | roboy_darkroom-master/darkroom/scripts/YAMLREADER/mergeimports.m | 5,334 | utf_8 | 2564bb2fc532430c64ab664d1cfceb4c | %==========================================================================
% Walks through a tree structure data. Whenever it finds a structure, which
% have field named 'import' it assumes that in that field is a cell array
% and merges all structures found in that array. Parameter verb is used for
% debugging pu... |
github | Roboy/roboy_darkroom-master | ReadYamlRaw.m | .m | roboy_darkroom-master/darkroom/scripts/YAMLREADER/ReadYamlRaw.m | 8,106 | utf_8 | e088fcbe02b123cafe72ee93107295fe | %==========================================================================
% Reads YAML file, converts YAML sequences to MATLAB cell columns and YAML
% mappings to MATLAB structs
%
% filename ... name of yaml file to be imported
% verbose ... verbosity level (0 or absent = no messages,
% ... |
github | Roboy/roboy_darkroom-master | makematrices.m | .m | roboy_darkroom-master/darkroom/scripts/YAMLREADER/makematrices.m | 5,810 | utf_8 | afb188bbb6dfad249186bc0158a07fa1 | %==========================================================================
% Recursively walks through a Matlab hierarchy and substitutes cell vectors
% by a matrix when possible.
% Specifically substitutes cell objects like
%
% {{1,2,3},{4,5,6}}
%
% by
%
% {1,2,3;4,5,6}
%
% It leaves other objects ... |
github | Roboy/roboy_darkroom-master | deflateimports.m | .m | roboy_darkroom-master/darkroom/scripts/YAMLREADER/deflateimports.m | 1,847 | utf_8 | 44bea4918316676d13e94582fc62ed7b | %==========================================================================
% Transforms structures:
% - import: A, B
% - import: C
% - import: D, E, F
%
% into:
% - import: A, B, C, D, F, F
%
%==========================================================================
function result = deflateimports(... |
github | Roboy/roboy_darkroom-master | dosubstitution.m | .m | roboy_darkroom-master/darkroom/scripts/YAMLREADER/dosubstitution.m | 1,084 | utf_8 | 4c5ec59493e7d2534379763e2d50520c | %==========================================================================
%==========================================================================
function result = dosubstitution(r, dictionary)
if ~exist('dictionary','var')
dictionary = {};
end;
result = recurse(r, 0, dictionary);
end... |
github | Roboy/roboy_darkroom-master | merge_struct.m | .m | roboy_darkroom-master/darkroom/scripts/YAMLREADER/merge_struct.m | 1,366 | utf_8 | afc9cfb74c801763c1a771acc6be9aec |
%--------------------------------------------------------------------------
% Does merge of two structures. The result is structure which is union of
% fields of p and s. If there are equal field names in p and s, fields in p
% are overwriten with their peers from s.
%
function result = merge_struct(p, s, donotm... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.