Skip to content

Instantly share code, notes, and snippets.

@tonyfast
tonyfast / Driver.m
Last active July 23, 2019 21:38
Generalized Peak and Valley Finding function in Matlab using the Image Processing Toolbox
%% Motivation
% This Matlab function is motivated by http://tonyfast.com/nsf-goali/2014/08/29/Peak-Finding/
%% Example use of Find_Peaks on a 2-D array
N = 100;
% Example Dataset
T = peaks( N );
%% Find Peaks using the default filter
@tonyfast
tonyfast / example.m
Created September 10, 2014 20:04
Example Script for COmputing on Hazelnut Data
filename = 'macadamia.mat'
if ~exist( filename, 'file' );
urlwrite( ... Write a url to a file
'https://dl.dropboxusercontent.com/u/22455492/natural-3d/macadamia.mat', ... The requested url
filename )
end % if:~exist
%%
load( filename ); % Variable is input as structure
@tonyfast
tonyfast / binary_edge.m
Created September 12, 2014 18:38
Edge Detection for Binary Images in Matlab
function edge = binary_edge( image )
% An approximate algorithm for finding edges in binary images.
%
% The algorithm shifts the images one voxel in each direction.
% It compares the difference betwee the original image and the shifted image.
% Nonzero values indicate edge values
DIMS = ndims(image);
shifts = vertcat( eye(DIMS), ...
@tonyfast
tonyfast / filelist.m
Created September 17, 2014 23:42
Create a File Name List Recursively through a directory in matlab
d = cd
paths = strsplit( genpath( d ), ':' );
fo = fopen( 'list.txt', 'w')
for pp = 1 : numel( paths )
ff = dir( paths{ pp } )
[~,b] = fileparts(paths{pp})
if numel( ff ) > 0 & numel(strfind(paths{pp},'.git')) == 0
@tonyfast
tonyfast / install.m
Created September 22, 2014 16:17
Install YAML-Matlab in Matlab
fn = tempname;
urlwrite( 'http://yamlmatlab.googlecode.com/files/YAMLMatlab_0.4.3.zip', ... YAMLUrl
fn );
unzip( fn, './yaml-matlab' )
delete( fn );
@tonyfast
tonyfast / SwiftStack-and-FrontMatter.ipynb
Created October 8, 2014 14:27
Connecting to SwiftStack + An Effective Reuse of Blog Posts
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tonyfast
tonyfast / adjust_normalize.m
Created October 8, 2014 20:03
ImAdjust and Normalize N-D Images in Matlab
normalize = @(A)( A-min(A(:)) ) ./ ( max(A(:)) - min(A(:)) )
adjust = @(A)reshape( ... back to original shape
imadjust( ... adjust image
reshape( ... flatten to 2-D image
normalize(A), ... normalize from zero to one
size(A,1), numel(A)./size(A,1))), ... Reshape to 2-D array
size(A) ... Reshape back to original size
);
@tonyfast
tonyfast / clusterdemo.m
Last active August 29, 2015 14:07
A simple clustering function that uses graph power for connectivity
%% Example use of simplecluster
X = rand(20,2);
cutoff = .1;
[ Xf, class ] =simplecluster( X, cutoff );
h(1) = scatter( X(:,1), X(:,2), 50, class, 'filled');
set(h(1), 'MarkerEdgeColor','k')
hold on
h(2) = plot( Xf(:,1), Xf(:,2), 'k+', ...
@tonyfast
tonyfast / noneigen.m
Created October 13, 2014 14:51
Create noneigen discretization of the equispaced local state spaces
function [MF, bins ] = noneigen( X, xx );
%%
% X :: values to be binned
% xx :: cellarray for the local state space
dims = cumprod(cellfun(@(x)numel(x),xx));
%%
MF = zeros( size(X,1), ...
dims(end) );
@tonyfast
tonyfast / fastradialv.m
Created October 13, 2014 18:48
Vectorized Fast Radial Symmetric Transform on Image Data. Adopted from http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/Spatial/fastradial.m
% FASTRADIAL - Loy and Zelinski's fast radial feature detector
%
% An implementation of Loy and Zelinski's fast radial feature detector
%
% Usage: S = fastradial(im, radii, alpha, beta)
%
% Arguments:
% im - Image to be analysed
% radii - Array of integer radius values to be processed
% suggested radii might be [1 3 5]