<s> import os . path <EOL> from Image import composite , LINEAR <EOL> import pyvision as pv <EOL> from pyvision . edge . sobel import sobel <EOL> from pyvision . point . DetectorSURF import DetectorSURF <EOL> import cv <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> ilog = pv . ImageLog ( ) <EOL> source_name = os . path . join ( pv . __path__ [ <NUM_LIT:0> ] , '<STR_LIT:data>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> im = pv . Image ( source_name ) <EOL> print "<STR_LIT>" % str ( im . size ) <EOL> im = pv . AffineScale ( <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) . transformImage ( im ) <EOL> print "<STR_LIT>" % str ( im . size ) <EOL> ilog . log ( im , '<STR_LIT>' ) <EOL> edges = sobel ( im , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:0> ) <EOL> ilog . log ( edges , '<STR_LIT>' ) <EOL> mat = im . asMatrix2D ( ) <EOL> high = mat > <NUM_LIT> <EOL> low = mat < <NUM_LIT:50> <EOL> mask = high <EOL> ilog . log ( pv . Image ( <NUM_LIT:1.0> * mask ) , '<STR_LIT>' ) <EOL> e = edges . asPIL ( ) . convert ( '<STR_LIT>' ) <EOL> m = pv . Image ( <NUM_LIT:1.0> * mask ) . asPIL ( ) <EOL> i = im . asPIL ( ) <EOL> logo = pv . Image ( composite ( i , e , m ) ) <EOL> ilog . log ( logo , '<STR_LIT>' ) <EOL> logo_surf = logo . copy ( ) <EOL> sm = pv . Image ( im . asPIL ( ) . resize ( ( <NUM_LIT> , <NUM_LIT> ) , LINEAR ) ) <EOL> detector = DetectorSURF ( ) <EOL> points = detector . detect ( sm ) <EOL> for score , pt , radius in points : <EOL> logo_surf . annotateCircle ( pt * <NUM_LIT:4> , radius * <NUM_LIT:4> ) <EOL> ilog . log ( logo_surf , '<STR_LIT>' ) <EOL> print "<STR_LIT>" <EOL> imontage = pv . ImageMontage ( [ im , edges , logo , logo_surf ] , layout = ( <NUM_LIT:2> , <NUM_LIT:2> ) , tileSize = im . size , gutter = <NUM_LIT:3> , byrow = True , labels = None ) <EOL> imontage . show ( window = "<STR_LIT>" , delay = <NUM_LIT:0> ) <EOL> print "<STR_LIT>" <EOL> ilog . show ( ) </s>
