درود به همه
امروز می خوام یه نمونه با حال برای تشخیص پلاک خودرو(فعلاً تعیین ناحیه شماره پلاک) براتون بذارم.
ابتدا
uses math;
بعد
procedure RGBtoHSL(R, G, B: Integer; var H, S, L: Integer);
var
  Delta: Double;
  CMax, CMin: Double;
  Red, Green, Blue, Hue, Sat, Lum: Double;
begin
  Red := R / 255;
  Green := G / 255;
  Blue := B / 255;
  CMax := Max(Red, Max(Green, Blue));
  CMin := Min(Red, Min(Green, Blue));
  Lum := (CMax + CMin) / 2;
  if CMax = CMin then
  begin
    Sat := 0;
    Hue := 0;
  end
  else
  begin
    if Lum < 0.5 then
      Sat := (CMax - CMin) / (CMax + CMin)
    else if (CMax < 1) then
      Sat := (CMax - CMin) / (2 - CMax - CMin);
    Delta := CMax - CMin;
    if Red = CMax then
      Hue := (Green - Blue) / Delta
    else if Green = CMax then
      Hue := 2 + (Blue - Red) / Delta
    else
      Hue := 4.0 + (Red - Green) / Delta;
    Hue := Hue / 6;
    if Hue < 0 then
      Hue := Hue + 1;
  end;
  H := Round(Hue * 360);
  S := Round(Sat * 100);
  L := Round(Lum * 100);
end;
{------------------------}
FUNCTION RGBTripleToY(CONST RGB: TRGBTriple): Integer;
BEGIN
  WITH RGB DO
    RESULT := Integer(77 * rgbtRed + 150 * rgbtGreen + 29 * rgbtBlue) SHR 8
END { RGBtoY };
بعد کد زیر رو توی یک button بنویسید.
var
  bmp, bmp1: TBitmap;
  x, y, ScanlineBytes: Integer;
  p1, p2: pbytearray;
  RVALUE, bvalue, gvalue, num: Integer;
  hVALUE, sVALUE, lVALUE: Integer;
  tm1, tm2: Integer;
begin
  self.DoubleBuffered := true;
  num := 0;
  bmp := TBitmap.Create;
  bmp1 := TBitmap.Create;
  bmp.Assign(OroginalColorImage.Picture.Bitmap);
  bmp1.Assign(OroginalColorImage.Picture.Bitmap);
  bmp.PixelFormat := pf24bit;
  bmp1.PixelFormat := pf24bit;
  for y := 0 to bmp.Height - 3 do
  begin
    p1 := bmp.ScanLine[y];
    p2 := bmp1.ScanLine[y];
    begin
      for x := 0 to bmp.Width - 3 do
      begin
        RVALUE := p2[3 * x + 1];
        gvalue := p2[3 * x] + 2;
        bvalue := p2[3 * x];
        RGBtoHSL(RVALUE, gvalue, bvalue, hVALUE, sVALUE, lVALUE);
        lVALUE := lVALUE;
        lVALUE := Min(100, lVALUE);
        if (hVALUE > 170) and (hVALUE <= 230) then
        begin
          num := num + 1;
          p1[3 * x] := 255;
          p1[3 * x + 1] := 255;
          p1[3 * x + 2] := 255;
        end
        else if (hVALUE > 40) and (hVALUE < 80) then
        begin
          p1[3 * x] := 200;
          p1[3 * x + 1] := 200;
          p1[3 * x + 2] := 200;
        end
        else if hVALUE > 340 then
        begin
          p1[3 * x] := 150;
          p1[3 * x + 1] := 150;
          p1[3 * x + 2] := 150;
        end
        else if lVALUE > 80 then
        begin
          p1[3 * x] := 100;
          p1[3 * x + 1] := 100;
          p1[3 * x + 2] := 100;
        end
        else
        begin
          p1[3 * x] := 0;
          p1[3 * x + 1] := 0;
          p1[3 * x + 2] := 0;
        end;
      end;
    end;
  end;
  ImageHistoStretched.Picture.Bitmap.Assign(bmp);
  bmp.free;
  bmp1.free;
گفتن نداره ولی :
 OroginalColorImage یک کنترل TImage است و باید عکس رو درونش قرار بدید.
در انتها
LPR.JPG
نکته : این فقط یک نمونه ساده بیشتر نیست و حساسیتش هم به رنگه پلاکه و با پلاک ایران کار نمی کنه !
کمی هم باید تلاش کنید.
موفق باشید.
اینم عکس ماشینی که توی نمونه است.