Hello.
Thanks for the sharing, and the quality of the code is good!
However, I find some issues in the local warping using seamcarving that cause the different results even when computing the same input image.
In the Line 175 in addSeam.cpp
, the code uses rand()
to generate different colors for seams. However, when computing the next seam, the colored image would be used to compute the energy. The energy would not keep the same in different experiement repeatition since the colored seam would involved in energy computation and it is given as random. As a result, the final seams obtained would not be the same, and are slightly dependent on the randomized color seams.
|
#if 1 |
|
color[0] = rand()%256; |
|
color[1] = rand()%256; |
|
color[2] = rand()%256; |
|
// Draw red on the seam |
|
for (int i = 0; i < h; ++i) { |
|
img[optVertSeam[i]*3] = color[0]; |
|
img[optVertSeam[i]*3+1] = color[1]; |
|
img[optVertSeam[i]*3+2] = color[2]; |
|
} |
|
#endif |
|
#if 0 |
|
// Draw red on the seam |
|
for (int i = 0; i < h; ++i) { |
|
img[optVertSeam[i]*3] = 255; |
|
img[optVertSeam[i]*3+1] = 0; |
|
img[optVertSeam[i]*3+2] = 0; |
|
} |
|
#endif |
The overall image is updated with the output image with a color seam from addSeam.cpp
. And in the next loop, the input image is resulted fromthe overall image with color seam.
|
idx = sub2ind(size(mask), y, x); |
|
idx2 = cat(3, idx, idx+h*w); |
|
idx3 = cat(3, idx2, idx+2*h*w); |
|
subImg = img(idx3); |
|
subMask = mask(idx); |
|
subXDispMap = xDispMap(idx); |
|
subYDispMap = yDispMap(idx); |
|
[outImg, outMask, outXDispMap, outYDispMap] = addSeam_wrap(subImg, subMask, subXDispMap, subYDispMap); |
|
img(idx3) = outImg; |
|
mask(idx) = outMask; |
|
xDispMap(idx) = outXDispMap; |
|
yDispMap(idx) = outYDispMap; |