A
download filterExplorer.pas
Language: Delphi
Copyright: (C) 2004 Durand Emmanuel (C) 2004 Burgel Eric
LOC: 136
Project Info
Filters
Server: SourceForge
Type: cvs
...ilters\Filters1\Src\Delphi\
   ...ractfilterNeighbor3.pas
   Chronometer.pas
   divers.pas
   filter.pas
   filterAdjust.pas
   filterArithmeticAdd.pas
   ...ithmeticConstantAdd.pas
   ...ArithmeticSubstract.pas
   filterBlobBalance.pas
   filterBlobExplorer.pas
   filterBlobGrouping.pas
   ...erBlobRepositioning.pas
   ...rBlobRepositioning2.pas
   filterBlur.pas
   filterCanny.pas
   filterContour.pas
   filterContrastExplorer.pas
   filterConvolution.pas
   filterCoocurenceMatrix.pas
   filterCopy.pas
   filterCorrelation.pas
   filterCutter.pas
   filterDistancesMap.pas
   filterExplorer.pas
   ...nisotropicDiffusion.pas
   ...GranularityExplorer.pas
   filterHistogram.pas
   ...erHistogramContrast.pas
   filterImageCreator.pas
   filterImageLoader.pas
   filterImageSaver.pas
   filterIntegration.pas
   filterInvert.pas
   filterLocalDeviation.pas
   filterLogPolar.pas
   filterMedian.pas
   filterMorphology.pas
   ...onMaximaSuppression.pas
   filterNormalize.pas
   filterOnOffCell.pas
   filterProjectionLine.pas
   filterPyramid.pas
   filterRescaleIntensity.pas
   filterResize.pas
   filterRotation.pas
   filterSigmoid.pas
   filterSmoothBilateral.pas
   filterSobel.pas
   filterSPV.pas
   filterStackProcessor.pas
   filterStackSmasher.pas
   ...erStandardDeviation.pas
   filterSUSAN.pas
   filterThresholdBinary.pas
   filterVectorHistogram.pas
   filterWavelets.pas
   filterWaves.pas
   fmask.pas
   fparameters.pas
   image.pas
   imageIO.pas
   imageIOVideo.pas
   lacModel.pas
   polygonalyzation.pas
   wrapper_itk.pas
   wrapper_opencv.pas

unit filterExplorer;
(* ***** BEGIN LICENSE BLOCK *****
 * Copyright (C) 2004 Durand Emmanuel
 * Copyright (C) 2004 Burgel Eric
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Contact :
 *   filters@edurand.com
 *   filters@burgel.com
 *
 * ***** END LICENSE BLOCK ***** *)

{
 edurand (filters@edurand.com)
}

interface
uses
  filter, fparameters, image;

type
  TFilterExplorer = class(TFilter)
  public
    constructor Create; override;
    destructor Destroy; override;
    procedure Run(); override;
  private
    parameterImageIn : TParameterImage;
    outputParameterImageOuts : TParameterImages;
    parameterX, parameterY : TParameterInteger;
    parameterPrecision : TParameterInteger;
    imgIn : PBitmap32 ;
    imageOuts : ArrayOfPBitmap32;
    procedure destroyImageOuts();
    procedure _run();
  end;

implementation
uses
  imageIO, Math, divers;

constructor TFilterExplorer.Create;
begin
  inherited;
  parameterImageIn := addParameterImage('inImage', 'input image to explore');
  outputParameterImageOuts := addOutputParameterImages('outImages','show pixels values on X and Y axis');
  parameterX := addParameterInteger('X','X',-maxint+1,maxint,0);
  parameterY := addParameterInteger('Y','Y',-maxint+1,maxint,0);
  parameterPrecision := addParameterInteger('precision','',1,15,1);
  SetLength( imageOuts, 2 );
end;

destructor TFilterExplorer.Destroy;
begin
  destroyImageOuts();
  inherited;
end;

procedure TFilterExplorer.destroyImageOuts();
var
  i : Integer;
begin
  for i:=Low(imageOuts) to High(imageOuts) do begin
    image.freeImage(imageOuts[i]);
  end;
end;

procedure TFilterExplorer.run();
var
  createImageOuts : boolean;
begin
  imgIn  := parameterImageIn.Image ;
  if (imgIn<>nil) then begin
    createImageOuts:=true;
    if (imageOuts[0]<>nil) and (imageOuts[1]<>nil) then begin
      if (imageOuts[0].Width=parameterImageIn.Image.Width) and
         (imageOuts[1].Width=parameterImageIn.Image.Height) then begin
         createImageOuts:=false;
      end;
    end;
    if createImageOuts=true then begin
      destroyImageOuts();
      imageOuts[0]:=createImage(parameterImageIn.Image.Width,256);
      imageOuts[1]:=createImage(parameterImageIn.Image.Height,256);
      setOutputParameterImages('outImages',imageOuts);
    end else begin
      eraseImage(imageOuts[0]);
      eraseImage(imageOuts[1]);
    end;
    _run();
  end;
end;

procedure TFilterExplorer._run();
var
  pSrc, PDest : PColor32Array;
  x, y, maxX, maxY : Integer ;
  imgOutX, imgOutY : PBitmap32 ;
  value, i, destY : Integer;
  c : TColor32;
  axisX, axisY : array of Single;
begin
  imgOutX := outputParameterImageOuts.Images[0];
  imgOutY := outputParameterImageOuts.Images[1];

  // get axis X
  maxX := scanWidth(imgIn)-1 ;
  SetLength( axisX, maxX+1 );
  pSrc := scanLine( imgIn, parameterY.Value );
  for x:=0 to maxX do begin
    value := Intensity(pSrc[0]);
    axisX[x] := value;
    Inc( pSrc );
  end;
  // smoot it
  divers.smoothIt( axisX, parameterPrecision.Value );
  // show it
  for x:=0 to maxX do begin
    value := Round( axisX[x] );
    if x=parameterX.Value then c:=clBlue32 else c:=clRed32;
    image.drawLine( imgOutX, x, 255-value, x, 255, c );
  end;

  // get axis Y
  maxY := scanHeight(imgIn)-1;
  SetLength( axisY, maxY+1 );
  for y:=0 to maxY do begin
    value := Intensity( getPixel(imgIn,parameterX.Value,y) );
    axisY[y] := value;
  end;
  // smoot it
  divers.smoothIt( axisY, parameterPrecision.Value );
  // show it
  for y:=0 to maxY do begin
    value := Round( axisY[y] );
    if y=parameterY.Value then c:=clBlue32 else c:=clRed32;
    image.drawLine( imgOutY, y, 255-value, y, 255, c );
  end;      

{  maxY := scanHeight(imgIn)-1 ;
  for y:=0 to maxY do begin
    value:=Intensity( getPixel(imgIn,parameterX.Value,y) );
    if y=parameterY.Value then c:=clBlue32 else c:=clRed32;
    for i:=255-value to 255 do begin
      setPixel(imgOutY,y,i,c);
    end;
  end;
}

  // show a short view of this pixel and its close neighbor
  maxX := scanWidth(imgIn)-1 ;
  maxY:=Min(scanHeight(imgIn)-1,parameterY.Value+5);
  destY:=0;
  for y:=Max(0,parameterY.Value-5) to maxY do begin
    pSrc:=scanLine(imgIn,y);
    pDest := scanLine(imgOutX,destY) ;
    for x:=0 to maxX do begin
      value:=Intensity(pSrc[0]);
      pDest^[0] := Gray32(value);
      inc(pDest) ;
      inc(pSrc) ;
    end;
    Inc(destY);
  end;

  // show a short view of this pixel and its close neighbor
  maxX:=Min(scanWidth(imgIn)-1,parameterX.Value+5);
  maxY := scanHeight(imgIn)-1 ;
  destY:=0;
  for x:=Max(0,parameterX.Value-5) to maxX do begin
    pDest := scanLine(imgOutY,destY) ;
    for y:=0 to maxY do begin
    value:=Intensity( getPixel(imgIn,x,y) );
      pDest^[0] := Gray32(value);
      inc(pDest) ;
    end;
    Inc(destY);
  end;

end;

end.

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us