⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findseamimg.m~

📁 Using the idea from Seam Carving for Content-Aware Image Resizing, the codes enables a selected im
💻 M~
字号:
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.
%
% The indexing can be interpreted as in this example image:
%   [(i-1,j-1)  (i-1,j)  (i-1,j+1)]
%   [(i,j-1)    (i,j)    (i,j+1)  ]
%   [(i+1,j-1)  (i+1,j)  (i+1,j+1)]
%
% Author: Danny Luong
%         http://danluong.com
%
% Last updated: 12/20/07


[rows cols]=size(x);

SeamImg=zeros(rows,cols);
SeamImg(1,:)=x(1,:);

for i=2:cols
    for j=1:rows
        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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -