How can I find horizontal Seams ?
3 views (last 30 days)
Show older comments
How can I change the following code from detecting vertical Seams to horizontal ones ?
You can find the global code in the following link : https://fr.mathworks.com/matlabcentral/fileexchange/18089-seam-carving-for-content-aware-image-resizing-gui-implementation-demo
function SeamImg = findSeamImg(x)
% FINDSEAMIMG finds the seam map from which the optimal (vertical running)
% seam can be calculated. Input is gradient image found from findEnergy.m.
[rows cols] = size(x);
SeamImg = zeros(rows,cols);
SeamImg(1,:) = x(1,:);
for i=2:rows
for j=1:cols
if j-1<1
SeamImg(i,j) = x(i,j)+min([SeamImg(i-1,j),SeamImg(i-1,j+1)]);
elseif j+1>cols
SeamImg(i,j) = x(i,j)+min([SeamImg(i-1,j-1),SeamImg(i-1,j)]);
else
SeamImg(i,j) = x(i,j)+min([SeamImg(i-1,j-1),SeamImg(i-1,j),SeamImg(i-1,j+1)]);
end
end
end
0 Comments
Answers (1)
Voss
on 1 Feb 2022
You may not have to change the code at all. Have you tried transposing the input before passing it to the function and then transposing the output you get back? That is:
SeamImg_horizontal = findSeamImg(x.').';
0 Comments
See Also
Categories
Find more on Computer Vision Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!