from scipy import interpolate
import matplotlib.pyplot as plt
import numpy as np
import cv2
a=np.arange(1,9)
filename = 'image_file_0.tiff'
img = cv2.imread(filename)
x = np.array([389, 392, 325, 211, 92,103,194,310])
y = np.array([184,281,365,401,333,188,127,126])
x = np.r_[x, x[0]]
y = np.r_[y, y[0]]
tck, u = interpolate.splprep([x, y], s=0, per=True)
xi, yi = interpolate.splev(np.linspace(0, 1, 1000), tck)
fig, ax = plt.subplots(1, 1)
ax.plot(xi, yi, '-b')
plt.imshow(img)
plt.show()
I want to transform the pixel values of the outer or inner region after forming an arbitrary closed curve in the image. How do I do it?
cv2.fillpoly
. +1 – Ornate