Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv
- import cv2
- import numpy
- import scipy
- from scipy.interpolate import griddata
- import matplotlib.pyplot as pyplot
- contours = cv2.imread('testcontours.bmp')
- contourPoints = []
- contourValues = []
- for row in range(contours.shape[0]):
- for col in range(contours.shape[1]):
- if contours[row,col][0] != 0:
- # contourPoints.append([20*float(row)/contours.shape[0], 20*float(col)/contours.shape[1]])
- contourPoints.append([float(row)/contours.shape[0], float(col)/contours.shape[1]])
- contourValues.append(float(contours[row, col][0])/255)
- grid_x, grid_y = numpy.mgrid[0:1:1000j, 0:1:1000j]
- # grid_x, grid_y = numpy.mgrid[0:20, 0:20]
- grid = griddata(numpy.asarray(contourPoints, numpy.float), numpy.asarray(contourValues, numpy.float), (grid_x, grid_y), method='linear')
- # grid = grid / 255
- pyplot.subplot(121)
- pyplot.imshow(numpy.asarray(contours, numpy.float)/255, interpolation='none')
- pyplot.subplot(122)
- pyplot.imshow(grid, interpolation='none')
- pyplot.colorbar()
- pyplot.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement