📄 iprocessing.m
字号:
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on button press in Gray_scale.function Gray_scale_Callback(hObject, eventdata, handles)% hObject handle to Gray_scale (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of Gray_scaleif (get(hObject,'Value') == get(hObject,'Max')) % then rsdio button is selected-take approriate action handles.gray = 1else % radio button is not selected-take approriate action handles.gray = 0;endguidata(hObject, handles);imageupdate(hObject,handles)% --- Executes on slider movement.function red_low_Callback(hObject, eventdata, handles)% hObject handle to red_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 sliderrl = get(handles.red_low,'Value');handles.rl=round(rl*255);guidata(hObject, handles);imageupdate(hObject,handles);% --- Executes during object creation, after setting all properties.function red_low_CreateFcn(hObject, eventdata, handles)% hObject handle to red_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 slider movement.function red_high_Callback(hObject, eventdata, handles)% hObject handle to red_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 sliderrh = get(handles.red_high,'Value');handles.rh=round(rh*255);guidata(hObject, handles);imageupdate(hObject,handles)% --- Executes during object creation, after setting all properties.function red_high_CreateFcn(hObject, eventdata, handles)% hObject handle to red_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.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function green_low_Callback(hObject, eventdata, handles)% hObject handle to green_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 slidergl = get(handles.green_low,'Value');handles.gl=round(gl*255);guidata(hObject, handles);imageupdate(hObject,handles)% --- Executes during object creation, after setting all properties.function green_low_CreateFcn(hObject, eventdata, handles)% hObject handle to green_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 slider movement.function green_high_Callback(hObject, eventdata, handles)% hObject handle to green_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 slidergh = get(handles.green_high,'Value');handles.gh=round(gh*255);guidata(hObject, handles);imageupdate(hObject,handles)% --- Executes during object creation, after setting all properties.function green_high_CreateFcn(hObject, eventdata, handles)% hObject handle to green_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.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function blue_low_Callback(hObject, eventdata, handles)% hObject handle to blue_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 sliderbl = get(handles.blue_low,'Value');handles.bl=round(bl*255);guidata(hObject, handles);imageupdate(hObject,handles)% --- Executes during object creation, after setting all properties.function blue_low_CreateFcn(hObject, eventdata, handles)% hObject handle to blue_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 slider movement.function blue_high_Callback(hObject, eventdata, handles)% hObject handle to blue_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 sliderbh = get(handles.blue_high,'Value');handles.bh=round(bh*255);guidata(hObject, handles);imageupdate(hObject,handles)% --- Executes during object creation, after setting all properties.function blue_high_CreateFcn(hObject, eventdata, handles)% hObject handle to blue_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.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);endfunction imageupdate(hObject,handles)[handles.I,Map] = frame2im(handles.mov(1,handles.n));guidata(hObject, handles);handles.I = imadjustment(handles);axes(handles.axes1)hold on,imshow(handles.I);if handles.path == 1 hold on plot(handles.glbx(handles.st:handles.en),handles.glby(handles.st:handles.en),'color','g') if ~isnan(handles.glbx(handles.n)) hold on,plot(handles.glbx(handles.n),handles.glby(handles.n),'o') endendif handles.path == 2 for i = 1:handles.marker clear px; clear px; px=handles.posx(i,:)'; py=handles.posy(i,:)'; hold on,axes(handles.axes1) py plot(px,py,'color','g') if ~isnan(handles.posx(handles.n)) pxm=handles.posx(i,handles.n)'; pym=handles.posy(i,handles.n)'; hold on,plot(pxm,pym,'o') end endend%set(handles.hp,'Position',[150 280 300 20]);guidata(hObject, handles);% --- Executes on button press in select_marker.function select_marker_Callback(hObject, eventdata, handles)% hObject handle to select_marker (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)if handles.marker==0 warndlg('To Continue First Enter The Marker Name');else %set(IProcessing,'Pointer','crosshair') %k = waitforbuttonpress; %point1 = get(gca,'CurrentPoint'); % button down detected %p = point1(1,1:2); % extract x and y %x = p(1); y = p(2); [x,y] = ginput(1); handles.h = round(str2double(get(handles.Marker_Height,'String'))); handles.w = round(str2double(get(handles.Marker_Width,'String'))); handles.h2 = round(str2double(get(handles.Marker_Height2,'String'))); handles.w2 = round(str2double(get(handles.Marker_Width2,'String'))); handles.mx = fix(x) - round(handles.w/2)+1; handles.my = fix(y) - round(handles.h/2)+1; handles.posi(handles.marker) = handles.n; axes(handles.axes1); tolx = round((handles.w2-handles.w)/2); toly = round((handles.h2-handles.h)/2); rectangle('Position',[handles.mx,handles.my,handles.w,handles.h],'Curvature',[0.2,0.2],'EdgeColor','g') rectangle('Position',[handles.mx-tolx,handles.my-toly,handles.w2,handles.h2],'Curvature',[0.2,0.2],'EdgeColor','r') %set(IProcessing,'Pointer','arrow') guidata(hObject, handles);end% --- Executes on button press in Auto_adjust.function Auto_adjust_Callback(hObject, eventdata, handles)% hObject handle to Auto_adjust (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)[I,Map] = frame2im(handles.mov(1,handles.n));If1 = I(handles.y:handles.y+handles.h,handles.x:handles.x+handles.w,:);clear I;red = ((If1(:,:,1)>handles.rl) & (If1(:,:,1)<handles.rh))*1;I = uint8(red).*If1(:,:,1);%I=rgb2gray(If1);%I=If1(:,:,1);%figure,imshow(I),title('original image');BWs = edge(I, 'sobel', (graythresh(I) * .1));%figure, imshow(BWs), title('binary gradient mask');se90 = strel('line', 2, 90);se0 = strel('line', 2, 0);BWsdil = imdilate(BWs, [se90 se0]);%figure, imshow(BWsdil), title('dilated gradient mask');BWdfill = imfill(BWsdil, 'holes');figure, imshow(BWdfill);title('binary image with filled holes');% item = {If1};% label = {'BWdfill'};% def = {'B'};% export2wsdlg(label, def, item, 'Export to Workspace');%g = size(If1);sz = sum(sum(BWdfill))r = sum(sum(If1(:,:,1).*uint8(BWdfill)))/szg = sum(sum(If1(:,:,2).*uint8(BWdfill)))/szb = sum(sum(If1(:,:,3).*uint8(BWdfill)))/szz=1;dr = sqrt(sum(sum((If1(:,:,1).*uint8(BWdfill) - r).^2)))/zdg = sqrt(sum(sum((If1(:,:,2).*uint8(BWdfill) - g).^2)))/zdb = sqrt(sum(sum((If1(:,:,3).*uint8(BWdfill) - b).^2)))/zhandles.rl = r - dr;handles.rh = r + dr;handles.gl = g - dg;handles.gh = g + dg;handles.bl = b - db;handles.bh = b + db;if handles.rl<1, handles.rl=1; endif handles.gl<1, handles.gl=1; endif handles.bl<1, handles.bl=1; endif handles.rh>255, handles.rh=255; endif handles.gh>255, handles.gh=255; endif handles.bh>255, handles.bh=255; endset(handles.red_low,'Value',handles.rl/255);set(handles.red_high,'Value',handles.rh/255);set(handles.green_low,'Value',handles.gl/255);set(handles.green_high,'Value',handles.gh/255);set(handles.blue_low,'Value',handles.bl/255);set(handles.blue_high,'Value',handles.bh/255);guidata(hObject, handles);imageupdate(hObject,handles)% --- Executes on button press in De_select_marker.function De_select_marker_Callback(hObject, eventdata, handles)% hObject handle to De_select_marker (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)imageupdate(hObject,handles)handles.mx=0;handles.my=0;guidata(hObject, handles);% --- Executes on button press in move_up.function move_up_Callback(hObject, eventdata, handles)% hObject handle to move_up (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)imageupdate(hObject,handles)handles.mx = handles.mx;handles.my = handles.my - 1;axes(handles.axes1)tolx = round((handles.w2-handles.w)/2);toly = round((handles.h2-handles.h)/2);rectangle('Position',[handles.mx,handles.my,handles.w,handles.h],'Curvature',[0.2,0.2],'EdgeColor','g')rectangle('Position',[handles.mx-tolx,handles.my-toly,handles.w2,handles.h2],'Curvature',[0.2,0.2],'EdgeColor','r')guidata(hObject, handles);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -