Skip to content

Instantly share code, notes, and snippets.

@vighneshbirodkar
vighneshbirodkar / csr_test.py
Created May 19, 2014 17:28
scipy csr_matrix demo
import numpy as np
from scipy.sparse import *
import pygraphviz as pgv
import random
a = np.array([[1,0,0,0],
[5,2,0,0],
[1,7,2,0],
[0,0,0,4]])
@vighneshbirodkar
vighneshbirodkar / ws-test.py
Created May 25, 2014 20:18
Watershed 3D test
import graph
import time
import sys
import tiffile as tf
from skimage import io
from matplotlib import pyplot as plt
import numpy as np
import random
from skimage.morphology import watershed
from scipy.ndimage import label
@vighneshbirodkar
vighneshbirodkar / dict_array_test.py
Created June 9, 2014 17:04
dict vs numpy arrays
import sets
import sys
import memory_profiler as mp
import numpy as np
def test_list(n):
a = np.zeros((n,),dtype = int)
b = np.zeros((n,),dtype = int)
del a
import numpy as np
import matplotlib.pyplot as plt
N = 4
# Custom, nx , LIL , CSR
# First data set
construct_mem1 = (10.92,29.47,8.03,17.17)
merge_mem1 = (11.26,29.89,8.28,476.95)
@vighneshbirodkar
vighneshbirodkar / max_time.py
Created June 23, 2014 17:19
Comapring Numpy vs Python to find maximum
import random
import numpy as np
import time
class ABC:
def __init__(self,x):
self.prop = x
def __lt__(self, other):
return self.prop < other.prop
def __le__(self, other):
# NESTED SAMPLING MAIN PROGRAM
# (GNU General Public License software, (C) Sivia and Skilling 2006)
# This file was translated to Python by Issac Trotts in 2007.
from math import *
import random
# or so
DBL_MAX = 1e300
@vighneshbirodkar
vighneshbirodkar / prog.md
Last active August 29, 2015 14:03
Progammind Experience
@vighneshbirodkar
vighneshbirodkar / mark.py
Created April 4, 2015 17:57
Python snippet to generate captions based on EXIF data
from PIL import Image, ImageDraw, ImageFont
import os
from PIL.ExifTags import TAGS
# get an image
fnt = ImageFont.truetype('Ubuntu-R.ttf', 30)
for name in os.listdir('images'):
print name
img = Image.open('images/' + name)
@vighneshbirodkar
vighneshbirodkar / result.txt
Created May 5, 2015 19:49
edge rag line profile
Timer unit: 1e-06 s
Total time: 11.423 s
File: /home/vighnesh/git/scikit-image/skimage/future/graph/rag.py
Function: rag_boundary at line 324
Line # Hits Time Per Hit % Time Line Contents
==============================================================
324 @profile
325 def rag_boundary(labels, edge_map, connectivity=2):
@vighneshbirodkar
vighneshbirodkar / interests.md
Created May 7, 2015 17:35
a Markdown file to hold interests and projects

Hello