Ambrosio-Tortorelli-Minimizer

Python implementation of minimizing the mumford-shah functional for piecewise smooth image approximation.

Stars
24

Piecewise Smooth image approximation by minimizing the mumford-shah functional with the Ambrosio-Tortorelli approach

import cv2
from AmbrosioTortorelliMinimizer import *

Use it on a grayscale image:

img = cv2.imread("image.jpg", 0)
solver = AmbrosioTortorelliMinimizer(img)
img, edges = solver.minimize()

Or on a color image:

img = cv2.imread("image.jpg", 1)
result, edges = [], []
for c in cv2.split(img):
	solver = AmbrosioTortorelliMinimizer(c, alpha = 1000, beta = 0.01, 
	epsilon = 0.01)
	
	f, v = solver.minimize()
	result.append(f)
	edges.append(v)

img = cv2.merge(result)
edges = np.maximum(*edges)

For more details refer here

License: Use this for whatever you want.

Related Projects