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 --- .../texture_synthesis/src/matlab/pgmWrite.m | 120 +++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmWrite.m (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmWrite.m') diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmWrite.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmWrite.m new file mode 100755 index 0000000..09c14c9 --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/pgmWrite.m @@ -0,0 +1,120 @@ +% RANGE = pgmWrite(MTX, FILENAME, RANGE, TYPE, COMMENT) +% +% Write a MatLab matrix to a pgm (graylevel image) file. +% This format is accessible from the XV image browsing utility. +% +% RANGE (optional) is a 2-vector specifying the values that map to +% black and white, respectively. Passing a value of 'auto' (default) +% sets RANGE=[min,max] (as in MatLab's imagesc). 'auto2' sets +% RANGE=[mean-2*stdev, mean+2*stdev]. 'auto3' sets +% RANGE=[p1-(p2-p1)/8, p2+(p2-p1)/8], where p1 is the 10th percentile +% value of the sorted MATRIX samples, and p2 is the 90th percentile +% value. +% +% TYPE (optional) should be 'raw' or 'ascii'. Defaults to 'raw'. + +% Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96. + +function range = pgmWrite(mtx, fname, range, type, comment ); + +[fid,msg] = fopen( fname, 'w' ); + +if (fid == -1) + error(msg); +end + +%------------------------------------------------------------ +%% optional ARGS: + +if (exist('range') ~= 1) + range = 'auto'; +end + +if (exist('type') ~= 1) + type = 'raw'; +end +%------------------------------------------------------------ + +%% Automatic range calculation: +if (strcmp(range,'auto1') | strcmp(range,'auto')) + [mn,mx] = range2(mtx); + range = [mn,mx]; + +elseif strcmp(range,'auto2') + stdev = sqrt(var2(mtx)); + av = mean2(mtx); + range = [av-2*stdev,av+2*stdev]; % MAGIC NUMBER: 2 stdevs + +elseif strcmp(range, 'auto3') + percentile = 0.1; % MAGIC NUMBER: 0