Description of MapTrimmer

Home > BiKEGG > MapTrimmer.m

# MapTrimmer

## PURPOSE

MapTrimmer

## SYNOPSIS

function I = MapTrimmer(I,ArrowX,ArrowY,Cntrs,Allx4Arrow,Ally4Arrow,LineStrength,ColSpec)

## DESCRIPTION

     MapTrimmer
     is a subfunction of NetDraw for drawing removing extra pixels
     after attaching arrowheads to reaction ends.

     Inputs:
     I: An array containing the customized metabolic map.
     ArrowX,ArrowY,Cntrs: Outputs from ArrowheadProcess.
     Allx4Arrow,Ally4Arrow: All reactions' coordinates.
     LineStrength: Reaction width.
     ColSpec: Color code corresponding to that of the reactions.

     Output:
     I: Modified image without extra pixels.

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- NetDraw NetDraw
- NetPoster NetPoster

## SOURCE CODE

    0001 function I = MapTrimmer(I,ArrowX,ArrowY,Cntrs,Allx4Arrow,Ally4Arrow,LineStrength,ColSpec)
    0002 % MapTrimmer
    0003 % is a subfunction of NetDraw for drawing removing extra pixels
    0004 % after attaching arrowheads to reaction ends.
    0005 %
    0006 % Inputs:
    0007 % I: An array containing the customized metabolic map.
    0008 % ArrowX,ArrowY,Cntrs: Outputs from ArrowheadProcess.
    0009 % Allx4Arrow,Ally4Arrow: All reactions' coordinates.
    0010 % LineStrength: Reaction width.
    0011 % ColSpec: Color code corresponding to that of the reactions.
    0012 %
    0013 % Output:
    0014 % I: Modified image without extra pixels.
    0015
    0016 % O. Jamialahmadi
    0017 % TMU, Chem. Eng. Dept., Biotech. Group
    0018 % July 2016
    0019
    0020 for i1 = 1:numel(ArrowX)
    0021     if isempty(ArrowX{i1})
    0022         continue
    0023     end
    0024     Xin = ArrowX{i1}; Yin = ArrowY{i1}; Cents = Cntrs{i1};
    0025     pixx = Allx4Arrow{i1};
    0026     pixy = Ally4Arrow{i1};
    0027     if ~std(pixx)
    0028         pixx1 = pixx + LineStrength/2;
    0029         pixx = pixx - LineStrength/2;
    0030         pixy1 = pixy;
    0031     elseif ~std(pixy)
    0032         pixy1 = pixy + LineStrength/2;
    0033         pixy = pixy - LineStrength/2;
    0034         pixx1 = pixx;
    0035     else
    0036         pixx1 = pixx + LineStrength/2;
    0037         pixx = pixx - LineStrength/2;
    0038         pixy1 = pixy + LineStrength/2;
    0039         pixy = pixy - LineStrength/2;
    0040     end
    0041
    0042     for cnt = 1:size(Xin,1)
    0043         X = Xin(cnt,:); Y = Yin(cnt,:); Cent = Cents(cnt,:);
    0044         DistToCpd = hypot( Allx4Arrow{i1} - Cent(1), Ally4Arrow{i1} - Cent(2));
    0045         CpdDistToPoint1 = hypot( X(1) - Cent(1), Y(1) - Cent(2));
    0046 %         CpdDistToPoint2 = hypot( X(2) - Cent(1), Y(2) - Cent(2));
    0047         Ind = find(DistToCpd < 0.8*CpdDistToPoint1);% & DistToCpd>CpdDistToPoint2);
    0048         pixx1T = pixx1(Ind); pixxT = pixx(Ind);
    0049         pixy1T = pixy1(Ind); pixyT = pixy(Ind);
    0050         pixx1T = round(pixx1T); pixxT = round(pixxT);
    0051         pixy1T = round(pixy1T); pixyT = round(pixyT);
    0052         for i5 = 1:numel(pixxT)
    0053             I(pixyT(i5):pixy1T(i5),pixxT(i5),1) = ColSpec(1);
    0054             I(pixyT(i5),pixxT(i5):pixx1T(i5),1) = ColSpec(1);
    0055             I(pixyT(i5):pixy1T(i5),pixxT(i5),2) = ColSpec(2);
    0056             I(pixyT(i5),pixxT(i5):pixx1T(i5),2) = ColSpec(2);
    0057             I(pixyT(i5):pixy1T(i5),pixxT(i5),3) = ColSpec(3);
    0058             I(pixyT(i5),pixxT(i5):pixx1T(i5),3) = ColSpec(3);
    0059         end
    0060     end
    0061 end