From d17b33131c14864bd1eae275f49a3f148e21cf29 Mon Sep 17 00:00:00 2001 From: Leo Chan Date: Thu, 22 Oct 2020 01:53:21 -0400 Subject: Squashed commit of the sb-vbs branch. Includes the SD-VBS benchmarks modified to: - Use libextra to loop as realtime jobs - Preallocate memory before starting their main computation - Accept input via stdin instead of via argc Does not include the SD-VBS matlab code. Fixes libextra execution in LITMUS^RT. --- .../toolbox/toolbox_basic/textons/find_textons1.m | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 SD-VBS/common/toolbox/toolbox_basic/textons/find_textons1.m (limited to 'SD-VBS/common/toolbox/toolbox_basic/textons/find_textons1.m') diff --git a/SD-VBS/common/toolbox/toolbox_basic/textons/find_textons1.m b/SD-VBS/common/toolbox/toolbox_basic/textons/find_textons1.m new file mode 100755 index 0000000..b192015 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/textons/find_textons1.m @@ -0,0 +1,37 @@ +function [centers,label,post,d2]=find_textons(fv,ncenters,centers_in,n_iter); +% [centers,label,post,d2]=find_textons(FIw,ncenters,centers_in,n_iter); +% +% find textons using kmeans for windowed portion FIw of filtered image +% +% to start with centers pulled randomly from image, set centers_in=[] + +[N1,N2] =size(fv); + +% take centers randomly from within image +if isempty(centers_in) + rndnum=1+floor(N1*rand(1,ncenters)); + centers_in=fv(rndnum,:); +end + +options = foptions; +options(1)=1; % Prints out error values. +options(5) = 0; +if nargin<4 + n_iter=15; +end +options(14) = n_iter; % Number of iterations. + +[centers,options,d2,post]=kmeans2(centers_in,fv,options); + + +% retrieve cluster number assigned to each feature vector +[minval,label]=min(d2,[],2); + + +h = hist(label(:),[1:max(label(:))]); +a = h>0; +a = cumsum(a); + +[nr,nc] = size(label); +label = reshape(a(label(:)),nr,nc); + -- cgit v1.2.2