56 lines
2.0 KiB
Matlab
56 lines
2.0 KiB
Matlab
function [ varargout ] = computeProjetion( varargin)% p1,p2, p3,axe )
|
|
%computeProjetion Summary of this function goes here
|
|
% start(x,y),skel, imlb,imChan{:},
|
|
narginchk(4,4);
|
|
labelStack=varargin{1};
|
|
skel=varargin{2};
|
|
imlb=varargin{3};
|
|
imChan=varargin{4};
|
|
|
|
[stackRegion centre Io bb orientlist xymin xymax ]=computelabPosVal(imChan,imlb, labelStack);
|
|
%disp(c);
|
|
|
|
varargout={stackRegion centre Io bb orientlist xymin xymax };%ell2mat(Io);
|
|
end
|
|
function [ varargout ] = computelabPosVal(imChan, imlb, labelStat)
|
|
%aricentre de tous les label et leur valeur
|
|
r = regionprops(imlb,imChan,'Centroid');
|
|
bb=regionprops( imlb,imChan,'BoundingBox');
|
|
nbregion = size(r,1);
|
|
Imgs = regionprops(imlb,imChan,'Image'); %liste de maske de region a extraire
|
|
pixlist = regionprops(imlb,imChan,'PixelList'); % list de pixel de region
|
|
% on recupére les Xmin Xmaxet Ymin Ymax par la suite
|
|
orientlist = regionprops(imlb,imChan,'Orientation'); % list de angle a compensé dans chaque label
|
|
xymin=zeros(nbregion,2);xymax=zeros(nbregion,2);
|
|
centre={};
|
|
stackRegion={};
|
|
Io={};
|
|
if isempty(labelStat(:))
|
|
output_args=0;
|
|
return;
|
|
end
|
|
|
|
for k =1:labelStat.NumObjects
|
|
|
|
|
|
centre{k} = r(k).Centroid;
|
|
stackRegion{k}=imrotate(Imgs(k).Image,-orientlist(k).Orientation);
|
|
stackRegion{k}(find(stackRegion{k} ==0))=k;
|
|
%region de la cellules
|
|
thisBB=bb(k).BoundingBox;
|
|
sI = imcrop(imChan,[thisBB(1), thisBB(2),thisBB(3), thisBB(4)]);
|
|
sM = uint16(imcrop(imlb,[thisBB(1), thisBB(2),thisBB(3), thisBB(4)]));
|
|
%Mc=imrotate(sI.*sM, -45, 'bilinear','crop');
|
|
%Mc=imrotate(sI.*sM, -45, 'bilinear','loose');
|
|
I =sI.*sM;
|
|
%I(find(I >0))=k;
|
|
%imshow(I)
|
|
Mc=imrotate(I, -orientlist(k).Orientation, 'bilinear','crop');
|
|
out = imresize(Mc,'OutputSize',[50 50]);
|
|
|
|
Io{1,k}=out;
|
|
|
|
end
|
|
varargout = {cat(1,stackRegion) centre Io bb cat(1,orientlist.Orientation) xymin xymax };
|
|
end
|