%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This is an implementation of CONFIGR, % as described in: % Carpenter, G. A., Gaddam, C. S., & Mingolla, E. (2007). % CONFIGR: A vision-based system for long-range figure completion. Neural Networks, xx(x) xxx-xxx. % Technical Report CAS/CNS TR-2007-016, Boston, MA: Boston University. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Programmed by Chaitanya Sai (August 2007) %%%%%%%%%%%%%%%%%%%%%%%%% % % The notation follows the article's notation, % as does the headers for each step of the % algorithm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if exist('IallRects') IrectSize=IallRects(:,2)+IallRects(:,4)-IallRects(:,1)-IallRects(:,3); [dumArray sortRect]=sort(IrectSize); IallRects=IallRects(sortRect,:); NumTotalRects=size(IallRects,1); stpRects=1; while stpRects<=NumTotalRects tmpVect=IallRects(stpRects,:); sizRect=tmpVect(2)+tmpVect(4)-tmpVect(1)-tmpVect(3); EmptyRect = (isempty(tmpVect(1)+1:tmpVect(2)-1) || isempty(tmpVect(3)+1:tmpVect(4)-1)); if (~EmptyRect) && sum(max(max(IfillIter(tmpVect(1)+1:tmpVect(2)-1,tmpVect(3)+1:tmpVect(4)-1))) == [1/dumArray(stpRects) 0]) && sum(sum(IpixelsFillA(tmpVect(1)+1:tmpVect(2)-1,tmpVect(3)+1:tmpVect(4)-1)))==0; tmp_dummy=0; [NborGround , tmp_dummy]=CheckOutBoundGround(tmpVect(1),tmpVect(2),tmpVect(3),tmpVect(4),SubPixRes,IpixelsFillA,FillNoFillVal,ImSize,tmp_dummy); NumFilled_Rule3(round((kk-1)/5)+1)=NumFilled_Rule3(round((kk-1)/5)+1)+tmp_dummy; gCorner=... (sum((IpixelsFillA(tmpVect(1)+1,tmpVect(3)-1)==[1 FIGR_VAL*(.15+((1-.15)*Iemergent_corners{4}(tmpVect(1),tmpVect(3))))])... +(IpixelsFillA(tmpVect(1)-1,tmpVect(3)+1)==[1 FIGR_VAL*(.15+((1-.15)*Iemergent_corners{4}(tmpVect(1),tmpVect(3))))]))>1)+... (sum((IpixelsFillA(tmpVect(2)+1,tmpVect(4)-1)==[1 FIGR_VAL*(.15+((1-.15)*Iemergent_corners{2}(tmpVect(2),tmpVect(4))))])... +(IpixelsFillA(tmpVect(2)-1,tmpVect(4)+1)==[1 FIGR_VAL*(.15+((1-.15)*Iemergent_corners{2}(tmpVect(2),tmpVect(4))))]))>1)+... (sum((IpixelsFillA(tmpVect(1)-1,tmpVect(4)-1)==[1 FIGR_VAL*(.15+((1-.15)*Iemergent_corners{3}(tmpVect(1),tmpVect(4))))])... +(IpixelsFillA(tmpVect(1)+1,tmpVect(4)+1)==[1 FIGR_VAL*(.15+((1-.15)*Iemergent_corners{3}(tmpVect(1),tmpVect(4))))]))>1)+... (sum((IpixelsFillA(tmpVect(2)+1,tmpVect(3)+1)==[1 FIGR_VAL*(.15+((1-.15)*Iemergent_corners{1}(tmpVect(2),tmpVect(3))))])... +(IpixelsFillA(tmpVect(2)-1,tmpVect(3)-1)==[1 FIGR_VAL*(.15+((1-.15)*Iemergent_corners{1}(tmpVect(2),tmpVect(3))))]))>1)+... NborGround; if (gCorner==0) ; %This rectangle is a candidate for filling-in as FIGURE. else IpixelsTempIter12(tmpVect(1):tmpVect(2),tmpVect(3):tmpVect(4))=max(FillNoFillVal*ones(size(I(tmpVect(1):tmpVect(2),tmpVect(3):tmpVect(4)))),I(tmpVect(1):tmpVect(2),tmpVect(3):tmpVect(4))); IpixelsFillTempIter12(tmpVect(1):tmpVect(2),tmpVect(3):tmpVect(4))=(IpixelsTempIter12(tmpVect(1):tmpVect(2),tmpVect(3):tmpVect(4))==.5)*.5+(IpixelsTempIter12(tmpVect(1):tmpVect(2),tmpVect(3):tmpVect(4))==FillNoFillVal)*FillNoFillVal; IpixelsFilledInTemp(tmpVect(1):tmpVect(2),tmpVect(3):tmpVect(4))=1; NumFilled_GROUND(round((kk-1)/5)+1)=NumFilled_GROUND(round((kk-1)/5)+1)+1; filled_in_grnd_rects_store(grnd_step,:)=[round((kk-1)/5)+1 tmpVect(1) tmpVect(2) tmpVect(3) tmpVect(4)]; grnd_step=grnd_step+1; if kk==2*5+1 IrectsShow(tmpVect(1):tmpVect(2),tmpVect(3):tmpVect(4))=1; end end if (dumArray(stpRects)