Skip to content

Instantly share code, notes, and snippets.

View pjspillai's full-sized avatar

Pree pjspillai

  • San Francisco Bay Area
View GitHub Profile
@pjspillai
pjspillai / mat.cpp
Created February 29, 2012 20:34
2D matrix convolution
/*
Explanation:
The 2D matrix is treated as a 1D vector
An element M[x][y] will be represented as a vector M[id], where id = (y+x*col)
e.g. M[1][2] for a 3*3 matrix would be represented as a vector M[5].
Each matrix M is thus, represented as an array of structs, with the following fields:
value - unsigned char element value
up , down, left, right - boolean values indicating whether the element lies on the border of the matrix
/** Global Variables **/
bool DispThreadHasFinished;
bool MainThreadHasFinished;
iplImage* myImg;
/** Main Loop that loops at >100fps **/
main() {
DispThreadHasFinished=FALSE;
MainThreadHasFinished=FALSE;
CreateThread(..,..,Thread,..);
@pjspillai
pjspillai / harris.m
Created March 15, 2012 00:47
Harris Corner Detector
% Pree
% EECS - 442
% Description - This code helps plot corners of the image using the harris
% corner detector.
% The value of K chosen is 0.04(default) since it seems to give finer
% accuracy in detecting points.
clc
function [r,c, rsubp, csubp] = nonmaxsup(cim, radius, thresh, im)
subPixel = nargout == 4; % We want sub-pixel locations
[rows,cols] = size(cim);
sze = 2*radius+1; % Size of dilation mask.
mx = ordfilt2(cim,sze^2,ones(sze)); % Grey-scale dilate.
#include <iostream>
#include <stdio.h>
#include <math.h>
#include "mpi.h"
#include <vector>
#include <ctdlib>
#include <fstream>
#define PI 3.14159265
using namespace std;
@pjspillai
pjspillai / Notes on iter.cpp
Created March 15, 2012 01:07
Fixed Point Iteration, MPI, Parallel Computing
The approach I used to allocate the elements is by splitting the matrix into smaller matrices and allocating one to each of the processors.
Each of the smaller matrix, belonging to a processor has a global id in the form of xdim and ydim based on it’s location in the bigger matrix.
Xdim=proc_id/sqrt(num of processors)
Ydim=proc_id/sqrt(num of processors)
By dividing the total no. of elements by the number of processors, and based on the remainder, all extra elements can be evenly distributed among the processors, starting from the initial one.
Six empty arrays were created for sti=oring the border element information: top row, bottom row, left column, right column, diagonal right corner element for sending data, top left corner diagonal element for receiving data.
@pjspillai
pjspillai / gist:2553470
Created April 29, 2012 22:01
Cal_Energy.m
function [Eng_Org] = Cal_Eng(N1); %function for calling from main program
Ini_val=0; %fvariable for initial value
for var_1=1:20
% Reading The XLS File
A=input('Enter Signal No:','s');
path=['H:\KRCL1\xls files for signal data\XLS-procdbs\Detection + Clutch Tight\Detection + Clutch Tight (VN EN)\ds',A,'.xls']; %Calculatign the path of the XLS file
@pjspillai
pjspillai / gist:2553570
Created April 29, 2012 22:29
Reject_Outliers.m
% Description - This code executes the function Reject_Outliers which finds
% the set of outliers using RANSAC
function [rej] = Reject_Outliers( B1, B2 )
threshold=5.65;
p=0.95;
w=(0.83);
/// EYETRACKER
///
/// MAIN.CPP
///
/// AUTHOR : Pree
///
/// PROGRAM NAME : main.cpp
///
/// LAST REVISED : 15th Oct, 2011
///
#ifndef BDD_TABLES_H
#define BDD_TABLES_H
/*
* File Bdd_tables.h
*
* Defines the class Bdd_tables, along with a structs computed_table_key
* and unique_table_key
*/