This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [images, images_RGB] = readDataFromPath(DataPath, image_size) | |
% Reads the image content of the given rootpath. Assumes that we have a | |
% root folder includes sub folder for each class of images | |
images = {}; | |
images_RGB = {}; | |
root_dir = dir(DataPath); | |
root_dir = root_dir([root_dir.isdir]); | |
folder_names = {root_dir.name}; | |
root_dir = root_dir(~ismember(folder_names,{'.','..'})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function im_array=gridsplit(im,grid_x,grid_y,width_fact,height_fact,left_extra,right_extra,top_extra,bottom_extra) | |
%Crops a grid of images out of one image | |
% im_array=gridsplit(im,...) returns an image array im_array that has | |
% size (MxNxPxR) in which M the width, N the height, P the channel and R | |
% the amount of images destilled from the grid. So it puts all the | |
% gridparts in R which has size (grid_x*grid_y) | |
% You get the idea. Otherwise more info on: www.timzaman.nl | |
% | |
% grid_x = Amount of horizontal patches | |
% grid_y = Amount of vertical patches |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function[binary_codes,G_vecs] = WTA_kernel_binary(X,G_vecs,G, K) | |
% G is number of permutation vectors | |
% K is the insterest span | |
if size(G_vecs,1) == 0 | |
G_vec = zeros(G,size(X,2)); | |
for i = 1:G | |
G_vecs(i,:) = randperm(size(X,2),size(X,2)); | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function[ROOT_DIR] = read_dir(PATH) | |
ROOT_DIR = dir(PATH); | |
% video_names = ls(fullfile(PATH,'*.mp4')); | |
file_names = {ROOT_DIR.name}; | |
ROOT_DIR = ROOT_DIR(~ismember(file_names,{'.','..'})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% | |
% Normalize data columnwise to reduce different unit's effect | |
% | |
function[X_norm, val] = normalize_data(X,val) | |
% if ~exist('va','var') | |
% [val,ind] = max(X,[],1); | |
% end | |
% X_norm = bsxfun(@rdivide, X, val); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function[X_norm, mu, sigma] = zscore_normalize_data(X, mu, sigma) | |
X_norm=bsxfun(@minus,X,mu); | |
X_norm=bsxfun(@rdivide,X_norm,sigma); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
from BeautifulSoup import BeautifulSoup | |
import pdb | |
import os | |
import htmlentitydefs | |
from BeautifulSoup import BeautifulStoneSoup | |
import HTMLParser | |
import cgi | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This code stupidly take the lined list of movie names, suppossely scraped from imdb | |
and download them as a first instance of YouTube. It also converts the downloaded video mp4 | |
to avi version to be processed in Matlab. | |
erogol - [email protected] | |
It needs; | |
Beautifulsoup : easy_install BeautifulSoup -- for scraping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mix = gmm(dim, ncentres, covar_type, ppca_dim) | |
%GMM Creates a Gaussian mixture model with specified architecture. | |
% | |
% Description | |
% MIX = GMM(DIM, NCENTRES, COVARTYPE) takes the dimension of the space | |
% DIM, the number of centres in the mixture model and the type of the | |
% mixture model, and returns a data structure MIX. The mixture model | |
% type defines the covariance structure of each component Gaussian: | |
% 'spherical' = single variance parameter for each component: stored as a vector | |
% 'diag' = diagonal matrix for each component: stored as rows of a matrix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [varargout] = rdir(rootdir,varargin) | |
% Lists the files in a directory and its sub directories. | |
% | |
% function [D] = rdir(ROOT,TEST) | |
% | |
% Recursive directory listing. | |
% | |
% ROOT is the directory starting point and includes the | |
% wildcard specification. | |
% The function returns a structure D similar to the one |
OlderNewer