Documente Academic
Documente Profesional
Documente Cultură
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, ExtDlgs, Menus, StdCtrls,
ComCtrls, Clipbrd, ExtCtrls, Spin;
type
TFormUtama = class(TForm)
PanelAtas: TPanel;
ButtonAmbilCitra: TButton;
StatusBar: TStatusBar;
OpenPictureDialog: TOpenPictureDialog;
ButtonAmbilCitra2: TButton;
ButtonDeteksiGerak: TButton;
SpinEditC: TSpinEdit;
Label1: TLabel;
procedure ButtonAmbilCitraClick(Sender: TObject);
procedure ButtonAmbilCitra2Click(Sender: TObject);
procedure Olah;
procedure ButtonDeteksiGerakClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FormUtama: TFormUtama;
implementation
uses UnitCitra;
var
FormCitra2, FormHasil: TFormCitra;
{$R *.dfm}
procedure TFormUtama.Olah;
var
i, j, C, temp: integer;
PC, PC2, PH: PByteArray;
begin
C := SpinEditC.Value;
if (FormCitra.Image.Picture.Bitmap.PixelFormat = pf8bit)
then
begin
for i:= 0 to FormCitra.Image.Picture.Height-1 do
begin
PC := FormCitra.Image.Picture.BitMap.ScanLine[i];
PC2 := FormCitra2.Image.Picture.BitMap.ScanLine[i];
PH := FormHasil.Image.Picture.BitMap.ScanLine[i];
for j:= 0 to FormCitra.Image.Picture.Width-1 do
begin
temp := C+PC[j]-PC2[j];
if (temp < 0) then
temp := 0;
if (temp > 255) then
temp := 255;
PH[j] := temp;
end;
end;
end;
if (FormCitra.Image.Picture.Bitmap.PixelFormat = pf24bit)
then
begin
for i:= 0 to FormCitra.Image.Picture.Height-1 do
begin
PC := FormCitra.Image.Picture.BitMap.ScanLine[i];
PC2 := FormCitra2.Image.Picture.BitMap.ScanLine[i];
PH := FormHasil.Image.Picture.BitMap.ScanLine[i];
for j:= 0 to FormCitra.Image.Picture.Width-1 do
begin
temp := C+PC[3*j]-PC2[3*j];
if (temp < 0) then
temp := 0;
if (temp > 255) then
temp := 255;
PH[3*j] := temp;
temp := C+PC[3*j+1]-PC2[3*j+1];
if (temp < 0) then
temp := 0;
if (temp > 255) then
temp := 255;
PH[3*j+1] := temp;
temp := C+PC[3*j+2]-PC2[3*j+2];
if (temp < 0) then
temp := 0;
if (temp > 255) then
temp := 255;
PH[3*j+2] := temp;
end
end;
end;
end;
end.