Seam contents in min path


should the seam in find min path contain energies or indices of the energies?

As detailed in sub-task 3.2, you are supposed to print the x-index (column) of each pixel on the minimal path, so it makes sense to store the indices in the seam array, not the energy values.

could you please tell me if we should assume that the energy array has already stored the accumulated energy for every pixel or is this array still empty like the seam array…if it is empty, I guess we should use the calculate_energy function to get the accumulated energy in the struct pixel from struct image…?
after that then use the calculate_min_energy_column function for every row from bottom to top and save the chosen row index in the seam array? But in the end , are we suppose to print it out or here save it in a reversed way…from top to bottom?

I’m not quite sure I can follow you.

First of all, you are asking about the find_print_min_path function. (Which is the closest actually existing function to “find min path”. Please be precise when referencing functions.)

There, you are just given the image and have to initialize and allocate all other required arrays yourself. So in that function, there is no energy array unless and until you create it yourself.

Other functions in the project have different conventions. Some are supposed to fill an array with values, others use these. Which of these is the case can usually be seen from the comment above the respective method.

sorry, I was actually asking about the calculate_optimal_path…
Yeah, I know in find_print_min_path task we should create an energy array and put the pixel date in it…
But for this task( calculate_optimal_path), the seam array is as input empty, right?
But the energy array also as input, is already filled with the date from accumulated pixel, we just need to use it in order to find the index in every row for the seam? or should we also create and initialize the energy array in this task?

about the order of the row index for seam, we should search it from the bottom to top…but we are supposed to save them in the seam array from top to bottom, right? like first get the index in the very last row and save it as the last element in seam…the index in the first row will be found at last but it should be saved as the first element in seam?

Indeed, for calculate_optimal_path, the uint32_t const* const energy already contains the energy. So it has to be computed before calling the function. The parameter uint32_t* const seam is a pointer to an array into which the resulting seam is to be written by the function.

The seam is to be written such that the first entry contains the index of the first row to be removed (that is the index in the top row). The last index is the one for the bottom row, and so on.

Calculating the total energy is done in calculate_energy.

In find_print_min_path, you need to allocate these arrays yourself (and free them afterwards), as you mentioned.

1 Like

Thank you so much for your patience and quick explanations. It helped. :+1: