Calculating Energy

I’m a little bit confused about the wording used for the functions calculate_energy and calculate_min_energy_column. What does w stand for?

Assume, we have an entry in the matrix with coordinates (i, j) whereas i is the colum and j is the row. Then the position in the array is defined by yx_index(j, i, width). Should I consider all entries with i < w or yx_index(j, i, width) < w?

Hi,

it is very helpful to look at why we need this w. Intuitively, the w tells you how many columns have already been removed. So how many black columns should be at the right boundary.
Thus, i < w is the concrete answer to your question.

If you would use yx_index(j, i, width) < w you would be ignoring rows of your image (or even only parts of a single row if w is chosen poorly).

I hope this helps you :smiley:

Lukas

4 Likes