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

📄 get_window.m

📁 this is a very very very nice code
💻 M
字号:
%This function finds the smallest sub-window in a mask that contains all
%the pixels to be inpainted or synthesized.
%
%Input is a binary mask, where 0 indicates a region to be painted or
%synthesized, and 1 represents all the other regions
function window = get_window(mask)

mask = ~mask;
window = [-1,-1,-1,-1];
%Find the top-most location
for y = 1:size(mask,1)
    if sum(mask(y,:)) > 0
        window(1) = y;
        break;
    end
end

%Find the bottom-most location
for y = size(mask,1):-1:1
    if sum(mask(y,:)) > 0
        window(2) = y;
        break;
    end
end

%Find the leftv-most location
for x = 1:size(mask,2)
    if sum(mask(:,x)) > 0
        window(3) = x;
        break;
    end
end

%Find the right-most location
for x = size(mask,2):-1:1
    if sum(mask(:,x)) > 0
        window(4) = x;
        break;
    end
end

⌨️ 快捷键说明

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