algorithm - Graph cut with python: How to set up the graph correctly? -
I want to use graph cut algorithm on images in my project, I use Python 2.7 I found, but the documentation does not seem so obvious. I'm making an example, this is my 5 * 5 matrix: gt; & Gt; An array ([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 1] 9 virtual terminal node, S (source) and T , [20, 21, 22, 23, 24]] (sync) matrix The infinite weight for all pixels of the lowest columns on the left and right should be linked to the arcs. Here's what I want to get: This is my code to get it, but it does not work left_most = concatenate ((1, ashp [0]), N.P. Ranges (ashp [0]). Reshape (1, ashp [0])). Unstable (npuit 64 ) left_most = np.ravel_multi_index (Bayan_ most, Asp) right_most = concatenate ((np. that ((1, Asp [0])) size (A, 1) - 1, NP Krenj (Asp [0]). The new size to (1, Ashaip [0])). volatile (Np.uint64) right_most = np.ravel_multi_index (right_most, A.shape) g.add_grid_tedges (Bayan_ most, Anpikons (Bayan_ most. Shaip) *...