74 lines
2.1 KiB
Matlab
74 lines
2.1 KiB
Matlab
function [ varargout ] = Fillsk2( varargin )
|
|
% FILLSK2 Summary of this function goes here
|
|
% [ out ] = Fillsk2( Im,squ,L,Lrgb )
|
|
narginchk(5,6);
|
|
[Im,squ,L,xclik,yclik] = varargin{1:5};
|
|
|
|
axe1=varargin{6};
|
|
axes(axe1);
|
|
%hold(axe1,'on');
|
|
[indices, TabInd, I, J]=computePPV(squ,xclik,yclik);
|
|
SkelCord=zeros(abs(TabInd(2)-TabInd(1)),2);
|
|
TabPlotX=[];
|
|
TabPlotY=[];
|
|
if TabInd(2)<TabInd(1)
|
|
for k=TabInd(2): TabInd(1)
|
|
SkelCord(k-TabInd(2)+1,:)=[J(k),I(k)];
|
|
% h=rectangle('Position',[J(k),I(k),2,2],...
|
|
% 'EdgeColor','g','LineWidth',2);
|
|
% set(h,'Parent',axe1);
|
|
TabPlotX=[TabPlotX J(k)];
|
|
TabPlotY=[TabPlotY I(k)];
|
|
|
|
end
|
|
end
|
|
if TabInd(2)>TabInd(1)
|
|
for k=TabInd(1): TabInd(2)
|
|
SkelCord(k-TabInd(1)+1,:)=[J(k),I(k)];
|
|
% h=rectangle('Position',[J(k),I(k),2,2],...
|
|
% 'EdgeColor','g','LineWidth',2);
|
|
% set(h,'Parent',axe1);
|
|
TabPlotX=[TabPlotX J(k)];
|
|
TabPlotY=[TabPlotY I(k)];
|
|
end
|
|
end
|
|
% h1=rectangle('Position',[indices(1,2), indices(1,1),2,2],...
|
|
% 'EdgeColor','b','LineWidth',3);
|
|
% h2=rectangle('Position',[indices(2,2), indices(2,1),2,2],...
|
|
% 'EdgeColor','b','LineWidth',3);
|
|
%
|
|
% set(h1,'Parent',axe1);
|
|
% set(h2,'Parent',axe1);
|
|
|
|
pixlist = regionprops(L,'PixelList'); % list de pixel de region
|
|
r = regionprops(L,'Centroid');
|
|
labInd=zeros(length(pixlist),1);
|
|
rTab=zeros(length(r),1);
|
|
cTab=zeros(length(r),1);
|
|
for i=2:length(pixlist)
|
|
region=struct2cell(pixlist(i));
|
|
a= intersect(region{1}(:,1),SkelCord(:,1));
|
|
b= intersect(region{1}(:,2),SkelCord(:,2));
|
|
if ((~isempty(a)) && (~isempty(b)))
|
|
labInd(i)=i;
|
|
px=struct2cell(r(i));
|
|
rTab(i)=floor(px{1}(:,1));
|
|
cTab(i)=floor(px{1}(:,2));
|
|
end
|
|
end
|
|
|
|
Ls = bwselect(L,rTab,cTab,8);
|
|
%figure;imshow(Ls,[]) ;title('Selected labels');
|
|
|
|
CCs=bwconncomp(Ls);
|
|
M=labelmatrix(CCs);
|
|
|
|
%Lrgb2 = label2rgb(M,'jet',[.6 .6 .5]);
|
|
|
|
%figure;imshow(Im);hold on ;title('Selected Labels laid on Source Image');
|
|
%imTrans = imshow(Lrgb2);
|
|
%set(imTrans, 'AlphaData', 0.3);
|
|
|
|
|
|
varargout = {Ls CCs TabPlotX TabPlotY};
|
|
end |