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

📄 iprocessing.m

📁 这是一个关于简单matlab motino trakcing 算法的工具箱,十分清楚,请用winzip 解压缩
💻 M
📖 第 1 页 / 共 5 页
字号:
if handles.gray==1    handles.pop = 2;else    handles.pop = 1;endflag = handles.x*handles.y;   % if any marker is selectedif flag~=0    defaultanswer={num2str(handles.nof)};    en=inputdlg('Last Frame to process','Input',1,defaultanswer);    if size(en)        handles.en = eval(char(en));        h = waitbar(0,'Please wait...');        handles.I=[];        clear If1;        [handles.I,Map] = frame2im(handles.mov(1,handles.n));        handles.I = imadjustment(handles);        guidata(hObject, handles);        If1 = handles.I(handles.y:handles.y+handles.h,handles.x:handles.x+handles.w,:);        sz = size(handles.I);        handles.st = handles.n;        st = handles.st;        en = handles.en;        if st>=en            warndlg('Your selected range of frames is incorrect');            st = en+1;        end        for i = st:en            waitbar((i-st)/(en-st),h)            clear I            %if (vel>10) & velflag            %[I1,Map] = frame2im(handles.mov(1,i-1));            %[I2,Map] = frame2im(handles.mov(1,i));            %I = I2-I1;            %else            [I,Map] = frame2im(handles.mov(1,i));            %end            x1 = handles.x-xl;            x2 = handles.x+handles.w+xr;            y1 = handles.y-yu;            y2 = handles.y+handles.h+yd;            %a = [x1,y1,x2-x1,y2-y1]            if y1<1, y1=1, end            if x1<1, x1=1, end            if y2+1>sz(1), y2=sz(1)-1, end            if x2+1>sz(2), x2=sz(2)-1, end            handles.I=[];            handles.I = I(y1:y2,x1:x2,:);            handles.I = imadjustment(handles);            guidata(hObject, handles);            %*************************            switch handles.pop                case 1                    [ey,ex,val] = fndc(handles.I,If1,1);                case 2                    [ey,ex,val] = fnd(handles.I,If1,1);            end            k=1;            v(i-st+1) = val;            handles.x = ex(k) + handles.x - xl - 1;            handles.y = ey(k) + handles.y - yu - 1;            if handles.y<1, break, end            if handles.x<1, break, end            if (handles.y+handles.h+1)>sz(1), break, end            if (handles.x+handles.w+1)>sz(2), break, end            clear If1            If1 = I(handles.y:handles.y+handles.h,handles.x:handles.x+handles.w,:);            clear fy            clear fx            %******************************************************************            if handles.Centroid_Flag==true;                for ina = [ist:0.01:0.99]                    mean_point_flag = true;                    clear Ia;                    clear ce;                    Ia = imadjust(If1,[ina; 1],[0; 1]);                    L1 = bwlabel(rgb2gray(Ia));                    stats = regionprops(L1,'Centroid','Area');                    ssz = size(stats);                    if ssz(1)==1 & stats.Area<30                        ce = stats.Centroid;                        fx = ce(1);                        fy = ce(2);                        ist = ina-0.1;                        if ist<0.1, ist = 0.1;end                        mean_point_flag = false;                        break                    end                end                if mean_point_flag                    szif1 =size(If1(:,:,1));                    fx = szif1(1)/2;                    fy = szif1(2)/2;                end            else                mx = max(max(If1(:,:,1)));                [fy,fx] = find(If1(:,:,1) == mx);            end            %*********************** Manual Check subroutine ******************            value_check=false;            if (i-st)>1                mean_val = mean(v(1:i-st));                crit1 = max((val/v(i-st)), (val/v(i-st)));                crit2 = max((val/mean_val), (val/mean_val));                crit3 = vel/8;                crit = max([crit1,crit2,crit3]);                if crit>str2num(get(handles.manual_check_value,'string'));                    value_check=true;                end                %[i crit1 crit2 value_check]            end            if handles.manual_check_flag & value_check                set(handles.text31,'Visible','on');                %             if handles.Centroid_Flag==false                %                 for ina = [ist:0.01:0.99]                %                     clear Ia                %                     Ia = imadjust(If1,[ina; 1],[0; 1]);                %                     L1 = bwlabel(rgb2gray(Ia));                %                     stats = regionprops(L1,'Centroid','Area');                %                     ssz = size(stats);                %                     if ssz(1)==1 & stats.Area<30, break, end                %                 end                %             end                %clear Ia                %clear stats                %clear ce                %clear a                %Ia = imadjust(handles.I,[ina; 1],[0; 1]);                %L1 = bwlabel(rgb2gray(Ia));                %stats = regionprops(L1,'Centroid','Area');                %nom = max(size(stats));      %Number of Markers                %if nom > 1                %             s = 'Choose the appropriate Marker? ';                %             ButtonName=questdlg(s, ...                %                 'Markers interference', ...                %                 'OK','Cancel','OK');                close(h)                [handles.I2,Map] = frame2im(handles.mov(1,i));                szi = size(handles.I2);                sh = szi(1);                sw = szi(2);                axes(handles.axes1)                cla                hold on,                dd = 2*vel + 50;                y3 = y1 - dd;                y4 = y2 + dd;                x3 = x1 - dd;                x4 = x2 + dd;                if y3<1, y3 = 1;end                if y4>sh, y4 = sh;end                if x3<1, x3 = 1;end                if x4>sw, x4 = sw;end                handles.I3 = handles.I2(y3:y4,x3:x4,:);                imshow(handles.I3);                %hold on,                dx = x4-x3;                dy = y4-y3;                rectangle('Position',[1,1,dx-1,dy-1],'Curvature',[0,0],'EdgeColor','g')                %rectangle('Position',[2,2,dx-2,dy-2],'Curvature',[0,0],'EdgeColor','g')                %rectangle('Position',[3,3,dx-3,dy-3],'Curvature',[0,0],'EdgeColor','g')                set(handles.Frame_NO,'String',i);                set(handles.slider1,'Value',i/max(size(handles.mov)));                %            switch ButtonName                %                case 'OK'                [x,y] = ginput(1);                x = x+x3;                y = y+y3;                handles.x = x-round(handles.w/2);                handles.y = y-round(handles.h/2);                Iff = I(y-round(handles.h/2):y+round(handles.h/2),x-round(handles.w/2):x+round(handles.w/2),:);                if handles.Centroid_Flag==true;                    for ina = [ist:0.01:0.99]                        mean_point_flag = true;                        clear Ia;                        clear ce;                        Ia = imadjust(Iff,[ina; 1],[0; 1]);                        L1 = bwlabel(rgb2gray(Ia));                        stats = regionprops(L1,'Centroid','Area');                        ssz = size(stats);                        if ssz(1)==1 & stats.Area<30                            ce = stats.Centroid;                            fx = ce(1);                            fy = ce(2);                            ist = ina-0.1;                            if ist<0.1, ist = 0.1;end                            mean_point_flag = false;                            break                        end                    end                    if mean_point_flag                        szif1 =size(Iff(:,:,1));                        fx = szif1(1)/2;                        fy = szif1(2)/2;                    end                else                    mx = max(max(Iff(:,:,1)));                    [fy,fx] = find(Iff(:,:,1) == mx);                end                %               case 'Cancel'                %end                %          end                h = waitbar(0,'Please wait...');                waitbar((i-st)/(en-st),h)            end            set(handles.text31,'Visible','off');            %******************************************************************            handles.glbx(i) = handles.x + round(fx(1)) - 1;            handles.glby(i) = handles.y + round(fy(1)) - 1;            clear If1;            handles.x = handles.glbx(i) - round(handles.w/2);            handles.y = handles.glby(i) - round(handles.h/2);            if handles.y<1, break, end            if handles.x<1, break, end            if (handles.y+handles.h+1)>sz(1), break, end            if (handles.x+handles.w+1)>sz(2), break, end            If1 = I(handles.y:handles.y+handles.h,handles.x:handles.x+handles.w,:);            if (i-st)>0                dx = round(handles.glbx(i) - handles.glbx(i-1));                dy = round(handles.glby(i) - handles.glby(i-1));                if dx>0                    xl = tolx + dx;                    xr = tolx;                else                    xr = tolx - dx;                    xl = tolx;                end                if dy>0                    yu = toly + dy;                    yd = toly;                else                    yd = toly - dy;                    yu = toly;                end                vel = round(sqrt(dy^2+dx^2));            end            %         [handles.I2,Map] = frame2im(handles.mov(1,i));            %         axes(handles.axes1)            %         hold on,            %         imshow(handles.I2);            %         hold on,            %         rectangle('Position',[x1,y1,x2-x1,y2-y1],'Curvature',[0.2,0.2],'EdgeColor','g')            %         ButtonName=questdlg('dfgh', ...            %             'Markers interference', ...            %             'Previous','OK','Next','OK');        end    close(h)    handles.en = i-1;    endelse    warndlg('Before start the process you must select a marker');endcla resetimageupdate(hObject,handles);guidata(hObject, handles);% --- Executes on slider movement.function gray_low_Callback(hObject, eventdata, handles)% hObject    handle to gray_low (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,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of sliderlg = get(handles.gray_low,'Value');handles.lg=round(lg*255);guidata(hObject, handles);imageupdate(hObject,handles)% --- Executes during object creation, after setting all properties.function gray_low_CreateFcn(hObject, eventdata, handles)% hObject    handle to gray_low (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on button press in grayscale.function grayscale_Callback(hObject, eventdata, handles)% hObject    handle to grayscale (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on slider movement.function gray_high_Callback(hObject, eventdata, handles)% hObject    handle to gray_high (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,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of sliderhg = get(handles.gray_high,'Value');handles.hg=round(hg*255);guidata(hObject, handles);imageupdate(hObject,handles)% --- Executes during object creation, after setting all properties.function gray_high_CreateFcn(hObject, eventdata, handles)% hObject    handle to gray_high (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.

⌨️ 快捷键说明

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