clc;
clear;
close all;
%读取原始的清晰图片
Io = imread('14.jpg' );
%加入运动模糊
for LEN = 1:200; %模糊长度,即实际中的抖动幅度
LEN
THETA = 0; %模糊角度,即实际中的抖动方向,%一般仅考虑水平抖动和垂直抖动
%产生抖动因子PSF
PSF = fspecial( 'motion',LEN,THETA);
%产生抖动效果图
Ipsf = imfilter(Io,PSF,'circular','conv');
%Read image and scale to [0,1]
I=double(rgb2gray(Ipsf))./255;
%We subsample by factor of 2 to make things run a bit faster when playing around
I=I(1:2:end,1:2:end,:);
%Compute adjacency
n=1;
k1=0.1;
A=adjacency(I,n,k1);
%Compute affinity
k2=2;
K=affinity(I,A,k2);
%Seed points, numbered from 1 and up
S=zeros(size(I));
S(75:80,25:30)=1; %coat
%S(60:65,40:45)=1; %hand
%S(110:115,20:25)=1; %leg
%S(10:15,80:85)=2; %sky
%S(100:105,110:125)=3; %grass
%Show seeds overlayed on image
I_rgb=repmat(I,[1,1,3]); %make rgb image (required by imoverlay)
% figure(1)
% image(I_rgb)
% imoverlay(S,S>0); %requires image in range [0,1]
% title('Seed regions');
%Compute FC
disp(sprintf('Processing...'));
FC=afc(S,K); %Absolute FC
T(LEN)=mean2(FC);
end
figure;
plot(T);
%
% %Show resulting FC-map
% figure(2)
% imagesc(FC,[0,1])
% colorbar
% title('Fuzzy connectedness map');
%
% %Threshold value
% thresh=0.8;
%
% %Show the 0.75-connected component overlayed on original image
% figure(3)
% image(I_rgb)
% imoverlay(FC,FC>thresh);
% title(sprintf('Fuzzy connected component at level %.2f',thresh));