% % L_system_3D_tiling( strOutFilestemOpt, nGenerations, nSymbolsAndRules, % nDecimate, nOffset, % strMotifFilename, arrayStart, varargin ) % ------------------------------------------------------------------------- % % Creates a 3-D L-System matrix (optionally a Space Software format % volume), with symbols represented by grayscale or optional set of % motifs. % % [NOTE: Currently strMotifFilename and rule images are ignored.] % % USAGE: nimOut = L_system_3D_tiling( '2-symbol_Thue-Morse_tiling', 4, 2, 1, 0, 'motif_image.png', 0, [0 1; 1 0], [1 0; 0 1] ); % OR nimOut = L_system_3D_tiling( '2-symbol_Thue-Morse_pattern', 4, 2, 1, 0, '', 0, [0 1; 1 0], [1 0; 0 1] ); % % % OR nimOut = L_system_3D_tiling( 'output_name', 4, 2, 1, 0, 'motif_image.png', 0, 'rule_image.png' ); % % % OR nimOut = L_system_3D_tiling( 'output_name', 4, 2, 1, 0, '', 0, 'rule_image.png' ); % % INPUT: % % strMotifFilename - Optional filestem for resulting PNG image. The % default filestem is 'LS'. All stems will have % system parameters appended. % nGenerations - [positive integer] Number of recursive iterations % for which the rules are applied to the initial % symbol(s). % strMotifFilename - Filename of an image containing tiling motifs. % [NOTE: Currently strMotifFilename is ignored.] % [NOTE: Currently the image must be either twice as wide as it is % high (4x2), or four times (for nNbrRule == 2) as high as it % is wide ((4x2)x4). Also, the dimensions must be even.] % % nNbrRule - [0,1] 0: B/W two symbol, strMotifFilename is ignored. % 1: "simple" two motif. % 2: "octal" eight motif, considers near neighbor % configuration. % [Note: "octal" edge motifs are replaced with % black, as the neighbors are not defined.] % [Note: "octal" also accepts 32 motifs % shadings for each of four rotations of % each motif.] % 3: "nested", cyclic four motif % % HARDCODED (immediately below function declaration): % % bShowResult - [0, 1] Show progress, display final image and % algorithm graphic in figure. % % bWriteResults - [0, 1] Write final image and algorithm graphic to % an image file. % % bCreateHistogram - [0, 1] Write a histogram of rule values numbered % from 1 to nSymbolsAndRules. % % nByGenOversample - [positive integer] Oversampling ratio for % generation frames graphic. % % nByGenWidthMax - [positive integer] Maximum width for % a generation graphics frame. % % bCreateGAFrames - [positive integer]Not currently used. % % strOutFileName - Convention for default (if strOutFilename == '') % output file name and format. % Default naming is: % TM[nNbrRule]_[nGenerations]_[strMotifFilename].png % % OUTPUT: % % % Returns an RGB image array. Depending on hardcoded options,the program % % will display and/or write a variety of auxilliary graphics. For the % % simplest systems (no motif as image,a single element initial initial % % condition, 2 x 2 rules) the dimensions of the final image will be % % 2^nGenerations x 2^nGenerations. % % If hardcoded bWriteResults == 1 creates an % image file called TM_[nGenerations]_[strMotifFilename].png, % and if bShowResult == 1 displays progress and a Matlab figure of the % image. % % % FUNCTION CALLS and DEPENDENCIES: % % Requires these image resources in same directory: % -> LS_rule_graphic_1.png % -> LS_rule_graphic_2.png % -> LS_rule_graphic_3.png % % If an image is given as a motif: % -> interp2_fa.m % -> interp1_fa.m % % Mark Dow, January 1, 2007 % Mark Dow, modified June 5, 2007 (Derived from Thue_Morse_tiling.m) % Mark Dow, modified August 23, 2007 (motif usage modifications) % Mark Dow, modified September 15, 2007 (handle images as rules) % Mark Dow, modified September 22, 2007 (output rule set graphic) % Mark Dow, modified October 16, 2007 (by generation frames graphic) % Mark Dow, modified December 5, 2007 (Derived from L_system_tiling.m) % Mark Dow, modified December 9, 2007 (coding of parameters in output filestem) % % TERMS FOR USE: There are no restrictions on the use of this code, % auxilliary code and other required resources. Claiming % to be the originator, explicitly or implicitly, is bad % karma. A link (if appropriate), a note to % dow[at]uoregon.edu, and credit are appreciated but not % required. % function nimOut = L_system_3D_tiling( strOutFilestemOpt, nGenerations, nSymbolsAndRules, nDecimate, nOffset, strMotifFilename, arrayInit, varargin ) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % hardcoded parameters bShowResult = 1; % [0,1] bWriteResults = 1; % [0,1] bWriteTilingOnly = 0; % [0,1] bCreateHistogram = 0; % [0,1] nByGenOversample = 2; nByGenWidthMax = 81; bCreateGAFrames = 0; % [0,1] % not used % Sanity check: at least one of the above booleans should be true. % hardcoded parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% arrayRules = 0; szRules = 0; imMotifs = -1; szMotifs = -1; imRules = -1; % Assemble an array of rules from function arguements. if nargin == 8 % % Extract rules from the eighth arguement's image file: % strRulesFilename = varargin{1}; % % % If the rules image is color, assign a numeric rule to each % % unique color: % %imRules = double( imread( strRulesFilename ) ); % % % Load the rules image into a 24 bit color array: % infRules = imfinfo( strRulesFilename ); % if infRules.ColorType == 'truecolor' % if infRules.Height == 1 % imRules(1,:,:) = imread( strRulesFilename ); % else % imRules = imread( strRulesFilename ); % end % else if infRules.ColorType == 'grayscale' % imGrayRules = imread( strRulesFilename ); % szGrayRules = size( imGrayRules ); % % r0 = 0 % % for i = 1 : szGrayRules(1)*szGrayRules(2) % % if % % end % imRules( 1:szGrayRules(1), 1:szGrayRules(2), 1:3 ) = 0; % imRules(:,:,1) = imGrayRules; % imRules(:,:,2) = imGrayRules; % imRules(:,:,3) = imGrayRules; % else if infRules.ColorType == 'indexed' % fprintf( [ 'Indexed image format for the rules is not currently supported.' ] ); % return; % end % end % end % % szRules = size( imRules ); % % % Find the unique colors of the rule image and initial conditions. % SymbolColor( 1:nSymbolsAndRules, 1:3 ) = -1; % imRulesCopy = imRules; % % % Count unique colors in rules before scaling based on total % % number of rules: % nClrsInRules = 0; % imRulesTemp = imRules; % for i = 1 : szRules(2) % for j = 1 : szRules(1) % % clr = imRulesTemp(j,i,:); % if clr(1) ~= 999; % imRulesTemp; % nClrsInRules = nClrsInRules + 1; % for ii = 1 : szRules(2) % for jj = 1 : szRules(1) % if imRulesTemp(jj,ii,:) == clr; % % imRulesCopy( jj,ii,:) = nClrsInRules - 1; % imRulesTemp( jj,ii,:) = 999; % end % end % end % end % end % end % % % % imRulesCopy = (nSymbolsAndRules-1)*((nClrsInRules-1)/(nSymbolsAndRules-1))*imRulesCopy/( max(max(max(imRulesCopy))) ); % imRulesCopyTemp = imRulesCopy; % for i = 0 : nClrsInRules - 1 % iLowest = find( imRulesCopy == min(min(min(imRulesCopy))) ); % imRulesCopyTemp( iLowest ) = i; % imRulesCopy( iLowest ) = 99999; % clear iLowest % end % imRulesCopy = imRulesCopyTemp; % % imRulesCopy = reshape( imRulesCopy, szRules(1)*szRules(2), 3 ); % szRulesOnly = size(imRulesCopy); % imInitCopy = arrayInit; % szInit = size(arrayInit); % %reshape( arrayInit, szInit(1)*szInit(2), 1 ) % % Append the initial array to the rules. % for i = 1 : szInit(1) % for j = 1 : szInit(2) % imRulesCopy( szRulesOnly(1) + j + szInit(2)*(i-1), 1 ) = imInitCopy( i, j ); % imRulesCopy( szRulesOnly(1) + j + szInit(2)*(i-1), 2 ) = imInitCopy( i, j ); % imRulesCopy( szRulesOnly(1) + j + szInit(2)*(i-1), 3 ) = imInitCopy( i, j ); % end % end % szRulesCopy = size( imRulesCopy ); % imRulesGray = double( 2*imRulesCopy(:,1) ) + 3*double( imRulesCopy(:,2) ) + 5*double( imRulesCopy(:,3) ); % for i = 1 : nSymbolsAndRules % % iLeastBright = -1; % nLeastBright = min(min(imRulesGray)); % iLeastBright = find( abs(imRulesGray - nLeastBright) < 4 ); % if iLeastBright(1) <= szRulesOnly(1) % % SymbolColor( i, 1 ) = imRules( iLeastBright(1) + 0 ); % SymbolColor( i, 2 ) = imRules( iLeastBright(1) + szRulesOnly(1) ); % SymbolColor( i, 3 ) = imRules( iLeastBright(1) + 2*szRulesOnly(1) ); % else % SymbolColor( i, 1 ) = imRulesCopy( iLeastBright(1) + 0 )*255*nSymbolsAndRules/(nClrsInRules*nClrsInRules); % SymbolColor( i, 2 ) = imRulesCopy( iLeastBright(1) + szRulesCopy(1) )*255*nSymbolsAndRules/(nClrsInRules*nClrsInRules); % SymbolColor( i, 3 ) = imRulesCopy( iLeastBright(1) + 2*szRulesCopy(1) )*255*nSymbolsAndRules/(nClrsInRules*nClrsInRules); % end % % imRulesGray( iLeastBright ) = 999; % end % % SymbolColor = SymbolColor*nClrsInRules/nSymbolsAndRules; % imRules = imRules*nClrsInRules/nSymbolsAndRules; % % ToDo: Check for more colors that nSymbolsAndRules % % szRules(2) = szRules(2)/nSymbolsAndRules; % % To Do: sanity check on size of input tile grid % % arrayRules = -1; % % Map colors to integer array rules, in the range [0 nSymbolsAndRules-1]. % for r = 1 : nSymbolsAndRules % for j = 1 : szRules(2) % for k = 1 : szRules(1) % % if imRules( 1:szRules(1), (i-1)*szRules(2) + 1 : i*szRules(2), : ) == SymbolColor( i, : ) % % arrayRules( 1:szRules(1), 1:szRules(2), i ) = imRules( 1:szRules(1), (i-1)*szRules(2) + 1 : i*szRules(2) ); % for i = 1 : nSymbolsAndRules % if ( imRules( k, j + (r-1)*szRules(2), 1 ) == SymbolColor(i,1) & imRules( k, j + (r-1)*szRules(2), 2 ) == SymbolColor(i,2) & imRules( k, j + (r-1)*szRules(2), 3 ) == SymbolColor(i,3) ) % arrayRules( k, j, r ) = i - 1; % end % end % end % end % end % % % arrayRules % % if length( strMotifFilename ) == 0 % % for i = 1:nSymbolsAndRules % imMotifs( 1:1, i, 1 ) = SymbolColor( i, 1 ); % imMotifs( 1:1, i, 2 ) = SymbolColor( i, 2 ); % imMotifs( 1:1, i, 3 ) = SymbolColor( i, 3 ); % end % end % szMotifs = size( imMotifs ); % % % for i = 1 : nSymbolsAndRules % % arrayRules( find( arrayRules == SymbolColor( i ) ) ) = 9999 + i - 1; % % end % % arrayRules = arrayRules - 9999; else % To Do: Sanity check that the number of rule planes is evenly % divisible by the number of symbols/rules. nPlanesPerRule = (nargin - 7)/nSymbolsAndRules; szRules = size(varargin{1}); szRules(3) = nPlanesPerRule; arrayRules( 1:szRules(1), 1:szRules(2), 1:nPlanesPerRule, 1:nSymbolsAndRules ) = 9999; % Load explicit rules from arguements: % for i = 1 : nargin - 7 k = 0; for i = 1 : nSymbolsAndRules for j = 1 : nPlanesPerRule k = k + 1; arrayRules( 1:szRules(1), 1:szRules(2), j, i ) = double( varargin{ k } ); end end for i = 1 : nSymbolsAndRules SymbolColor( i, 1:3 ) = i; end end % Extract rule codes: for i = 1 : nSymbolsAndRules nCodes(i) = 0; iDigit = 0; for k = szRules(1):-1:1 for l = szRules(2):-1:1 for j = nPlanesPerRule:-1:1 nCodes(i) = nCodes(i) + arrayRules( k, l, j, i )*nSymbolsAndRules^iDigit; iDigit = iDigit + 1; end end end end % Construct output's filestem: strMotifnamePostfix = ''; if strMotifFilename ~= '' strMotifnamePostfix = [ strMotifFilename '-' ]; end if length( strOutFilestemOpt ) == 0 % If no output filename is given, construct one from other input parameters. strOutFilestem = [ 'LS-' num2str(szRules(2)) 'x' num2str(szRules(1)) 'x' num2str(nPlanesPerRule) '_' num2str(nSymbolsAndRules) 's-' strMotifnamePostfix(1:length(strMotifFilename)-4) ]; else strOutFilestem = [ strOutFilestemOpt '-' num2str(szRules(2)) 'x' num2str(szRules(1)) 'x' num2str(nPlanesPerRule) '_' num2str(nSymbolsAndRules) 's-' strMotifnamePostfix(1:length(strMotifFilename)-4) ]; end if nSymbolsAndRules <= 7 for i = 1:nSymbolsAndRules if i == 1 strOutFilestem = [ strOutFilestem num2str( nCodes(i) ) ]; else strOutFilestem = [ strOutFilestem '_' num2str( nCodes(i) ) ]; end end end szInit = size( arrayInit ); if length( arrayInit ) == 1 szTiling = [ szRules(1)^nGenerations szRules(2)^nGenerations szRules(3)^nGenerations ]; else szTiling = [ szInit(1)*(szRules(1)^nGenerations) szInit(2)*(szRules(2)^nGenerations) szInit(3)*(szRules(3)^nGenerations)]; end if bShowResult fprintf( ['\n'] ); end % Read or initialize motifs. if length( strMotifFilename ) ~= 0 % % Load any motif image into a 24 bit color array: % infMotif = imfinfo( strMotifFilename ); % if infMotif.ColorType == 'truecolor' % if infMotif.Height == 1 % imMotifs( 1, 1:infMotif.Width, 1:3 ) = imread( strMotifFilename ); % else % imMotifs = imread( strMotifFilename ); % end % else if infMotif.ColorType == 'grayscale' % % imMotifsGray = imread( strMotifFilename ); % szGrayMotifs = size( imMotifsGray ) % imMotifs( 1:szGrayMotifs(1), 1:szGrayMotifs(2), 1:3 ) = 0; % % imMotifs(:,:,1) = imMotifsGray; % imMotifs(:,:,2) = imMotifsGray; % imMotifs(:,:,3) = imMotifsGray; % % else if infMotif.ColorType == 'indexed' % fprintf( [ 'Indexed image format for the motifs is not currently supported.' ] ); % return; % end % end % end % % szMotifs = size( imMotifs ); % % To Do: sanity check on size of input tile grid % % if bShowResult % fprintf( [ 'Size of image: ' num2str( szTiling(1)*szMotifs(1) ) ' x ' num2str( szTiling(2)*szMotifs(1) ) ' px. \n' ] ); % fprintf( [ 'Memory required (final image): ' num2str( szTiling(1)*szTiling(2) * szMotifs(1)^2 *3/(2^20) ) ' MB \n' ] ); % end else if nargin ~= 8 nimPattern = 255*ones( szTiling(1), szTiling(2), 'uint8' ); szMotifs = [1,1]; if bShowResult fprintf( [ 'Size of volume: ' num2str( szTiling(1) ) ' x ' num2str( szTiling(2) ) ' x ' num2str( szTiling(3) ) ' vx. \n' ] ); fprintf( [ 'Memory required (final volume only): ' num2str( szTiling(1)*szTiling(2)*szTiling(2)/(2^20) ) ' MB \n' ] ); end end end imMotifs = double(imMotifs)/255; % Initialize output image. if length( strMotifFilename ) == 0 nimOut = 255*zeros( szTiling(1)*szMotifs(1), szTiling(2)*szMotifs(2), szTiling(2)*szMotifs(2), 'uint8' ); else nimOut = 255*zeros( szTiling(1)*szMotifs(1), szTiling(2)*szMotifs(2), szTiling(2)*szMotifs(2), 3, 'uint8' ); end % Construct scaled sequence of each generation: % if 1%strMotifFilename == 'animate' % % vctLS0 = arrayInit; % szLS = size(vctLS0); % vctLS( 1:szLS(1)*szRules(1), 1:szLS(2)*szRules(2), 1:szLS(2)*szRules(2) ) = 0; % % nByGenerations = floor( log10( nByGenWidthMax/(nByGenOversample*szInit(2)) )/log10( szRules(2) ) ); % % nBGSpacing = 6; % % 2*nBGSpacing + 1 + nByGenOversample*szRules(1)^nByGenerations % % ( nByGenerations + 1 )*nBGSpacing + 1 + nByGenerations*nByGenOversample*szRules(2)^nByGenerations % nimByGenerationGraphic( 1:2*nBGSpacing + 0 + nByGenOversample*szInit(1)*szRules(1)^nByGenerations, 1:( nByGenerations + 1 )*nBGSpacing + 0 + nByGenerations*nByGenOversample*szInit(1)*szRules(2)^nByGenerations, 1:3 ) = (10/13)*(nSymbolsAndRules-1); % % for ii = 1 : nByGenerations % % for j = 1 : szLS(1) % for k = 1 : szLS(2) % % vctLS( (j-1)*szRules(1) + 1 : j*szRules(1), (k-1)*szRules(2) + 1 : k*szRules(2) ) = arrayRules( 1:szRules(1), 1:szRules(2), vctLS0( j, k ) + 1 ); % % end % end % % vctLS0 = vctLS; % szLS = size(vctLS0); % % % Black border/background % nimByGenerationGraphic( nBGSpacing : nBGSpacing + nByGenOversample*szInit(1)*( szRules(1)^nByGenerations ) + 1, nBGSpacing + (ii-1)*nBGSpacing + nByGenOversample*szInit(2)*(ii - 1)*( szRules(2)^nByGenerations ) : nBGSpacing + nByGenOversample*szInit(2)*( szRules(2)^nByGenerations ) + (ii-1)*nBGSpacing + nByGenOversample*szInit(2)*(ii-1)*( szRules(2)^nByGenerations ) + 1, 1 ) = 0; % nimByGenerationGraphic( nBGSpacing : nBGSpacing + nByGenOversample*szInit(1)*( szRules(1)^nByGenerations ) + 1, nBGSpacing + (ii-1)*nBGSpacing + nByGenOversample*szInit(2)*(ii - 1)*( szRules(2)^nByGenerations ) : nBGSpacing + nByGenOversample*szInit(2)*( szRules(2)^nByGenerations ) + (ii-1)*nBGSpacing + nByGenOversample*szInit(2)*(ii-1)*( szRules(2)^nByGenerations ) + 1, 2 ) = 0; % nimByGenerationGraphic( nBGSpacing : nBGSpacing + nByGenOversample*szInit(1)*( szRules(1)^nByGenerations ) + 1, nBGSpacing + (ii-1)*nBGSpacing + nByGenOversample*szInit(2)*(ii - 1)*( szRules(2)^nByGenerations ) : nBGSpacing + nByGenOversample*szInit(2)*( szRules(2)^nByGenerations ) + (ii-1)*nBGSpacing + nByGenOversample*szInit(2)*(ii-1)*( szRules(2)^nByGenerations ) + 1, 3 ) = 0; % % % Upsample each generation to match the size of the last generation. % nUpsampleX = nByGenOversample*szRules(2)^( nByGenerations - ii ); % nUpsampleY = nByGenOversample*szRules(1)^( nByGenerations - ii ); % for i = 1 : szLS(1) % for j = 1 : szLS(2) % for k = 1 : nUpsampleY % for l = 1 : nUpsampleX % nimByGenerationGraphic( nBGSpacing + 0 + nUpsampleY*(i-1)+ k, nBGSpacing + 0 + nUpsampleX*(j-1) + l + (ii-1)*nBGSpacing + nByGenOversample*szInit(2)*(ii-1)*( szRules(2)^nByGenerations ), 1 ) = vctLS( i, j ); % nimByGenerationGraphic( nBGSpacing + 0 + nUpsampleY*(i-1)+ k, nBGSpacing + 0 + nUpsampleX*(j-1) + l + (ii-1)*nBGSpacing + nByGenOversample*szInit(2)*(ii-1)*( szRules(2)^nByGenerations ), 2 ) = vctLS( i, j ); % nimByGenerationGraphic( nBGSpacing + 0 + nUpsampleY*(i-1)+ k, nBGSpacing + 0 + nUpsampleX*(j-1) + l + (ii-1)*nBGSpacing + nByGenOversample*szInit(2)*(ii-1)*( szRules(2)^nByGenerations ), 3 ) = vctLS( i, j ); % end % end % end % end % % end % % nimByGenerationGraphic = nimByGenerationGraphic/max(max(max(nimByGenerationGraphic))); % % nimByGenerationGraphic(:,:,2) = nimByGenerationGraphic; % % nimByGenerationGraphic(:,:,3) = nimByGenerationGraphic(:,:,1); % if bShowResult % % figure; % imshow( nimByGenerationGraphic ); % end % % szBG = size( nimByGenerationGraphic ); % imByGenerationAlpha( 1:szBG(1), 1:szBG(2) ) = 1; % imByGenerationAlpha( find( nimByGenerationGraphic(:,:,1) == nimByGenerationGraphic(1,1) & nimByGenerationGraphic(:,:,2) == nimByGenerationGraphic(1,1) & nimByGenerationGraphic(:,:,3) == nimByGenerationGraphic(1,1) ) ) = 0; % end % % clear vctLS0; % clear vctLS; % Construct 3D sequence: vctLS0 = arrayInit; szLS = size(vctLS0); if length( arrayInit ) == 1 vctLS( 1:szRules(1), 1:szRules(2), 1:szRules(3) ) = 0; else vctLS( 1:szLS(1)*szRules(1), 1:szLS(2)*szRules(2), 1:szLS(3)*szRules(3) ) = 0; end for i = 1 : nGenerations if szLS(1) == 1 vctLS( 1:szRules(1), 1:szRules(2), 1:szRules(3) ) = arrayRules( 1:szRules(1), 1:szRules(2), 1:szRules(3), vctLS0( 1 ) + 1 ); else for j = 1 : szLS(1) for k = 1 : szLS(2) for l = 1 : szLS(3) vctLS( (j-1)*szRules(1)+1:j*szRules(1), (k-1)*szRules(2)+1:k*szRules(2), (l-1)*szRules(3)+1:l*szRules(3) ) = arrayRules( 1:szRules(1), 1:szRules(2), 1:szRules(3), vctLS0( j, k, l ) + 1 ); end end end end vctLS0 = vctLS; szLS = size(vctLS0); end szLS0 = size(vctLS0); % szLS = size(vctLS0); % vctLSD = zeros(szLS); % if nDecimate > 1 % % % jj = 0; % for j = 1 : szLS(1) % if mod( j, nDecimate ) == 1 % jj = jj + 1; % kk = 0; % for k = 1 : szLS(2) % % if mod( k, nDecimate ) == 1 % % kk = kk + 1; % vctLSD( jj, kk ) = vctLS0( j, k ); % end % end % end % end % % vctLS0 = vctLSD; % end if bCreateHistogram vct1D = reshape( vctLS0, 1, [] ); % length(find(vct1D == 0)) hFig = figure; hist( vct1D + .5, nGenerations + 1 ); % N = ( histc( vct1D, -.5 : 1 : nGenerations + .5 ) ) % bar( -.5 : 1 : nGenerations + .5, N, 'histc' ) saveas( hFig,[ strOutFilestem '_hist.png' ] ) end % vctLS0 = vctLS0; if max(max(max(vctLS0))) > 0 nimOut = vctLS0/max(max(max(vctLS0))); end clear vctLS; % if length( strMotifFilename ) > 0 | nargin == 8 % % % Replace sybolic values with corresponding motifs. % for i = 1 : szTiling(1) % for j = 1 : szTiling(2) % % nimOut( 1 + (i-1)*szMotifs(1):i*szMotifs(1), 1 + (j-1)*szMotifs(1):j*szMotifs(1), 1:3 )... % = imMotifs( 1 : szMotifs(1), 1 + ( vctLS0( i, j ) - 0)*szMotifs(2)/nSymbolsAndRules : ( vctLS0( i, j ) + 1 )*szMotifs(2)/nSymbolsAndRules, 1:3 ); % end % end % % clear vctLS0; % % nimOut = nimOut/max(max(max(nimOut))); % end % nimOutTemp = nimOut; % nUpsample = 3; % for i = 1 : szTiling(1) % for j = 1 : szTiling(2) % for k = 1 : nUpsample % for l = 1 : nUpsample % nimOut( nUpsample*(i-1)+k+1, nUpsample*(j-1)+l+1 ) = nimOutTemp( i, j ); % end % end % end % end % if nDecimate > 1 % % nimOutTemp1 = downsample( nimOut, nDecimate, nOffset ); % nimOutTemp1 = nimOutTemp1'; % nimOutTemp1 = downsample( nimOutTemp1, nDecimate, nOffset ); % clear nimOut; % nimOut = nimOutTemp1'; % % % nimOutTemp1(:,:) = downsample( nimOut(:,:,1), nDecimate, nOffset ); % % nimOutTemp2(:,:) = downsample( nimOut(:,:,2), nDecimate, nOffset ); % % nimOutTemp3(:,:) = downsample( nimOut(:,:,3), nDecimate, nOffset ); % % nimOutTemp1 = nimOutTemp1'; % % nimOutTemp2 = nimOutTemp2'; % % nimOutTemp3 = nimOutTemp3'; % % nimOutTemp1 = downsample( nimOutTemp1, nDecimate, nOffset ); % % nimOutTemp2 = downsample( nimOutTemp2, nDecimate, nOffset ); % % nimOutTemp3 = downsample( nimOutTemp3, nDecimate, nOffset ); % % clear nimOut; % % nimOut(:,:,1) = nimOutTemp1'; % % nimOut(:,:,2) = nimOutTemp2'; % % nimOut(:,:,3) = nimOutTemp3'; % end % if bShowResult % % % Show tiling in a figure (only first plane if 3-D). % figure; % imshow( nimOut ); % end % Draw algorithm and rule graphical representation ("algorithm graphic"): nES = 16; % rule element size (even) nSS = 4; % spacing size (even) nB = 2; % element border size (even) % Read auxilliary graphic icons (arrows, bars, identity, etc.). imRuleGraphic1 = imread( 'LS_rule_graphic_1.png' ); szRulesGraphic1 = size( imRuleGraphic1 ); imRuleGraphic2 = imread( 'LS_rule_graphic_2.png' ); szRulesGraphic2 = size( imRuleGraphic2 ); imRuleGraphic3 = imread( 'LS_rule_graphic_3.png' ); szRulesGraphic3 = size( imRuleGraphic3 ); szInit = size( arrayInit ); imAlgorithmGraphic = 0; % Draw background color onto full image size. xRight = 3*nSymbolsAndRules*nB + 3*nB + nSS*( 2 + nSymbolsAndRules ) + nES*( szInit(2) + nSymbolsAndRules*szRules(2) ) + nB*( 3 + szInit(2) + (nSymbolsAndRules-1)*( 1 + szRules(2) ) ) + szRules(2) + szRulesGraphic1(2); if length( strMotifFilename ) > 0 imAlgorithmGraphic( 1 : 3*nSS + 2*nES + 4*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB + 2, 1 : xRight, 1:3 ) = (10/13)*(nSymbolsAndRules-1); else imAlgorithmGraphic( 1 : (szRules(3)-1)*szRules(2)*nES + 2*nSS + nES + 2*nB + szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB, 1 : xRight, 1:3 ) = (10/13)*(nSymbolsAndRules-1); end % Draw initial symbol matrix. for j = 1:szInit(2) for k = 1:szInit(1) % Draw initial matrix backgrounds. imAlgorithmGraphic( 1 + nSS + nB + (k-1)*( nES + nB ) - nB : nSS + nB + (k-1)*( nES + nB ) + nES + nB, 1 + nSS + nB + (j-1)*( nES + nB ) - nB : nSS + nB + (j-1)*( nES + nB ) + nES + nB, 1:3 ) = (5/13)*(nSymbolsAndRules-1); % Draw initial matrix foregrounds. imAlgorithmGraphic( 1 + nSS + nB + (k-1)*( nES + nB ) : nSS + nB + (k-1)*( nES + nB ) + nES , 1 + nSS + nB + (j-1)*( nES + nB ) : nSS + nB + (j-1)*( nES + nB ) + nES , 1:3 ) = arrayInit(k,j); end end % Draw input symbol and output matrix (each rule). for i = 1:nSymbolsAndRules % Draw input rule background and then foreground. xLeft = 1 + 3*(i-1)*nB + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 + nB/2; xRight = xLeft + 2*nB + nES - 1; imAlgorithmGraphic( 1 + nSS : nSS + nES + 2*nB, xLeft : xRight, 1:3 ) = (5/13)*(nSymbolsAndRules-1); imAlgorithmGraphic( 1 + nSS + nB : nSS + nES + nB, xLeft + nB : xRight - nB, 1:3 ) = i - 1; for l = szRules(3):-1:1 for j = 1:szRules(2) for k = 1:szRules(1) % Draw output rule background then foreground. yTop = 1 + nSS + (l-1)*szRules(2)*nES + (nES + 2*nB) + szRulesGraphic2(1) + (k-1)*(nES + nB); yBot = nSS + (l-1)*szRules(2)*nES + (nES + 2*nB) + szRulesGraphic2(1) + k *(nES + nB) + nB; xLeft = 1 + 3*(i+l-2)*nB + nSS*( 1 + i ) + nES*( szInit(2) + (i-1)*szRules(2) + (j - 1) ) + nB*( 1 + szInit(2) + (i-1)*( 1 + szRules(2) ) + (j - 1) ) + szRulesGraphic1(2); xRight = xLeft + nES + 2*nB - 1; imAlgorithmGraphic( yTop : yBot, xLeft : xRight , 1:3 ) = (5/13)*(nSymbolsAndRules-1); imAlgorithmGraphic( yTop + nB : yBot - nB, xLeft + nB : xRight - nB, 1:3 ) = arrayRules(k,j,l,i); end end end end imAlgorithmGraphic = imAlgorithmGraphic/max(max(imAlgorithmGraphic(:,:,1))); % Insert line graphics: % Feedback: imRuleGraphic1 = double(imRuleGraphic1)/255; imRuleGraphic1( find( imRuleGraphic1 == imRuleGraphic1(1,1) ) ) = imAlgorithmGraphic(1,1); % Forward arrow. yTop = 1 + nSS + (nES + 2*nB)/2 - 9; yBot = yTop + 17; xLeft = 1 + nSS + nES*szInit(2) + nB*(szInit(2) + 1) + nSS/2; xRight = xLeft + szRulesGraphic1(2) - 1; imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 1 ) = imRuleGraphic1( 1:18, : ); imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 2 ) = imRuleGraphic1( 1:18, : ); imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 3 ) = imRuleGraphic1( 1:18, : ); % Return arrow. yTop = 1 + nSS + nES + 2*nB + szRulesGraphic2(1) + ( k*(nES + nB) + nB )/2 - 7; yBot = yTop + 14; xLeft = 1 + nSS + nES*szInit(2) + nB*(szInit(2) + 1) + nSS/2; xRight = xLeft + szRulesGraphic1(2) - 1; imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 1 ) = imRuleGraphic1( 19:33, : ); imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 2 ) = imRuleGraphic1( 19:33, : ); imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 3 ) = imRuleGraphic1( 19:33, : ); % Vertical bar. yTop = 1 + nSS + (nES + 2*nB)/2; yBot = yTop + szRulesGraphic2(1) + ( (k+1)*(nES + nB) + nB )/2; xLeft = 1 + nSS + nES*szInit(2) + nB*(szInit(2) + 1) + 16; xRight = xLeft + 1; imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 1 ) = 0; imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 2 ) = 0; imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 3 ) = 0; % Rule identity: imRuleGraphic2 = double(imRuleGraphic2)/255; imRuleGraphic2( find( imRuleGraphic2 == imRuleGraphic2(1,1) ) ) = imAlgorithmGraphic(1,1,1); yTop = 1 + nSS + 2*nB + nES; yBot = yTop + szRulesGraphic2(1) - 1; for i = 1:nSymbolsAndRules xLeft = 1 + 3*(i-1)*nB + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2); xRight = xLeft + nB + nES - 1; imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 1 ) = imRuleGraphic2; imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 2 ) = imRuleGraphic2; imAlgorithmGraphic( yTop : yBot, xLeft : xRight, 3 ) = imRuleGraphic2; end % if length( strMotifFilename ) > 0 % % % Draw motifs extension onto graphic. % imRuleGraphic3 = double(imRuleGraphic3)/255; % imRuleGraphic3( find( imRuleGraphic3 == imRuleGraphic3(1,1) ) ) = imAlgorithmGraphic(1,1,1); % for i = 1:nSymbolsAndRules % % % Motif identity signs: % imAlgorithmGraphic( 1 + 2*nSS + 2*nB + nES + szRulesGraphic3(1) + szRules(1)*(nES + nB) + nB : 2*nSS + 2*nB + nES + 2*szRulesGraphic3(1) + szRules(1)*(nES + nB) + nB, 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) : 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2), 1 ) = imRuleGraphic3; % imAlgorithmGraphic( 1 + 2*nSS + 2*nB + nES + szRulesGraphic3(1) + szRules(1)*(nES + nB) + nB : 2*nSS + 2*nB + nES + 2*szRulesGraphic3(1) + szRules(1)*(nES + nB) + nB, 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) : 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2), 2 ) = imRuleGraphic3; % imAlgorithmGraphic( 1 + 2*nSS + 2*nB + nES + szRulesGraphic3(1) + szRules(1)*(nES + nB) + nB : 2*nSS + 2*nB + nES + 2*szRulesGraphic3(1) + szRules(1)*(nES + nB) + nB, 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) : 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2), 3 ) = imRuleGraphic3; % % % ithMotif = imMotifs( 1 : szMotifs(1), 1 + (i-1)*szMotifs(2)/nSymbolsAndRules : i*szMotifs(2)/nSymbolsAndRules, : ); % % szIthMotifs = size( ithMotif(:,:,1) ); % % ndim = nES + 2*nB; % % dy = szIthMotifs(1)/ndim; % % dx = szIthMotifs(2)/ndim; % % yi = 1:dy:szIthMotifs(1); % % yi = yi'; % % xi = 1:dx:szIthMotifs(2); % % ithMotifSmall(:,:,1) = interp2( 0:szIthMotifs(1)-1, 0:szIthMotifs(2)-1, ithMotif(:,:,1), xi, yi, 'linear' ); % % ithMotifSmall(:,:,2) = interp2( 0:szIthMotifs(1)-1, 0:szIthMotifs(2)-1, ithMotif(:,:,2), xi, yi, 'linear' ); % % ithMotifSmall(:,:,3) = interp2( 0:szIthMotifs(1)-1, 0:szIthMotifs(2)-1, ithMotif(:,:,3), xi, yi, 'linear' ); % % size( ithMotifSmall ); % % % % 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1) *(nES + nB) + nB % % 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB % % 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 % % 2*nSS + nES*szInit(2) + nB*( szRules(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1 % % % Draw motifs. % % imAlgorithmGraphic( 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB : 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB, 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 : 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1, : ) = ithMotifSmall; % % % imAlgorithmGraphic( 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB : 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB, 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 : 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1, 2 ) = ithMotifSmall; % % imAlgorithmGraphic( 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB : 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB, 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 : 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1, 3 ) = ithMotifSmall; % % % Draw output motif background/border, black single pixel. % imAlgorithmGraphic( 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB : 2 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB, 0 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 : 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1, 1 ) = (5/13)*(nSymbolsAndRules-1)/nSymbolsAndRules; % imAlgorithmGraphic( 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB : 2 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB, 0 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 : 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1, 2 ) = (5/13)*(nSymbolsAndRules-1)/nSymbolsAndRules; % imAlgorithmGraphic( 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB : 2 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB, 0 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 : 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1, 3 ) = (5/13)*(nSymbolsAndRules-1)/nSymbolsAndRules; % % imAlgorithmGraphic( 2 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB : 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB, 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 : 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1, 1 ) = imMotifs( 1 : szMotifs(1), 1 + (i - 1)*szMotifs(2)/nSymbolsAndRules : i*szMotifs(2)/nSymbolsAndRules, 1 ); % imAlgorithmGraphic( 2 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB : 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB, 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 : 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1, 2 ) = imMotifs( 1 : szMotifs(1), 1 + (i - 1)*szMotifs(2)/nSymbolsAndRules : i*szMotifs(2)/nSymbolsAndRules, 2 ); % imAlgorithmGraphic( 2 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + szRules(1)*(nES + nB) + nB : 1 + 2*nSS + nES + 2*nB + 2*szRulesGraphic2(1) + (szRules(1) + 1)*(nES + nB) + 2*nB, 1 + 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)-1)*(nB + nES))/2 + nB/2 + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 2 : 2*nSS + nES*szInit(2) + nB*( szInit(2) + 1) + (( szRules(2)+1)*(nB + nES))/2 + nB + (i-1)*( nES*szRules(2) + nSS + nB*( szRules(2) + 1 ) ) + szRulesGraphic1(2) - 1, 3 ) = imMotifs( 1 : szMotifs(1), 1 + (i - 1)*szMotifs(2)/nSymbolsAndRules : i*szMotifs(2)/nSymbolsAndRules, 3 ); % % end % end szA = size( imAlgorithmGraphic ); imAlgorithmAlpha( 1:szA(1), 1:szA(2) ) = 1; imAlgorithmAlpha( find( imAlgorithmGraphic(:,:,1) == imAlgorithmGraphic(1,1) & imAlgorithmGraphic(:,:,2) == imAlgorithmGraphic(1,1) & imAlgorithmGraphic(:,:,3) == imAlgorithmGraphic(1,1) ) ) = 0; if bShowResult figure; imshow( imAlgorithmGraphic ); end % if bShowResult % figure; % imshow( imMotifs ); % end if bWriteResults if bShowResult fprintf( [ '\nWriting image file and graphics to the current directory, \n' ] ); fprintf( [ 'with the file stem: ' strOutFilestem '\n' ] ); end % imwrite( nimOut, [strOutFilestem '.png' ] ); write_Space_volume( nimOut, [ strOutFilestem '-' num2str( num2str(nGenerations) ) 'g' ] ); % % Write documentation graphics: if bWriteTilingOnly == 0 % imwrite( imAlgorithmGraphic, [ strOutFilestem '_algorithm_graphic.png' ], 'BitDepth', 16, 'Alpha', imAlgorithmAlpha ); % imwrite( nimByGenerationGraphic, [ strOutFilestem '_byGeneration_graphic.png' ], 'BitDepth', 16, 'Alpha', imByGenerationAlpha ); % % % Construct 1 px/symbol horizontal rule image, and save with a name % % related to the image and algorithm graphic. % clear imRules; % imRules( 1:szRules(1), 1:nSymbolsAndRules*szRules(2) ) = 0; % for i = 1:nSymbolsAndRules % for j = 1:szRules(2) % for k = 1:szRules(1) % imRules( k, j + (i-1)*szRules(2) ) = arrayRules(k,j,i); % end % end % end % % imRules = imRules/max(max(max(imRules))); % % imRules = imRules/255; % imwrite( imRules, [ strOutFilestem '_rules.png' ] ); % % % If a motif (or color mapping of rules) is provided, resave with a % % name related to the image and algorithm graphic. % if length( strMotifFilename ) > 0 | nargin == 8 % imwrite( imMotifs, [ strOutFilestem '_motifs.png' ] ); % end end % End write documentation graphics. end if bShowResult fprintf( ['\n'] ); end