יום חמישי, 9 במאי 2013

Toy Tetragraph Hash

At my  Security Computer course i was asked in one of my exercise to build a machine that imitiate Hash procedure.But instead of bits the hash input is chars.

The mechanism of the hash function is illustrated here:

and that is the small python code to compute the hash function:


import numpy as np

text="I leave twenty million dollars to my friendly cousin Bill"
text="AYHG" +"A"*12 +"A"*32
print(text)
#this is the input for the tth...
IV=(0,0,0,0) # initial Vector


def shiftlist(l,n):  #this function do the shift list
    l=list(l)
    Shifted=l[n:]+l[:n]
    return Shifted


text=text.replace(" ",'') #ignore spaces
text=text.lower()         #ignore case sensitive
text=[ord(c)-97 for c in text] #convert text to ascii

lenght = len(text) # move 16 char every time..
for x in range(int(lenght/16)):

    Matrix =np.array(text[16*x:16*(x+1)]).reshape(4,4) #convert 16 string to 4X4 matrix
    
    sumMatrix=(Matrix.sum(axis=0)) #sum the Matrix
    for x in range(3):   # rotate each row
        Matrix[x,:] =shiftlist(Matrix[x,:],x+1)

    #ugly last row rotation:
    temp =Matrix[3,0];Matrix[3,0]=Matrix[3,3];Matrix[3,3]=temp
    temp =Matrix[3,1];Matrix[3,1]=Matrix[3,2];Matrix[3,2]=temp

    ##Sum the  columns + the rotate colums +IV
    
    IV=(IV +(Matrix.sum(axis=0))+sumMatrix)%26
    

#now IV is the output
for i in range(4):  #print the string
    print(chr(IV[i]+97),end=" ")

#######################################################

The next challange is to find a collision.
i leave it as a riddle for you.

יום שבת, 13 באפריל 2013

My advanced computer Vision Assigment (Or : how to make an angry giraffe to disappear)


The university task of my CV course asked me & my friend (let's call him UV) to take the basic knowledge that we acquire into something practice and cool one. 

We had to take a movie from the internet (that's take from one fixed point) 
and fulfill the 3 missions bellow:

1) remove any object from the movie.
2) insert a fixed object into the movie.
3) Tracking a motion object inside the movie.


Surprisingly or not, all those 3 tasks related to a one feature that known to all:
Panorama feature. (the feature that take a wide-angle shot by attaching several pictures)

BTW- this is why the requirement to take the movie from one single fixed-point.


-So what is the technique behind the scene?

1)
2)
3)


The code:


The videos :

1)Remove
original video: 
remove giraffe:

2)Insert
original video:
inserted object:
 
3)Tracking
TDB