2222
2323% Edit the above text to modify the response to help ImageSegmentation
2424
25- % Last Modified by GUIDE v2.5 16 -Nov-2015 15: 20:52
25+ % Last Modified by GUIDE v2.5 17 -Nov-2015 20:49:31
2626
2727% set(gcf,'units','normalized')%?????,??????????;
2828
@@ -266,7 +266,7 @@ function selectpoint_Callback(hObject, eventdata, handles)
266266% %hold off
267267% end
268268
269- numberOfPoints = inputdlg({' number of inside points' ,' number of outside points' , ' number of pixels ' });
269+ numberOfPoints = inputdlg({' number of inside points' ,' number of outside points' });
270270% set the inside points 0, and put them in the front
271271
272272label = zeros(1 ,str2num(cell2mat(numberOfPoints(1 ))));
@@ -327,7 +327,7 @@ function selectpoint_Callback(hObject, eventdata, handles)
327327
328328global numofpixels ;
329329global newsegOutline ;
330- numofpixels= str2num(cell2mat(numberOfPoints(3 )));
330+ % numofpixels=str2num(cell2mat(numberOfPoints(3)));
331331% newsegOutline = Expand(segOutline,numofpixels);
332332axes(handles .axes );
333333hold on
@@ -430,6 +430,7 @@ function selectpoint_Callback(hObject, eventdata, handles)
430430% end
431431% plot(gray);title(vector);
432432
433+
433434% D = bwdist(segOutline,'euclidean');
434435% [px,py] = gradient(D); % for example px(2,1) = (D(3,1)+D(1,1))/2
435436% figure;imagesc(D);
@@ -438,6 +439,7 @@ function selectpoint_Callback(hObject, eventdata, handles)
438439% vector = 5;
439440% graymapIn = zeros(length(segOutline(1,:)),length(segOutline(:,1)));
440441% graymapOut = graymapIn;
442+ %
441443% [x,y]=find(segOutline);
442444% for i = 1:length(find(segOutline))
443445% positionX = vector*px(x(i),y(i))+x(i);
@@ -454,14 +456,17 @@ function selectpoint_Callback(hObject, eventdata, handles)
454456% posX(i) = px(x(i),y(i));
455457% posY(i) = py(x(i),y(i));
456458% end
459+ % figure;imshow(neighborIn);
460+ % figure;imshow(segOutline);
461+ % figure;imshow(neighborOut);
457462
458463
459464% --- Executes on button press in average.
460465function average_Callback(hObject , eventdata , handles )
461466% hObject handle to average (see GCBO)
462467% eventdata reserved - to be defined in a future version of MATLAB
463468% handles structure with handles and user data (see GUIDATA)
464- global segOutline ;
469+ % global segOutline;
465470global volume ;
466471global cflag ;
467472global rect ;
@@ -668,6 +673,7 @@ function expand_Callback(hObject, eventdata, handles)
668673global numofpixels ;
669674global newsegOutline ;
670675global evalue ;
676+ numofpixels = str2num(get(handles .ExpandNum ,' String' ));
671677newsegOutline = Expand(segOutline ,numofpixels );
672678axes(handles .axes );
673679hold on
@@ -683,7 +689,47 @@ function expand_Callback(hObject, eventdata, handles)
683689hold off
684690
685691
686- % expand the segOutline to 3 pixels
692+ % --- Executes during object creation, after setting all properties.
693+ function ExpandNum_CreateFcn(hObject , eventdata , handles )
694+ % hObject handle to ExpandNum (see GCBO)
695+ % eventdata reserved - to be defined in a future version of MATLAB
696+ % handles empty - handles not created until after all CreateFcns called
697+
698+ % Hint: edit controls usually have a white background on Windows.
699+ % See ISPC and COMPUTER.
700+ if ispc && isequal(get(hObject ,' BackgroundColor' ), get(0 ,' defaultUicontrolBackgroundColor' ))
701+ set(hObject ,' BackgroundColor' ,' white' );
702+ end
703+ set(hObject ,' String' ,3 );
704+
705+
706+ % --- Executes on button press in Contrast.
707+ function Contrast_Callback(hObject , eventdata , handles )
708+ % hObject handle to Contrast (see GCBO)
709+ % eventdata reserved - to be defined in a future version of MATLAB
710+ % handles structure with handles and user data (see GUIDATA)
711+ global volume ;
712+ global cflag ;
713+ global rect ;
714+ global segOutline ;
715+ slct= get(handles .slice ,' value' );
716+ slice= volume(: ,: ,slct );
717+ if cflag == 1
718+ slicecut= slice(rect(1 ): rect(2 ),rect(3 ): rect(4 ));
719+ slice= slicecut ;
720+ end
721+
722+ neighborIn = Expand(segOutline ,-1 );
723+ neighborOut = Expand(segOutline ,1 );
724+ valueIn= sum(neighborIn .* slice )/sum(neighborIn );
725+ valueOut= sum(neighborOut .* slice )/sum(neighborOut );
726+ contrast = valueOut / valueIn ;
727+ set(handles .ContrastValue , ' String' , num2str(contrast )); % 0 means black and 1 means white
728+ set(handles .contrastIn , ' String' , num2str(valueIn ));
729+ set(handles .contrastOut , ' String' , num2str(valueOut ));
730+
731+
732+ % expand the segOutline to several pixels
687733function [newsegOutline ] = Expand(segOutline ,numofpixels )
688734% msgbox('a');
689735% disp(segOutline);
@@ -694,16 +740,33 @@ function expand_Callback(hObject, eventdata, handles)
694740for i = 1 : length(m(: ))
695741 if m(i )>=center(1 )
696742 if n(i )>=center(2 )
697- newsegOutline(m(i ): m(i )+numofpixels - 1 ,n(i ): n(i )+numofpixels - 1 )=1 ;
743+ if numofpixels > 0
744+ newsegOutline(m(i ): m(i )+numofpixels ,n(i ): n(i )+numofpixels )=1 ;
745+ else
746+ newsegOutline(m(i )+numofpixels : m(i ),n(i )+numofpixels : n(i ))=1 ;
747+ end
698748 else
699- newsegOutline(m(i ): m(i )+numofpixels - 1 ,n(i )-numofpixels + 1 : n(i ))=1 ;
749+ if numofpixels > 0
750+ newsegOutline(m(i ): m(i )+numofpixels ,n(i )-numofpixels : n(i ))=1 ;
751+ else
752+ newsegOutline(m(i )+numofpixels : m(i ),n(i ): n(i )-numofpixels )=1 ;
753+ end
700754 end
701755 else
702756 if n(i )>=center(2 )
703- newsegOutline(m(i )-numofpixels + 1 : m(i ),n(i ): n(i )+numofpixels - 1 )=1 ;
757+ if numofpixels > 0
758+ newsegOutline(m(i )-numofpixels : m(i ),n(i ): n(i )+numofpixels )=1 ;
759+ else
760+ newsegOutline(m(i ): m(i )-numofpixels ,n(i )+numofpixels : n(i ))=1 ;
761+ end
704762 else
705- newsegOutline(m(i )-numofpixels + 1 : m(i ),n(i )-numofpixels + 1 : n(i ))=1 ;
763+ if numofpixels > 0
764+ newsegOutline(m(i )-numofpixels : m(i ),n(i )-numofpixels : n(i ))=1 ;
765+ else
766+ newsegOutline(m(i ): m(i )-numofpixels ,n(i ): n(i )-numofpixels )=1 ;
767+ end
706768 end
707769 end
708770end
709771newsegOutline = newsegOutline - segOutline ;
772+
0 commit comments