From f618466c25d43f3bae9e40920273bf77de1e1149 Mon Sep 17 00:00:00 2001 From: leochanj105 Date: Mon, 19 Oct 2020 23:09:30 -0400 Subject: initial sd-vbs initial sd-vbs add sd-vbs sd-vbs --- .../benchmarks/texture_synthesis/src/matlab/clip.m | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/matlab/clip.m (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/clip.m') diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/clip.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/clip.m new file mode 100755 index 0000000..28804f3 --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/clip.m @@ -0,0 +1,32 @@ +% [RES] = clip(IM, MINVALorRANGE, MAXVAL) +% +% Clip values of matrix IM to lie between minVal and maxVal: +% RES = max(min(IM,MAXVAL),MINVAL) +% The first argument can also specify both min and max, as a 2-vector. +% If only one argument is passed, the range defaults to [0,1]. + +function res = clip(im, minValOrRange, maxVal) + +if (exist('minValOrRange') ~= 1) + minVal = 0; + maxVal = 1; +elseif (length(minValOrRange) == 2) + minVal = minValOrRange(1); + maxVal = minValOrRange(2); +elseif (length(minValOrRange) == 1) + minVal = minValOrRange; + if (exist('maxVal') ~= 1) + maxVal=minVal+1; + end +else + error('MINVAL must be a scalar or a 2-vector'); +end + +if ( maxVal < minVal ) + error('MAXVAL should be less than MINVAL'); +end + +res = im; +res(find(im < minVal)) = minVal; +res(find(im > maxVal)) = maxVal; + -- cgit v1.2.2