Skip to content
Snippets Groups Projects
Commit 1d6f5c4b authored by Andrew Cohen's avatar Andrew Cohen
Browse files

label mapping in importExport

parent 5110c884
No related branches found
No related tags found
No related merge requests found
......@@ -240,22 +240,24 @@ end
close(conn);
% tids -- trackid,proxy,tbegin,tend
% tids -- trackid,label,tbegin,tend
function im=setMissingTrackLabels(conn,im,tids,t)
idsIm=unique(im(:));
idsIm(idsIm==0)=[];
tctc=t-1;
idx=find(tctc>=tids(:,3) & tctc<=tids(:,4));
idsNeeded=tids(idx,1);
idsMissing=setdiff(idsNeeded,idsIm);
if isempty(idsMissing)
idsNeeded=tids(idx,2);
labelsMissing=setdiff(idsNeeded,idsIm);
if isempty(labelsMissing)
return
end
for i=1:length(idsMissing)
for i=1:length(labelsMissing)
% get the centroids
cmd=['select time,centroid from tblCells where trackID=' num2str(idsMissing(i))];
idxMissing=find(tids(:,2)==labelsMissing(i));
tidMissing=tids(idxMissing,1);
cmd=['select time,centroid from tblCells where trackID=' num2str(tidMissing)];
q=ljsFetch(conn,cmd);
trackTime=cell2mat(q(:,1));
cx=cellfun(@jsondecode,q(:,2),'uniformoutput',false);
......@@ -286,17 +288,16 @@ for i=1:length(idsMissing)
w1=1-(trackTime(idx1)-t)/(trackTime(idx1)-trackTime(idx0));
cxInterp=cx{idx0}.*w0 + cx{idx1} .* w1 ;
cxInterp=round(cxInterp);
idxLabel=find(tids(:,1)==idsMissing(i));
if length(size(im))<3
cxInterp=cxInterp(1:2);
cxInterp=min(cxInterp,[size(im,2);size(im,1)]);
cxInterp=max(cxInterp,ones(length(cxInterp),1));
im(cxInterp(2),cxInterp(1))=tids(idxLabel,2);
im(cxInterp(2),cxInterp(1))=labelsMissing(i);
else
cxInterp=min(cxInterp,[size(im,2);size(im,1);size(im,3)]);
cxInterp=max(cxInterp,ones(length(cxInterp),1));
im(cxInterp(2),cxInterp(1),cxInterp(3))=tids(idxLabel,2);
im(cxInterp(2),cxInterp(1),cxInterp(3))=labelsMissing(i);
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment