1. 参考文献

2. FFM模型实现
2.1 FFM模型代码
%%%%%%%%%%%%%%%%%%%%%%%%%%% Demo of Fast March Method %%%%%%%%%%%%%%%%%%%%%
% Date: 2014-10-23
% author: HSW
% HARBIN INSTITUTE OF TECHNOLOGY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all
clear all
clc;
% 读入图像
BAND = 1;
KNOWN = 2;
INSIDE = 3;
% 读入图像
I = imread('C10.bmp');
M = imread('mask2.png');
% 彩色图像
if size(M,3) == 3
M = rgb2gray(M);
M = M>0;
end
figure;
imshow(I, []);
title('原图像');
I = im2double(I);
Temp(:,:,1) = M;
Temp(:,:,2) = M;
Temp(:,:,3) = M;
I = (1-Temp).*I; %+ Temp.*0.5;
% % 灰度图像
% if ndims(M)
% M = rgb2gray(M);
% I = rgb2gray(I);
% end
% M = M<1;
% I = double(I);
% Temp = M;
% I = (1-Temp).*I + Temp.*255;
figure;
imshow(I,[]);
title('原图像');
% 标记
[m,n,dims] = size(I);
M1 = (bwdist(M,'cityblock') <= 1);
%初始化flag值
flag = INSIDE*M + KNOWN*(1-M);
flag =(1-M1+M).*flag+BAND*(M1-M);
%初始化 T
T = zeros([m,n]) + 1e6.*M;
IterMax = 10;
for iter = 1:IterMax
[I] = fast_march_method(I,T,flag);
end
figure;
imshow(I,[]);
title('修复结果');
2.2 FFM模型
function [I,T,flag] = fast_march_method(I,T,flag)
% input:
% I: 待修复图像
% M: 缺损区域mask,缺损区域 = 1
% T: 距离标记矩阵
% flag:标记矩阵,BAND/KNOWN/INSIDE
% output:
% I: 修复图像
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BAND = 1;
KNOWN = 2;
% INSIDE = 3;
[m,n,dims] = size(I);
iter = 0;
while find(flag == BAND) %存在待修复点
% 获取T最小的点的坐标
xposition = 1;
yposition = 1;
Tmin = 1e6;
for i = 1:m
for j = 1:n
if (flag(i,j) == BAND) && (T(i,j) < Tmin )
xposition = i;
yposition = j;
Tmin = T(i,j);
end
end
end

该博客详细介绍了FFM(Field-aware Factorization Machine)模型在图像修复领域的实现过程,包括模型代码的编写和模型的运行效果展示,是理解FFM模型在图像修复技术上应用的良好参考资料。
最低0.47元/天 解锁文章
840

被折叠的 条评论
为什么被折叠?



