jacobgil / Ambrosio-Tortorelli-Minimizer

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

Home Page:http://jacobcv.blogspot.com/2015/04/smoothing-images-with-mumford-shah.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

enter image description hereenter image description here

enter image description hereenter image description here

enter image description hereenter image description here

For more details refer here

License: Use this for whatever you want.

About

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

http://jacobcv.blogspot.com/2015/04/smoothing-images-with-mumford-shah.html


Languages

Language:Python 100.0%