| function [conf, jobId] = bk_calcRoiHistograms(conf, varargin) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
|
|
| conf_.histDir = '' ; |
| conf_.ppDir = '' ; |
| conf_.imageDbPath = '' ; |
| conf_.roiDbPath = '' ; |
| conf_.roiSel = [] ; |
| conf_.className = '' ; |
| conf_.featNames = {} ; |
| conf_.featOpts = struct ; |
| conf_.roiMagnif = 0 ; |
| conf_.maxDenseDim = +inf ; |
| conf_.normalize = true ; |
| conf_.noClobber = false ; |
|
|
| if nargin < 1, conf = conf_ ; return ; end |
| conf = override(conf_, conf, 'skip', 'warn') ; |
|
|
| [jobId, taskId] = parallelDriver('numNodes', 40, varargin{:}) ; |
| if ~isnan(jobId) & isnan(taskId) ; return ; end |
|
|
| ensuredir(conf.histDir) ; |
|
|
| roidb = getRoiDb(conf.roiDbPath) ; |
| imdb = getImageDb(conf.imageDbPath) ; |
|
|
| imageIndex = [imdb.images.id] ; |
|
|
| if isempty(conf.roiSel) |
| roiSel = 1:length([roidb.rois.id]) ; |
| else |
| roiSel = conf.roiSel ; |
| end |
|
|
| |
| |
| |
|
|
| numSkipped = 0 ; |
|
|
| for rsi = 1:length(roiSel) |
|
|
| |
| locked = parallelLock(rsi, varargin{:}) ; |
| if ~locked, continue ; end |
|
|
| idx = roiSel(rsi) ; |
| roiId = roidb.rois.id(idx) ; |
| roiImageId = roidb.rois.imageId(idx) ; |
| roiBox = roidb.rois.box(:,idx) ; |
| roiJitter = roidb.rois.jitter(:,idx) ; |
|
|
| |
| roiHistPath = fullfile(conf.histDir, sprintf('%012.0f', roiId)) ; |
| if conf.noClobber & checkFile(roiHistPath) |
| numSkipped = numSkipped + 1 ; |
| continue ; |
| end |
|
|
| fprintf('Processing ROI ''%012.0f'' (%d of %d).\n', ... |
| roiId, rsi, length(roiSel)) ; |
|
|
| |
| ii = binsearch(imageIndex, roiImageId) ; |
| imageName = imdb.images.name{ii} ; |
|
|
| |
| if roiJitter > 0 |
| jitterName = decodeEnum(roidb.jitters, roiJitter) ; |
| imageName = [imageName '_' lower(jitterName)] ; |
| end |
|
|
| |
| fprintf('\tComputing histograms.\n') ; tic ; |
| roiHists = getAllRoiHists(conf, ... |
| imageName, ... |
| roiBox, ... |
| 'className', conf.className, ... |
| 'magnif', conf.roiMagnif, ... |
| 'maxDenseDim', conf.maxDenseDim, ... |
| 'normalize', conf.normalize) ; |
| fprintf('\tComputed in %.2f s.\n', toc) ; |
|
|
| |
| roiHistPath = fullfile(conf.histDir, sprintf('%012.0f', roiId)) ; |
| fprintf('\tSaving to ''%s''.\n', roiHistPath) ; |
| ssave(roiHistPath, '-STRUCT', 'roiHists') ; |
| end |
|
|
| fprintf('\t%d where skipped to avoid clobbering.\n', numSkipped) ; |
|
|