Advertisement
Guest User

Untitled

a guest
Jan 13th, 2013
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import cv
  2. import cv2
  3. import numpy
  4. import scipy
  5. from scipy.interpolate import griddata
  6. import matplotlib.pyplot as pyplot
  7.  
  8. contours        = cv2.imread('testcontours.bmp')
  9. contourPoints   = []
  10. contourValues   = []
  11.  
  12. for row in range(contours.shape[0]):
  13.     for col in range(contours.shape[1]):
  14.         if contours[row,col][0] != 0:
  15.             # contourPoints.append([20*float(row)/contours.shape[0], 20*float(col)/contours.shape[1]])
  16.             contourPoints.append([float(row)/contours.shape[0], float(col)/contours.shape[1]])
  17.             contourValues.append(float(contours[row, col][0])/255)
  18.  
  19. grid_x, grid_y = numpy.mgrid[0:1:1000j, 0:1:1000j]
  20. # grid_x, grid_y = numpy.mgrid[0:20, 0:20]
  21.  
  22. grid = griddata(numpy.asarray(contourPoints, numpy.float), numpy.asarray(contourValues, numpy.float), (grid_x, grid_y), method='linear')
  23.  
  24. # grid = grid / 255
  25.  
  26. pyplot.subplot(121)
  27. pyplot.imshow(numpy.asarray(contours, numpy.float)/255, interpolation='none')
  28. pyplot.subplot(122)
  29. pyplot.imshow(grid, interpolation='none')
  30. pyplot.colorbar()
  31. pyplot.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement