⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 livertexturerec.~pas

📁 数字图像预出处理系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
unit LiverTextureRec;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,datamodule,
  Dialogs, ExtCtrls,CHILDWIN, StdCtrls, ComCtrls, ToolWin, Menus, ImgList,
  Clipbrd,GrayCurrenceMatrix;
var
  pattern:array [0..2] of LiverPattern;
  F:double=0.0;
type
  TLiverTextureRecForm = class(TForm)
    LiverPartImage: TImage;
    Panel1: TPanel;
    GroupBox1: TGroupBox;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    ToolBar1: TToolBar;
    OpenToolButton: TToolButton;
    RadioGroup1: TRadioGroup;
    HealthLiverRadioButton: TRadioButton;
    FattyLiverRadioButton: TRadioButton;
    CirrhosisRadioButton: TRadioButton;
    R1: TMenuItem;
    H1: TMenuItem;
    SaveAllToolButton: TToolButton;
    ImageList1: TImageList;
    SaveNowToolButton: TToolButton;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    EnergyEdit: TEdit;
    EntropyEdit: TEdit;
    CorrelationEdit: TEdit;
    RecognizeToolButton: TToolButton;
    GroupBox3: TGroupBox;
    ComputeButton: TButton;
    GroupBox4: TGroupBox;
    Label4: TLabel;
    LiverKindEdit: TEdit;
    Label5: TLabel;
    LiverKindIDEdit: TEdit;
    SaveCurrentlyPatternButton: TButton;
    SaveAllPatternButton: TButton;
    PatternOrderButton: TButton;
    GroupBox5: TGroupBox;
    Label6: TLabel;
    RecLiverKindEdit: TEdit;
    SaveDialog1: TSaveDialog;
    SdudyToolButton: TToolButton;
    PopupMenu1: TPopupMenu;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    R2: TMenuItem;
    S1: TMenuItem;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    OpenDialog1: TOpenDialog;
    TempPartImage: TImage;
    InertiaQuadratureEdit: TEdit;
    LocalCalmEdit: TEdit;
    Label8: TLabel;
    Label9: TLabel;
    MouseUpTimer: TTimer;
    TimeEdit: TEdit;
    Label7: TLabel;
    Label10: TLabel;
    EnergyVEdit: TEdit;
    EntropyVEdit: TEdit;
    CorrelationVEdit: TEdit;
    InertiaQuadratureVEdit: TEdit;
    LocalCalmVEdit: TEdit;
    EnergyRDEdit: TEdit;
    EntropyRDEdit: TEdit;
    CorrelationRDEdit: TEdit;
    InertiaQuadratureRDEdit: TEdit;
    EntropyLDEdit: TEdit;
    CorrelationLDEdit: TEdit;
    InertiaQuadratureLDEdit: TEdit;
    LocalCalmLDEdit: TEdit;
    LocalCalmRDEdit: TEdit;
    EnergyLDEdit: TEdit;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    LMSEButton: TToolButton;
    ResultLabel: TLabel;
    N5: TMenuItem;
    LMSE1: TMenuItem;
    RecLiverKindIdEdit: TEdit;
    Label14: TLabel;
    procedure FormShow(Sender: TObject);
    procedure RecognizeToolButtonClick(Sender: TObject);
    procedure MouseUpTimerTimer(Sender: TObject);
    procedure ComputeButtonClick(Sender: TObject);
    procedure LiverKindEditChange(Sender: TObject);
    procedure SaveAllPatternButtonClick(Sender: TObject);
    procedure SaveCurrentlyPatternButtonClick(Sender: TObject);
    procedure SaveNowToolButtonClick(Sender: TObject);
    procedure SaveAllToolButtonClick(Sender: TObject);
    procedure SdudyToolButtonClick(Sender: TObject);
    procedure PatternOrderButtonClick(Sender: TObject);
    //procedure GetLiverPartImage();
    procedure R2Click(Sender: TObject);
    procedure S1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure LMSEButtonClick(Sender: TObject);
    procedure N5Click(Sender: TObject);
    procedure LMSE1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
    function Get_Most_LRTB: TRect;
    procedure GetLiverPartImage();
  end;

var
  LiverTextureRecForm: TLiverTextureRecForm;
  RecognizeStudyvariable:Boolean;
  BP_LMSRecognize:Boolean;
  ImageArray:array of array of byte;
  pathstring:string;

implementation

{$R *.dfm}
uses QReport;

procedure TLiverTextureRecForm.FormShow(Sender: TObject);
begin
  //Self.TempPartImage.Picture.LoadFromFile('./ade.bmp');
  //GetLiverPartImage();
  //Self.LiverPartImage.Picture.LoadFromFile('./ade1.bmp');
 // GrayCurrenceMatrix.OpenPatternFile();
 // GrayCurrenceMatrix.ClusterCenterCompare();
end;

procedure TLiverTextureRecForm.RecognizeToolButtonClick(Sender: TObject);
begin
  RecognizeStudyvariable:=true;
  BP_LMSRecognize:=false;
  SdudyToolButton.Down:=false;
  LMSEButton.Down:=false;
end;

procedure TLiverTextureRecForm.MouseUpTimerTimer(Sender: TObject);
//var
//Bitmap: TBitmap;
begin
{  if mark5=true then
   begin
    if Clipboard.HasFormat(CF_BITMAP) then
      begin
        Bitmap := TBitmap.Create;
      try
        Bitmap.Assign(Clipboard);
        TempPartImage.Canvas.Draw(0, 0, Bitmap);
      finally
        Bitmap.Free;
     end;
  end;
  //Self.TempPartImage.Picture.LoadFromFile('./ade.bmp');
  //TempPartImage.Picture.LoadFromClipboardFormat(CF_BITMAP,ClipBoard.GetAsHandle(CF_BITMAP),0);
  GetLiverPartImage();
  Self.LiverPartImage.Picture.LoadFromFile('./ade1.bmp');
   end; }
end;

procedure TLiverTextureRecForm.ComputeButtonClick(Sender: TObject);
var
Feature_Energy,Feature_Entropy,Feature_Correlation:double;
Feature_InertiaQuadrature,Feature_LocalCalm:double;
F_EnergyV,F_EntropyV,F_CorrelationV:double;
F_InertiaQuaV,F_LocalCalmV:double;
F_EnergyRD,F_EntropyRD,F_CorrelationRD:double;
F_InertiaQuaRD,F_LocalCalmRD:double;
F_EnergyLD,F_EntropyLD,F_CorrelationLD:double;
F_InertiaQuaLD,F_LocalCalmLD:double;
arLocalImage:TMyImage;//array [0..FilterWindowsWidth-1,0..FilterWindowsWidth-1] of byte;//vc离定义的是char
RollTimeH,RollTimeW:integer;
i,j,p,q:integer;
ts,te:Cardinal;
a1,a2,a3,a4,a5:double;
//ImageArray:array  of array  of byte;
//a:array [0..3] of TMatrix;
begin
  setlength(arLocalImage,FilterWindowsWidth,FilterWindowsWidth);
  setlength(ImageArray,LiverPartImage.Height,LiverPartImage.Width);
  a1:=0.46; a2:=0.46;a3:=0.08;//a4:=;a5:=;
  FeatureEnergy:=0.0;  FeatureEntropy:=0.0;  FeatureCorrelation:=0.0;
  FeatureInertiaQuadrature:=0.0;FeatureLocalCalm:=0.0;
  FEnergyV:=0.0;FEntropyV:=0.0;FCorrelationV:=0.0;FInertiaQuaV:=0.0;FLocalCalmV:=0.0;
  FEnergyRD:=0.0;FEntropyRD:=0.0;FCorrelationRD:=0.0;FInertiaQuaRD:=0.0;FLocalCalmRD:=0.0;
  FEnergyLD:=0.0;FEntropyLD:=0.0;FCorrelationLD:=0.0;FInertiaQuaLD:=0.0;FLocalCalmLD:=0.0;
  Feature_Energy:=0.0;  Feature_Entropy:=0.0;  Feature_Correlation:=0.0;
  Feature_LocalCalm:=0.0;Feature_InertiaQuadrature:=0.0;
  F_EnergyV:=0.0;F_EntropyV:=0.0;F_CorrelationV:=0.0;F_InertiaQuaV:=0.0;F_LocalCalmV:=0.0;
  F_EnergyRD:=0.0;F_EntropyRD:=0.0;F_CorrelationRD:=0.0;F_InertiaQuaRD:=0.0;F_LocalCalmRD:=0.0;
  F_EnergyLD:=0.0;F_EntropyLD:=0.0;F_CorrelationLD:=0.0;F_InertiaQuaLD:=0.0;F_LocalCalmLD:=0.0;
  ts:=gettickcount;
  RollTimeH:=LiverPartImage.Height div FilterWindowsWidth;//FilterWindowsWidth应该是属于类的
  RollTimeW:=LiverPartImage.Width div FilterWindowsWidth;
  for i:=0 to LiverPartImage.Height-1 do
    for j:=0 to LiverPartImage.Width-1 do
      ImageArray[i][j]:= LiverPartImage.Canvas.Pixels[i,j];
  for i:=0 to RollTimeH-1 do
    for j:=0 to RollTimeW-1 do
    begin
      for p:=0 to FilterWindowsWidth-1 do
        for q:=0 to FilterWindowsWidth-1 do
          arLocalImage[p][q]:= ImageArray[i*FilterWindowsWidth+p][j*FilterWindowsWidth+q];
      GrayCurrenceMatrix.ComputeCorrelationMatrix(arLocalImage,FilterWindowsWidth);
      CurrenceMatrixH:=resultH;
      CurrenceMatrixV:=resultV;
      CurrenceMatrixRD:=resultRD;
      CurrenceMatrixLD:=resultLD;
      //0度共现矩阵
      GrayCurrenceMatrix.ComputeTextureFeature(Feature_Energy,Feature_Entropy,
      Feature_Correlation,Feature_InertiaQuadrature,Feature_LocalCalm,CurrenceMatrixH,GrayLayerNum);
      Feature_Energy:=resultEnergy;
      Feature_Entropy:=resultEntropy;
      Feature_Correlation:=resultCorrelation;
      Feature_InertiaQuadrature:=resultInertiaQuadrature;
      Feature_LocalCalm:=resultLocalCalm;
      FeatureEnergy:=Feature_Energy+FeatureEnergy;
      FeatureEntropy:=Feature_Entropy+FeatureEntropy;
      FeatureCorrelation:=Feature_Correlation+FeatureCorrelation;
      FeatureInertiaQuadrature:=Feature_InertiaQuadrature+FeatureInertiaQuadrature;
      FeatureLocalCalm:=Feature_LocalCalm+FeatureLocalCalm;
      //90度共现矩阵
      GrayCurrenceMatrix.ComputeTextureFeature(Feature_Energy,Feature_Entropy,
      Feature_Correlation,Feature_InertiaQuadrature,Feature_LocalCalm,CurrenceMatrixV,GrayLayerNum);
      F_EnergyV:=resultEnergy;
      F_EntropyV:=resultEntropy;
      F_CorrelationV:=resultCorrelation;
      F_InertiaQuaV:=resultInertiaQuadrature;
      F_LocalCalmV:=resultLocalCalm;
      FEnergyV:=F_EnergyV+FEnergyV;
      FEntropyV:=F_EntropyV+FEntropyV;
      FCorrelationV:=F_CorrelationV+FCorrelationV;
      FInertiaQuaV:=F_InertiaQuaV+FInertiaQuaV;
      FLocalCalmV:=F_LocalCalmV+FLocalCalmV;
      //45度共现矩阵
      GrayCurrenceMatrix.ComputeTextureFeature(Feature_Energy,Feature_Entropy,
      Feature_Correlation,Feature_InertiaQuadrature,Feature_LocalCalm,CurrenceMatrixRD,GrayLayerNum);
      F_EnergyRD:=resultEnergy;
      F_EntropyRD:=resultEntropy;
      F_CorrelationRD:=resultCorrelation;
      F_InertiaQuaRD:=resultInertiaQuadrature;
      F_LocalCalmRD:=resultLocalCalm;
      FEnergyRD:=F_EnergyRD+FEnergyRD;
      FEntropyRD:=F_EntropyRD+FEntropyRD;
      FCorrelationRD:=F_CorrelationRD+FCorrelationRD;
      FInertiaQuaRD:=F_InertiaQuaRD+FInertiaQuaRD;
      FLocalCalmRD:=F_LocalCalmRD+FLocalCalmRD;
      //135度共现矩阵
      GrayCurrenceMatrix.ComputeTextureFeature(Feature_Energy,Feature_Entropy,
      Feature_Correlation,Feature_InertiaQuadrature,Feature_LocalCalm,CurrenceMatrixLD,GrayLayerNum);
      F_EnergyLD:=resultEnergy;
      F_EntropyLD:=resultEntropy;
      F_CorrelationLD:=resultCorrelation;
      F_InertiaQuaLD:=resultInertiaQuadrature;
      F_LocalCalmLD:=resultLocalCalm;
      FEnergyLD:=F_EnergyLD+FEnergyLD;
      FEntropyLD:=F_EntropyLD+FEntropyLD;
      FCorrelationLD:=F_CorrelationLD+FCorrelationLD;
      FInertiaQuaLD:=F_InertiaQuaLD+FInertiaQuaLD;
      FLocalCalmLD:=F_LocalCalmLD+FLocalCalmLD;
    end;
  FeatureEnergy:=FeatureEnergy /(RollTimeH*RollTimeW);
  FeatureEnergy:=strtofloat(format('%.5f',[FeatureEnergy]));
  FeatureEntropy:=FeatureEntropy/(RollTimeH*RollTimeW);
  FeatureEntropy:=strtofloat(format('%.5f',[FeatureEntropy]));
  FeatureCorrelation:=FeatureCorrelation/(RollTimeH*RollTimeW);
  FeatureCorrelation:=strtofloat(format('%.5f',[FeatureCorrelation]));
  FeatureInertiaQuadrature:=FeatureInertiaQuadrature/(RollTimeH*RollTimeW);
  FeatureInertiaQuadrature:=strtofloat(format('%.5f',[FeatureInertiaQuadrature]));
  FeatureLocalCalm:=FeatureLocalCalm/(RollTimeH*RollTimeW);
  FeatureLocalCalm:=strtofloat(format('%.5f',[FeatureLocalCalm]));
  //90度方向纹理特征
  FEnergyV:=FEnergyV /(RollTimeH*RollTimeW);
  FEnergyV:=strtofloat(format('%.5f',[FEnergyV]));
  FEntropyV:=FEntropyV/(RollTimeH*RollTimeW);
  FEntropyV:=strtofloat(format('%.5f',[FEntropyV]));
  FCorrelationV:=FCorrelationV/(RollTimeH*RollTimeW);
  FCorrelationV:=strtofloat(format('%.5f',[FCorrelationV]));
  FInertiaQuaV:=FInertiaQuaV/(RollTimeH*RollTimeW);
  FInertiaQuaV:=strtofloat(format('%.5f',[FInertiaQuaV]));
  FLocalCalmV:=FLocalCalmV/(RollTimeH*RollTimeW);
  FLocalCalmV:=strtofloat(format('%.5f',[FLocalCalmV]));
  //45度方向纹理特征
  FEnergyRD:=FEnergyRD /(RollTimeH*RollTimeW);
  FEnergyRD:=strtofloat(format('%.5f',[FEnergyRD]));
  FEntropyRD:=FEntropyRD/(RollTimeH*RollTimeW);
  FEntropyRD:=strtofloat(format('%.5f',[FEntropyRD]));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -