How can I find horizontal Seams ?

3 views (last 30 days)
gbjbjubj cvivnqvndivnd
gbjbjubj cvivnqvndivnd on 31 Jan 2022
Answered: Voss on 1 Feb 2022
How can I change the following code from detecting vertical Seams to horizontal ones ?
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

Answers (1)

Voss
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.').';

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!