diff options
| author | ziejd2 | 2017-09-28 15:04:40 -0500 |
|---|---|---|
| committer | ziejd2 | 2017-09-28 15:04:40 -0500 |
| commit | 8070dc963753142bb86c4ed698d91fd623ed28e7 (patch) | |
| tree | d0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/KPMtools/montageKPM2.m | |
| parent | 7cc31810d53176e805532b2789955f4eedbce6bb (diff) | |
| download | BNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz | |
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/KPMtools/montageKPM2.m')
| -rw-r--r-- | sourcecodes/bnt-master/KPMtools/montageKPM2.m | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/KPMtools/montageKPM2.m b/sourcecodes/bnt-master/KPMtools/montageKPM2.m new file mode 100644 index 00000000..1bd521a9 --- /dev/null +++ b/sourcecodes/bnt-master/KPMtools/montageKPM2.m @@ -0,0 +1,69 @@ +function montageKPM2(data) +% data(y,x,b,f) or data(y,x,f) +% can be double - uses imagesc to display, not imshow +% based on imaqmontage + +if ndims(data)==3 + nr = size(data,1); nc = size(data,2); Npatches = size(data,3); Nbands = 1; + data = reshape(data, [nr nc Nbands Npatches]); +else + nr = size(data,1); nc = size(data,2); Nbands = size(data,3); Npatches = size(data,4); +end +nativeVal = data(1, 1); +dataOrig = data; + +%put a black border around them for display purposes +border = 5; +bgColor = min(data(:)); +%bgColor = max(data(:)); +data = bgColor*ones(nr+2*border, nc+2*border, Nbands, Npatches, class(data)); +data(border+1:end-border, border+1:end-border, :, :) = dataOrig; + +[width, height, bands, nFrames] = size(data); + +% Determine the number of axis rows and columns. +axCols = sqrt(nFrames); +if (axCols<1) + % In case we have a slim image. + axCols = 1; +end +axRows = nFrames/axCols; +if (ceil(axCols)-axCols) < (ceil(axRows)-axRows), + axCols = ceil(axCols); + axRows = ceil(nFrames/axCols); +else + axRows = ceil(axRows); + axCols = ceil(nFrames/axRows); +end + +% Size the storage to hold all frames. +storage = repmat(nativeVal, [axRows*width, axCols*height, bands, 1]); + +% Fill the storage up with data pixels. +rows = 1:width; +cols = 1:height; +for i=0:axRows-1, + for j=0:axCols-1, + k = j+i*axCols+1; + if k<=nFrames, + storage(rows+i*width, cols+j*height, :) = data(:,:,:,k); + else + break; + end + end +end + + +% Display the tiled frames nicely and +% pop the window forward. +im = imagesc(storage); + +ax = get(im, 'Parent'); +fig = get(ax, 'Parent'); +set(ax, 'XTick', [], 'YTick', []) +figure(fig) + +% If working with single band images, update the colormap. +if 0 % bands==1, + colormap(gray); +end |
