extractPixelsFromNrrd.m 562 B

1234567891011121314151617181920
  1. function v0=extractPixelsFromNrrd(file)
  2. %extract a nRegion x nx x ny x nz table where
  3. %each point contained in segmentation corresponds to
  4. %a row in output table v0
  5. addpath('nrrd_read_write_rensonnet');
  6. hInfo=nhdr_nrrd_read(file,true);
  7. v0=zeros(0,4);
  8. for idx=1:10
  9. f=find(hInfo.data==idx);
  10. n=size(f,1)
  11. if n==0
  12. continue
  13. end
  14. [a,b,c]=ind2sub(size(hInfo.data),f);
  15. v0=[v0; [idx*ones(n,1) a b c] ];
  16. end
  17. %switch to zero based matrix addressing
  18. v0(:,2:4)=v0(:,2:4)-1;