📄 deinterlacing.m
字号:
function Frame_NO_Callback(hObject, eventdata, handles)
% hObject handle to Frame_NO (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Frame_NO as text
% str2double(get(hObject,'String')) returns contents of Frame_NO as a double
handles.n = round(str2double(get(handles.Frame_NO,'String')));
if handles.n>max(size(handles.mov))
handles.n = max(size(handles.mov))
set(handles.Frame_NO,'String',handles.n);
end
set(handles.slider1,'Value',handles.n/max(size(handles.mov)));
[I,Map] = frame2im(handles.mov(1,handles.n));
axes(handles.axes1);
image(I)
guidata(hObject, handles);
% --- Executes on button press in show_selection.
function show_selection_Callback(hObject, eventdata, handles)
% hObject handle to show_selection (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ux = str2double(get(handles.ULCX,'String'));
uy = str2double(get(handles.ULCY,'String'));
lx = str2double(get(handles.LRCX,'String'));
ly = str2double(get(handles.LRCY,'String'));
handles.x = ux;
handles.y = uy;
handles.w = lx - handles.x;
handles.h = ly - handles.y;
axes(handles.axes1)
rectangle('Position',[handles.x,handles.y,handles.w,handles.h],'Curvature',[0.2,0.2],'EdgeColor','r')
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in Start_Deinterlacing.
function Start_Deinterlacing_Callback(hObject, eventdata, handles)
% hObject handle to Start_Deinterlacing (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%handles.F = [];
%handles.F = 1;
if handles.pop==0
warndlg('To Continue First select the Image type from popup menu');
else
prompt={'From frame #:','To frame #:'};
name='Range of frames For Deinterlacing';
numlines=1;
defaultanswer={num2str(handles.n),num2str(handles.nof)};
answer=inputdlg(prompt,name,numlines,defaultanswer);
st = eval(char(answer(1)));
en = eval(char(answer(2)));
h = waitbar(0,'Please wait...');
if handles.pop == 1
clc
ux = str2double(get(handles.ULCX,'String'));
uy = str2double(get(handles.ULCY,'String'));
lx = str2double(get(handles.LRCX,'String'));
ly = str2double(get(handles.LRCY,'String'));
if fix(uy/2)~=uy/2
uy=2*fix(uy/2);
if uy == 0,uy = 2; end
set(handles.ULCY,'String',uy);
end
if fix((ly-uy)/4)~=(ly-uy)/4
ly=uy + 4*fix((ly-uy)/4);
set(handles.LRCY,'String',ly);
end
liy = round(abs(uy-ly)/2);
irx = abs(ux-lx); % Image resize X
iry = abs(uy-ly); % Image resize Y
for k = st:en
waitbar((k-st)/(en-st),h)
clear I1;
clear I2;
Frame_Number = k
[II,Map] = frame2im(handles.mov(1,k));
F1 = II(uy:ly,ux:lx,:);
for i=1:liy
I1(i,:,:) = F1(2*i-1,:,:);
I2(i,:,:) = F1(2*i,:,:);
end
I1 = imresize(I1,[iry irx],'bicubic');
I2 = imresize(I2,[iry irx],'bicubic');
I1 = I1(2:iry,:,:);
I2 = I2(1:iry-1,:,:);
handles.F(1,2*(k-st+1)-1) = im2frame(I1);
handles.F(1,2*(k-st+1)-0) = im2frame(I2);
end
guidata(hObject, handles);
disp('------------------------------------------------')
disp('The Deinterlacing process Completed Successfully')
end
if (handles.pop == 2 | handles.pop ==3)
disp(' Please wait a minute ')
disp(' Finding the corresponding Regions ...')
ux = str2double(get(handles.ULCX,'String'));
uy = str2double(get(handles.ULCY,'String'));
lx = str2double(get(handles.LRCX,'String'));
ly = str2double(get(handles.LRCY,'String'));
if fix(uy/4)~=uy/4
uy=4*fix(uy/4);
set(handles.ULCY,'String',uy);
end
if fix((ly-uy)/4)~=(ly-uy)/4
ly=uy + 4*fix((ly-uy)/4);
set(handles.LRCY,'String',ly);
end
liy = round(abs(uy-ly)/2);
irx = abs(ux-lx); % Image resize X
iry = abs(uy-ly); % Image resize Y
[II,Map] = frame2im(handles.mov(1,handles.n));
I = II(handles.y11:handles.y21,handles.x11:handles.x21,:);
I1 = II(uy:ly,ux:lx,:);
[ey,ex,val]=fndc(I,I1,1);
sf1=size(I);
sf2=size(I1);
yf1=sf1(1);
xf1=sf1(2);
yf2=sf2(1);
xf2=sf2(2);
disp('One Region is Found')
disp('-------------------')
disp('Deinterlacing is started ... ')
for k = st:en
waitbar((k-st)/(en-st),h)
clear I1;
clear I2;
clear I3;
clear I4;
Frame_Number = k
[II,Map] = frame2im(handles.mov(1,k));
F1 = II(uy:ly,ux:lx,:);
F2 = II(handles.y11-1+ey:handles.y11-1+yf2+ey-1,handles.x11+ex-1:handles.x11+ex+(lx-ux)-1,:);
for i=1:liy
I1(i,:,:) = F1(2*i-1,:,:);
I2(i,:,:) = F1(2*i,:,:);
end
I1 = imresize(I1,[iry irx],'bicubic');
I2 = imresize(I2,[iry irx],'bicubic');
I1 = I1(2:iry,:,:);
I2 = I2(1:iry-1,:,:);
for i=1:liy
I3(i,:,:) = F2(2*i-1,:,:);
I4(i,:,:) = F2(2*i,:,:);
end
I3 = imresize(I3,[iry irx],'bicubic');
I4 = imresize(I4,[iry irx],'bicubic');
I3 = I3(2:iry,:,:);
I4 = I4(1:iry-1,:,:);
handles.F(1,4*(k-st+1)-3) = im2frame(I1);
handles.F(1,4*(k-st+1)-2) = im2frame(I3);
handles.F(1,4*(k-st+1)-1) = im2frame(I2);
handles.F(1,4*(k-st+1)-0) = im2frame(I4);
end
guidata(hObject, handles);
disp('------------------------------------------------')
disp('The Deinterlacing process Completed Successfully')
end
if handles.pop == 4
disp(' Please wait a minute ')
disp(' Finding the corresponding Regions ...')
ux = str2double(get(handles.ULCX,'String'));
uy = str2double(get(handles.ULCY,'String'));
lx = str2double(get(handles.LRCX,'String'));
ly = str2double(get(handles.LRCY,'String'));
if fix(uy/4)~=uy/4
uy=4*fix(uy/4);
set(handles.ULCY,'String',uy);
end
if fix((ly-uy)/4)~=(ly-uy)/4
ly=uy + 4*fix((ly-uy)/4);
set(handles.LRCY,'String',ly);
end
liy = round(abs(uy-ly)/2);
irx = abs(ux-lx); % Image resize X
iry = abs(uy-ly); % Image resize Y
[II,Map] = frame2im(handles.mov(1,handles.n));
Ib = II(handles.y11:handles.y21,handles.x11:handles.x21,:);
Ic = II(handles.y12:handles.y22,handles.x12:handles.x22,:);
Id = II(handles.y13:handles.y23,handles.x13:handles.x23,:);
I1 = II(uy:ly,ux:lx,:);
[eyb,exb]=fnd(Ib,I1);
[eyc,exc]=fnd(Ic,I1);
[eyd,exd]=fnd(Id,I1);
sfb=size(Ib);
sfc=size(Ic);
sfd=size(Id);
sf2=size(I1);
yfb=sfb(1);
xfb=sfb(2);
yfc=sfc(1);
xfc=sfc(2);
yfd=sfd(1);
xfd=sfd(2);
yf2=sf2(1);
xf2=sf2(2);
disp('One Region is Found')
disp('-------------------')
disp('Deinterlacing is started ... ')
for k = st:en
waitbar((k-st)/(en-st),h)
clear I1;
clear I2;
clear I3;
clear I4;
clear I5;
clear I6;
clear I7;
clear I8;
Frame_Number = k
[II,Map] = frame2im(handles.mov(1,k));
F1 = II(uy:ly,ux:lx,:);
Fb = II(handles.y11-1+eyb:handles.y11-1+yf2+eyb-1,handles.x11+exb-1:handles.x11+exb+(lx-ux)-1,:);
Fc = II(handles.y12-1+eyc:handles.y12-1+yf2+eyc-1,handles.x12+exc-1:handles.x12+exc+(lx-ux)-1,:);
Fd = II(handles.y13-1+eyd:handles.y13-1+yf2+eyd-1,handles.x13+exd-1:handles.x13+exd+(lx-ux)-1,:);
for i=1:liy
I1(i,:,:) = F1(2*i-1,:,:);
I2(i,:,:) = F1(2*i,:,:);
end
I1 = imresize(I1,[iry irx],'bicubic');
I2 = imresize(I2,[iry irx],'bicubic');
I1 = I1(2:iry,:,:);
I2 = I2(1:iry-1,:,:);
for i=1:liy
I3(i,:,:) = Fb(2*i-1,:,:);
I4(i,:,:) = Fb(2*i,:,:);
end
I3 = imresize(I3,[iry irx],'bicubic');
I4 = imresize(I4,[iry irx],'bicubic');
I3 = I3(2:iry,:,:);
I4 = I4(1:iry-1,:,:);
for i=1:liy
I5(i,:,:) = Fc(2*i-1,:,:);
I6(i,:,:) = Fc(2*i,:,:);
end
I5 = imresize(I5,[iry irx],'bicubic');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -