def makeConventionManyPano(): conv1 = io.imread("convention/convention-1.png") conv2 = io.imread("convention/convention-2.png") conv3 = io.imread("convention/convention-3.png") pointList1 = [ np.array([298, 206, 1], dtype=np.float64), np.array([267, 320, 1], dtype=np.float64), np.array([170, 325, 1], dtype=np.float64), np.array([172, 188, 1], dtype=np.float64), ] pointList2 = [ np.array([309, 70, 1], dtype=np.float64), np.array([270, 175, 1], dtype=np.float64), np.array([182, 176, 1], dtype=np.float64), np.array([179, 42, 1], dtype=np.float64), ] listOfPairs1 = zip(pointList1, pointList2) pointList3 = [ np.array([288, 173, 1], dtype=np.float64), np.array([267, 306, 1], dtype=np.float64), np.array([219, 306, 1], dtype=np.float64), np.array([217, 210, 1], dtype=np.float64), ] pointList4 = [ np.array([298, 15, 1], dtype=np.float64), np.array([269, 151, 1], dtype=np.float64), np.array([225, 148, 1], dtype=np.float64), np.array([221, 55, 1], dtype=np.float64), ] listOfPairs2 = zip(pointList3, pointList4) listOfImages = [conv1, conv2, conv3] listOfListOfPairs = [listOfPairs1, listOfPairs2] refIndex = 1 out = a6.stitchN(listOfImages, listOfListOfPairs, refIndex) io.imwrite(out, "MyPanoMany.png")
def testStitchNVancouver(): #im1=io.imread('vancouverPan/vancouver4.png') #im2=io.imread('vancouverPan/vancouver3.png') im1=io.imread('vancouverPan/vancouver2.png') im2=io.imread('vancouverPan/vancouver1.png') im3=io.imread('vancouverPan/vancouver0.png') imList = [im1, im2, im3]#, im4, im5] pointList1a=[np.array([99, 326, 1], dtype=np.float64), np.array([271, 247, 1], dtype=np.float64), np.array([180, 178, 1], dtype=np.float64), np.array([179, 276, 1], dtype=np.float64)] pointList2a=[np.array([124, 169, 1], dtype=np.float64), np.array([284, 98, 1], dtype=np.float64), np.array([189, 25, 1], dtype=np.float64), np.array([194, 125, 1], dtype=np.float64)] listOfPairs2=zip(pointList1a, pointList2a) pointList1b=[np.array([176, 300, 1], dtype=np.float64), np.array([318, 204, 1], dtype=np.float64), np.array([258, 203, 1], dtype=np.float64), np.array([181, 138, 1], dtype=np.float64)] pointList2b=[np.array([179, 180, 1], dtype=np.float64), np.array([317, 86, 1], dtype=np.float64), np.array([256, 87, 1], dtype=np.float64), np.array([173, 15, 1], dtype=np.float64)] listOfPairs1=zip(pointList1b, pointList2b) #pointList1_3=[np.array([165, 186, 1], dtype=np.float64), np.array([173, 146, 1], dtype=np.float64), np.array([188, 80, 1], dtype=np.float64), np.array([164, 40, 1], dtype=np.float64)] #pointList2_3=[np.array([153, 298, 1], dtype=np.float64), np.array([162, 253, 1], dtype=np.float64), np.array([178, 188, 1], dtype=np.float64), np.array([156, 151, 1], dtype=np.float64)] #listOfPairs3=zip(pointList1_3, pointList2_3) #pointList1_4=[np.array([156, 151, 1], dtype=np.float64), np.array([220, 34, 1], dtype=np.float64), np.array([184, 160, 1], dtype=np.float64), np.array([186, 89, 1], dtype=np.float64)] #pointList2_4=[np.array([151, 304, 1], dtype=np.float64), np.array([226, 189, 1], dtype=np.float64), np.array([180, 316, 1], dtype=np.float64), np.array([190, 239, 1], dtype=np.float64)] #listOfPairs4=zip(pointList1_4, pointList2_4) listOfListOfPairs = [listOfPairs1, listOfPairs2]# listOfPairs4] #listOfListOfPairs = [listOfPairs]#, listOfPairs2]#, listOfPairs2]#, listOfPairs3, listOfPairs4] out = a6.stitchN(imList, listOfListOfPairs, 0) io.imwrite(out, "vancouver_stitchN.png")
def testStitchMIT(): im1=io.imread('mit1.png') im2=io.imread('mit0.png') pointList1=[np.array([196, 245, 1], dtype=np.float64), np.array([250, 320, 1], dtype=np.float64), np.array([138, 306, 1], dtype=np.float64), np.array([113, 260, 1], dtype=np.float64)] pointList2=[np.array([200, 48, 1], dtype=np.float64), np.array([255, 115, 1], dtype=np.float64), np.array([150, 109, 1], dtype=np.float64), np.array([119, 65, 1], dtype=np.float64)] listOfPairs=zip(pointList1, pointList2) out = a6.stitch(im1, im2, listOfPairs) io.imwrite(out, "MyPano.png")
def testCompositeStata(): im1=io.imread('stata/stata-1.png') im2=io.imread('stata/stata-2.png') pointList1=[np.array([209, 218, 1]), np.array([425, 300, 1]), np.array([209, 337, 1]), np.array([396, 336, 1])] pointList2=[np.array([232, 4, 1]), np.array([465, 62, 1]), np.array([247, 125, 1]), np.array([433, 102, 1])] listOfPairs=zip(pointList1, pointList2) out = a6.stitchN([im1, im2], [listOfPairs], 0) io.imwrite(out, "stata_stitchN.png")
def testStitchFun(): im1=io.imread('fun/room1.png') im2=io.imread('fun/room2.png') pointList1=[np.array([327, 258, 1], dtype=np.float64), np.array([75, 437, 1], dtype=np.float64), np.array([224, 364, 1], dtype=np.float64), np.array([423, 449, 1], dtype=np.float64)] pointList2=[np.array([294, 50, 1], dtype=np.float64), np.array([50, 227, 1], dtype=np.float64), np.array([190, 161, 1], dtype=np.float64), np.array([366, 240, 1], dtype=np.float64)] listOfPairs=zip(pointList1, pointList2) out = a6.stitch(im1, im2, listOfPairs) io.imwrite(out, "MyPano.png")
def testStitchScience(): im1=io.imread('science/science-1.png') im2=io.imread('science/science-2.png') pointList1=[np.array([307, 15, 1], dtype=np.float64), np.array([309, 106, 1], dtype=np.float64), np.array([191, 102, 1], dtype=np.float64), np.array([189, 47, 1], dtype=np.float64)] pointList2=[np.array([299, 214, 1], dtype=np.float64), np.array([299, 304, 1], dtype=np.float64), np.array([182, 292, 1], dtype=np.float64), np.array([183, 236, 1], dtype=np.float64)] listOfPairs=zip(pointList1, pointList2) out = a6.stitch(im1, im2, listOfPairs) io.imwrite(out, "science_stitch.png")
def test_computeFactor(): im2=io.imread('data/design-2.png') im3=io.imread('data/design-3.png') w2=a5.computeWeight(im2) w3=a5.computeWeight(im3) out=a5.computeFactor(im2, w2, im3, w3) if abs(out-50.8426955376)<1 : print 'Correct'
def testStitchStata(): im1 = io.imread("stata/stata-1.png") im2 = io.imread("stata/stata-2.png") pointList1 = [np.array([209, 218, 1]), np.array([425, 300, 1]), np.array([209, 337, 1]), np.array([396, 336, 1])] pointList2 = [np.array([232, 4, 1]), np.array([465, 62, 1]), np.array([247, 125, 1]), np.array([433, 102, 1])] listOfPairs = zip(pointList1, pointList2) out = a6.stitch(im1, im2, listOfPairs) io.imwrite(out, "stata_stitch.png")
def testComputeTransformedBBox(): im1=io.imread('stata/stata-1.png') im2=io.imread('stata/stata-2.png') pointList1=[np.array([209, 218, 1]), np.array([425, 300, 1]), np.array([209, 337, 1]), np.array([396, 336, 1])] pointList2=[np.array([232, 4, 1]), np.array([465, 62, 1]), np.array([247, 125, 1]), np.array([433, 102, 1])] listOfPairsS=zip(pointList1, pointList2) HS=a6.computeHomography(listOfPairsS) shape = np.shape(im2) print a6.computeTransformedBBox(shape, HS)
def testComputeAndApplyHomographyFun(): im1=io.imread('fun/room1.png') im2=io.imread('fun/room2.png') pointList1=[np.array([327, 258, 1], dtype=np.float64), np.array([75, 437, 1], dtype=np.float64), np.array([224, 364, 1], dtype=np.float64), np.array([423, 449, 1], dtype=np.float64)] pointList2=[np.array([294, 50, 1], dtype=np.float64), np.array([50, 227, 1], dtype=np.float64), np.array([190, 161, 1], dtype=np.float64), np.array([366, 240, 1], dtype=np.float64)] listOfPairsS=zip(pointList1, pointList2) HS=a6.computeHomography(listOfPairsS) #multiply by 0.2 to better show the transition out=im2*0.5 a6.applyHomography(im1, out, HS, True) io.imwrite(out, "fun.png")
def testComputeAndApplyHomographyStata(): im1=io.imread('stata/stata-1.png') im2=io.imread('stata/stata-2.png') pointList1=[np.array([209, 218, 1]), np.array([425, 300, 1]), np.array([209, 337, 1]), np.array([396, 336, 1])] pointList2=[np.array([232, 4, 1]), np.array([465, 62, 1]), np.array([247, 125, 1]), np.array([433, 102, 1])] listOfPairsS=zip(pointList1, pointList2) HS=a6.computeHomography(listOfPairsS) #multiply by 0.2 to better show the transition out=im2*0.5 a6.applyHomography(im1, out, HS, True) io.imwrite(out, "stata_computeAndApplyHomography.png")
def testNPanoGuedelon(): im1 = io.imread("guedelon/guedelon-1.png") im2 = io.imread("guedelon/guedelon-2.png") im3 = io.imread("guedelon/guedelon-3.png") im4 = io.imread("guedelon/guedelon-4.png") pointList1 = [ np.array([444, 306, 1], dtype=np.float64), np.array([198, 210, 1], dtype=np.float64), np.array([271, 198, 1], dtype=np.float64), np.array([399, 203, 1], dtype=np.float64), ] pointList2 = [ np.array([434, 114, 1], dtype=np.float64), np.array([188, 44, 1], dtype=np.float64), np.array([261, 24, 1], dtype=np.float64), np.array([394, 18, 1], dtype=np.float64), ] listOfPairs1 = zip(pointList1, pointList2) pointList3 = [ np.array([419, 293, 1], dtype=np.float64), np.array([384, 234, 1], dtype=np.float64), np.array([254, 274, 1], dtype=np.float64), np.array([301, 324, 1], dtype=np.float64), ] pointList4 = [ np.array([401, 142, 1], dtype=np.float64), np.array([372, 88, 1], dtype=np.float64), np.array([245, 139, 1], dtype=np.float64), np.array([292, 179, 1], dtype=np.float64), ] listOfPairs2 = zip(pointList3, pointList4) pointList5 = [ np.array([245, 139, 1], dtype=np.float64), np.array([403, 143, 1], dtype=np.float64), np.array([379, 220, 1], dtype=np.float64), np.array([273, 311, 1], dtype=np.float64), ] pointList6 = [ np.array([236, 70, 1], dtype=np.float64), np.array([398, 69, 1], dtype=np.float64), np.array([371, 149, 1], dtype=np.float64), np.array([267, 238, 1], dtype=np.float64), ] listOfPairs3 = zip(pointList5, pointList6) listOfImages = [im1, im2, im3, im4] listOfListOfPairs = [listOfPairs1, listOfPairs2, listOfPairs3] refIndex = 2 out = a6.stitchN(listOfImages, listOfListOfPairs, refIndex) io.imwrite(out, "guedelon_stitchNFast.png")
def makeStreetSign(): sign = io.imread("highway.png") people = io.imread("coverphoto.png") h, w = people.shape[0] - 1, people.shape[1] - 1 peoplecorners = [np.array([0, 0, 1]), np.array([0, w, 1]), np.array([h, w, 1]), np.array([h, 0, 1])] pointList1 = [ np.array([105, 94, 1], dtype=np.float64), np.array([110, 200, 1], dtype=np.float64), np.array([162, 200, 1], dtype=np.float64), np.array([159, 92, 1], dtype=np.float64), ] listOfPairs = zip(peoplecorners, pointList1) H = a6.computeHomography(listOfPairs) a6.applyHomography(people, sign, H, True) io.imwrite(sign, "Fun.png")
def main(): im=imageIO.imread('rgb.png') lumi=im[:,:,1] #I'm lazy, I'll just use green smallLumi=numpy.transpose(lumi[0:5, 0:5]) # Replace if False: by if True: once you have implement the required functions. # Exercises: if False: outputNP, myFunc=smoothGradientNormali print ' Dimensionality of Halide Func:', myFunc.dimensions() imageIO.imwrite(outputNP, 'normalizedGradient.png') if False: outputNP, myFunc=smoothGradientNormali print ' Dimensionality of Halide Func:', myFunc.dimensions() imageIO.imwrite(outputNP, 'rgbWave.png') if False: outputNP, myFunc=a11.sobel(lumi) imageIO.imwrite(outputNP, 'sobelMag.png') print ' Dimensionality of Halide Func:', myFunc.dimensions() if False: L=pythonCodeForBoxSchedule5(smallLumi) print L if False: L=pythonCodeForBoxSchedule6(smallLumi) print L if False: L=pythonCodeForBoxSchedule7(smallLumi) print L
def getPNGsInDir(path): fnames = glob.glob(path+"*.png") out=[] for f in fnames: #print f imi = io.imread(f) out.append(imi) return out
def timeChallenge(): im = io.imread('zebra.png') t1=time.time() a3.gaussianBlur(im,2, 3) print time.time()-t1, 'seconds for Gaussian Blur' t2=time.time() a3.convolve(im, a3.gauss2D()) print time.time()-t2, 'seconds for Convolve'
def test_convolve_gauss(): im=io.imread('pru.png') gauss3=np.array([[1, 2, 1], [2, 4, 2], [1, 2, 1]]) kernel=gauss3.astype(float) kernel=kernel/sum(sum(kernel)) out=a3.convolve(im, kernel) io.imwrite(out, 'my_gaussblur.png')
def getPNGsInDir(path): '''gets the png's in a folder and puts them in out.''' fnames = glob.glob(path+"*.png") out=[] for f in fnames: imi = io.imread(f) out.append(imi) return out
def makeBostonPano(): boston1 = io.imread("boston1/boston1-2.png") boston2 = io.imread("boston1/boston1-3.png") pointList1 = [ np.array([207, 215, 1], dtype=np.float64), np.array([243, 324, 1], dtype=np.float64), np.array([252, 195, 1], dtype=np.float64), np.array([274, 247, 1], dtype=np.float64), ] pointList2 = [ np.array([208, 55, 1], dtype=np.float64), np.array([249, 162, 1], dtype=np.float64), np.array([256, 33, 1], dtype=np.float64), np.array([277, 90, 1], dtype=np.float64), ] listOfPairs = zip(pointList1, pointList2) out = a6.stitch(boston1, boston2, listOfPairs) io.imwrite(out, "MyPano.png")
def getPNGsInDir(path): '''gets the png's in a folder and puts them in out.''' fnames = glob.glob(path + "*.png") out = [] for f in fnames: #print f imi = io.imread(f) out.append(imi) return out
def main(): # This program defines a single-stage imaging pipeline that # brightens an image. # First we'll load the input image we wish to brighten. # We'll use imageIO to get a numpy array from a PNG image im=imageIO.imread('rgb.png') # We then create a Halide representation of this image using the Image # constructor input = Image(Float(32), im) # the first input to the Image constructor is a type 32-bit float here) # the second can be a filename, a numpy array or nothing # when it's a filename, the file gets loaded # Next we declare our Func object that represents our one pipeline # stage. sel=Func() # Our Func will have three arguments, representing the position # in the image and the color channel. Halide treats color # channels as an extra dimension of the image, just like in numpy # let's declare the corresponding Vars before we can use them x, y, c = Var(), Var(), Var() # Finally define the function. sel[x, y, c] = select(input[x,y,1]<0.5, 0.0, 1.0) # The equivalent one-liner to all of the above is: # # brighter[x, y, c] = input[x, y, c] * 1.5 # # Remember. All we've done so far is build a representation of a # Halide program in memory. We haven't actually processed any # pixels yet. We haven't even compiled that Halide program yet. # So now we'll realize the Func. The size of the output image # should match the size of the input image. If we just wanted to # brighten a portion of the input image we could request a # smaller size. If we request a larger size Halide will throw an # error at runtime telling us we're trying to read out of bounds # on the input image. output = sel.realize(input.width(), input.height(), input.channels()); # realize provides us with some Halide internal datatype representing image buffers. # We want to convert it to a numpy array. For this, we first turn it into a # proper Halide Image using the Halide constructor Image(), and we then convert # it to a numpy array. It's a little verbose but not a big deal. outputNP=numpy.array(Image(output)) imageIO.imwrite(outputNP, 'sel.png') print "Success!\n" return 0;
def main(): # This program defines a multi-stage Halide imaging pipeline # One stage computes the horixontal gradient of an image dI/dx # Another stage computes dI/dy (for all three channels of RGB in both cases) # The final stage computes the magnitude of the corresponding vector # We will compute the gradient with finite differences: dI/dx=I(x+1)-I(x) # As usual, let's load an input im=imageIO.imread('rgb.png') # and create a Halide representation of this image input = Image(Float(32), im) # Next we declaure the Vars # We here give an extra argument to the Var constructor, an optional string that # can help for debugging by naming the variable in the Halide representation. # Otherwise, the names x, y, c are only known to the Python side x, y, c = Var('x'), Var('y'), Var('c') # Next we declare the three Funcs corresponding to the various stages of the gradient . # Similarly, we pass strings to name them. gx = Func('gx') gy = Func('gy') gradientMagnitude=Func('gradientMagnitude') # Define our horizontal gradient Func using finite difference # The value at a pixel is the input at that pixel minus its left neighbor. # Note how we now use the more direct definition of Funcs without declaring # intermediate Exprs gx[x,y,c]=input[x+1,y,c]-input[x, y,c] # Similarly define the vertical gradient. gy[x,y,c]=input[x,y+1,c]-input[x,y,c] # Finally define the gradient magnitude as the Euclidean norm of the gradient vector # We use overloaded operators and functions such as **, + and sqrt # Through he magic of metaprogramming, this creates the appropriate algebraic tree # in Halide representation # Most operators and functions you expect are supported. # Check the documentation for the full list. gradientMagnitude[x,y,c]= sqrt(gx[x,y,c]**2+gy[x,y,c]**2) # As usual, all we have done so far is create a Halide internal representation. # No computation has happened yet. # We now call realize() to compile and execute. # You'll note that we subtracted 1 from the width and height to make sure that the # x+1 and y+1 neighbors always exist. We'll see a more general solution in the next tutorial output = gradientMagnitude.realize(input.width()-1, input.height()-1, input.channels()); outputNP=numpy.array(Image(output)) imageIO.imwrite(outputNP, 'tut3out.png', gamma=1.0) print 'success!' return 0
def testCompositeVancouver(): im1 = io.imread('vancouverPan/vancouver0.png') im2 = io.imread('vancouverPan/vancouver1.png') im3 = io.imread('vancouverPan/vancouver2.png') pointList1=[np.array([138, 70, 1], dtype=np.float64), np.array([113, 151, 1], dtype=np.float64), np.array([279, 127, 1], dtype=np.float64), np.array([292, 84, 1], dtype=np.float64)] pointList2=[np.array([127, 220, 1], dtype=np.float64), np.array([90, 305, 1], dtype=np.float64), np.array([269, 278, 1], dtype=np.float64), np.array([279, 234, 1], dtype=np.float64)] listOfPairs1=zip(pointList1, pointList2) pointList3=[np.array([292, 97, 1], dtype=np.float64), np.array([316, 86, 1], dtype=np.float64), np.array([172, 140, 1], dtype=np.float64), np.array([164, 24, 1], dtype=np.float64)] pointList4=[np.array([293, 215, 1], dtype=np.float64), np.array([316, 205, 1], dtype=np.float64), np.array([171, 256, 1], dtype=np.float64), np.array([172, 145, 1], dtype=np.float64)] listOfPairs2=zip(pointList3, pointList4) listOfListOfPairs = [listOfPairs1, listOfPairs2] listOfImages = [im1, im2, im3] refIndex = 1 start = time.time() out = a6.stitchN(listOfImages, listOfListOfPairs, refIndex) end = time.time() print end - start io.imwrite(out, "MyPanoMany.png")
def test_makeHDR(file): import glob inputs=sorted(glob.glob('data/' + file + '-*.png')) im_list = [] for inp in inputs: im_list.append(io.imread(inp)) hdr=a5.makeHDR(im_list) np.save('npy/'+file+'hdr', hdr) hdr_scale=hdr/max(hdr.flatten()) io.imwrite(hdr_scale, file+'_hdr_linear_scale.png')
def test_makeHDR(): import glob, time inputs=glob.glob('data/sea-*.png') im_list = [] for inp in inputs: im_list.append(io.imread(inp)) hdr=a5.makeHDR(im_list) np.save('hdr', hdr) hdr_scale=hdr/max(hdr.flatten()) io.imwrite(hdr_scale, 'hdr_linear_scale.png')
def main(): im=imageIO.imread('hk.png', 1.0) t=time.time() out=harris(im) dt=time.time()-t print 'took ', dt, 'seconds' norm=np.max(out) imageIO.imwrite(out/norm)
def main(): im=imageIO.imread('hk.png') im = im[:im.shape[0]/1.2, :im.shape[1]/1.2] t=time.time() out=harris(im) dt=time.time()-t print 'took ', dt, 'seconds' mp = im.shape[0] * im.shape[1] / 1e6 print dt / float(mp), 'seconds / mp' # norm=np.max(out) imageIO.imwrite(out)
def main(): im=imageIO.imread('rgb.png') lumi=im[:,:,1] #I'm lazy, I'll just use green smallLumi=numpy.transpose(lumi[0:5, 0:5]) # Replace if False: by if True: once you have implement the required functions. # Exercises: if False: outputNP, myFunc=a11.smoothGradientNormalized() print ' Dimensionality of Halide Func:', myFunc.dimensions() imageIO.imwrite(outputNP, 'normalizedGradient.png') if False: outputNP, myFunc=a11.wavyRGB() print ' Dimensionality of Halide Func:', myFunc.dimensions() imageIO.imwrite(outputNP, 'rgbWave.png') if False: outputNP, myFunc=a11.luminance(im) imageIO.imwrite(outputNP, 'luminance.png') print ' Dimensionality of Halide Func:', myFunc.dimensions() if False: outputNP, myFunc=a11.sobel(lumi) imageIO.imwrite(outputNP, 'sobelMag.png') print ' Dimensionality of Halide Func:', myFunc.dimensions() if False: L=a11.pythonCodeForBoxSchedule5(smallLumi) print L if False: L=a11.pythonCodeForBoxSchedule6(smallLumi) print L if False: L=a11.pythonCodeForBoxSchedule7(smallLumi) print L if False: outputNP, myFunc=a11.localMax(lumi) print ' Dimensionality of Halide Func:', myFunc.dimensions() imageIO.imwrite(outputNP, 'maxi.png') if False: input=Image(Float(32), lumi) x, y, c = Var('x'), Var('y'), Var('c') clamped = Func('clamped') clamped[x, y] = input[clamp(x, 0, input.width()-1), clamp(y, 0, input.height()-1)] blurX, finalBlur= a11.GaussianSingleChannel(clamped) if False: im=numpy.load('Input/hk.npy') scheduleIndex=0 outputNP, myFunc=a11.harris(im, scheduleIndex) print ' Dimensionality of Halide Func:', myFunc.dimensions() imageIO.imwrite(outputNP, 'harris.png')
def main(): im=imageIO.imread('hk.png') #print 'loading input file' #im=numpy.load('Input/hk.npy') #print ' done loading input file, size: ', im.shape output=None for i in xrange(3): output, dt=boxBlur(im, i) #outputNP=numpy.array(Image(output)) #imageIO.imwrite(outputNP) numpy.save('Input/hk.npy', im)
def main(): im=imageIO.imread('hk.png') # path='Input/hk.npy' # print 'loading file ', path # im=numpy.load(path) print ' done. size ', im.shape output=None #first explore the different schedules for i in xrange(5): output, dt=boxBlur(im, i, 256, 256) # then explore tile sizes for tile in [32, 64, 128, 256, 512, 1024]: output, dt=boxBlur(im, 3, tile, tile)
def testTileSize(): im = imageIO.imread('hk.png') f = harris(im) w, h = (im.shape[1], im.shape[0]) print 'all root' best = (runAndMeasure(f, w, h), "all_root") c1 = None c2 = 'xo' c3 = 'xo' for tile1 in xrange(7,11): for tile2 in xrange(5,tile1): for tile3 in xrange(5,tile1): print 2**tile1, 2**tile2, 2**tile3, c1, c2, c3 f = harrisSameTile(im, 1, 2**tile1, 2**tile2, 2**tile3, c1, c2, c3) t = runAndMeasure(f, w, h) if t < best[0]: best = (t, (2**tile1, 2**tile2, 2**tile3, c1, c2, c3)) print best
import a1 import imageIO as io castle = io.imread('castle_small.png') imL, imC = a1.spanish(castle) io.imwrite(imL, 'L.png') io.imwrite(imC, 'C.png')
import a1 import imageIO as io im = io.imread() a1.printHisto(im, 10, 15)
io.imwrite(out, str(outputName + "SingleScaleOriented" + ".png")) def testOrientedPaint(im, texture, outputName, N=10000, size=50, noise=0.3): io.imwrite(npr.orientedPaint(im, texture, N, size, noise), str(outputName + "OrientedPaint" + ".png")) def runTests(im, texture, imname): testSingleScale(im, texture, imname) testPainterly(im, texture, imname) testSingleScaleOrientedPaint(im, texture, imname) testOrientedPaint(im, texture, imname) brush1 = io.imread('brush.png') longBrush = io.imread('longBrush.png') bigBrush = io.imread('longBrush2.png') roundIm = io.imread('round.png') liz = io.imread('liz.png') china = io.imread('china.png') vpd = io.imread('villeperdue.png') brushtest = np.zeros([200, 200, 3]) testBrush(brushtest, brush1) io.imwrite(brushtest, "brushtest1.png") testAngle(roundIm) runTests(liz, brush1, "Liz") runTests(china, brush1, "China") runTests(vpd, brush1, "VPD")