Einzelnen Beitrag anzeigen

Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#30

AW: Prozentrechnung

  Alt 8. Nov 2011, 14:48
kann es sein dass Du mit Laufzeitpaketen kompiliert hast und die bpl's nicht gefunden werden?
Ich habe den Teil der Geschwindigkeit bringt mal kurz ausgetauscht:
Delphi-Quellcode:
type
  pRGBTripleArray = ^TRGBTripleArray;
  TRGBTripleArray = ARRAY[0..$effffff] OF TRGBTriple;


procedure TForm1.BitBtn1Click(Sender: TObject);
var
  x,y:Integer;
  bmp:TBitMap;
  pLine: pRGBTripleArray;
begin
bmp := TBitmap.Create;
bmp.Assign(Image1.Picture.Bitmap);
bmp.PixelFormat := pf24Bit;
try
  //Progress Bar
  ProgressBar1.Max := Image1.Picture.Bitmap.Width +1;
  //Progress Bar Ende

Memo3.lines.Delete(0);
ProgressBar1.position:=0;
  for Y := 0 to bmp.Height - 1 do

  begin
    ProgressBar1.Position := ProgressBar1.Position+1;
    pLine := bmp.ScanLine[Y];
    for x := 0 to bmp.Width -1 do
        begin
          b := pLine[x].rgbtBlue;
          r := pLine[x].rgbtRed;
          g := pLine[x].rgbtGreen;
          z:=(0.299*r)+(0.587*g)+(0.114*b);
          u:=(b-z)*0.493;
          v:=(r-z)*0.877;
            if (z>0) and (z<121)then begin
               // y = 0 - 0.33
               if (u>-112) and (u<16) and (v<157) and (v>33.64)then
                  rot:=rot+1
               else begin
                      if (u<8) and (u>-64) and (v<33.64) and (v>11.21)then
                          rot:=rot+1
                      else begin
                          if (u<112) and (u>16) and (v<157) and (v>100.92)then
                              lila:=lila+1
                          else begin
                                if (u<112) and (u>32) and (v<100.92) and (v>33.64)then
                                    blau:=blau+1
                                else begin
                                    if (u<112) and (u>8) and (v<33.64) and (v>-157)then
                                        blau:=blau+1
                                    else begin
                                        if (u<8) and (u>-8) and (v<11.21) and (v>-157)then
                                            gruen:=gruen+1
                                        else begin
                                            if (u<-8) and (u>-112) and (v<0) and (v>-157)then
                                                gruen:=gruen+1
                                            else begin
                                                if (u<64) and (u>-112) and (v<33.64) and (v>0)then
                                                    gruen:=gruen+1
                                                else begin
                                                    if (u<-8) and (u>64) and (v<11.21) and (v>0)then
                                                        gruen:=gruen+1
                                                    else begin
                                                        if (u<8) and (u>-8) and (v<11.21) and (v>-11.21)then
                                                            schwarz:=schwarz+1
                                                    end;
                                                end;
                                            end;
                                        end;
                                    end;
                                end;
                          end;
                      end;
               end;
            end
            else begin
              if (z>120) and (z<160)then begin
                  //y = 86 - 170
                  if (u<-16) and (u>-112) and (v<112.14) and (v>22.42)then
                      orange:=orange+1
                  else begin
                      if (u<16) and (u>-112) and (v<157) and (v>112.14)then
                          orange:=orange+1
                      else begin
                          if (u<112) and (u>-16) and (v<157) and (v>11.21)then
                              lila:=lila+1
                          else begin
                              if (u<122) and (u>8) and (v<11.21) and (v>-11.21)then
                                  blau:=blau+1
                              else begin
                                  if (u<112) and (u>0) and (v<-11.21) and (v>-157)then
                                      blau:=blau+1
                                  else begin
                                      if (u<0) and (u>-112) and (v<-11.21) and (v>-157)then
                                          gruen:=gruen+1
                                      else begin
                                          if (u<-8) and (u>-112) and (v<11.21) and (v>-11.21)then
                                              gruen:=gruen+1
                                          else begin
                                              if (u<8) and (u>-8) and (v<11.21) and (v>-11.21)then
                                                  grauweiss:=grauweiss+1;
                                          end;
                                      end;
                                  end;
                              end;
                          end;
                      end;
                  end;
              end
              else begin
              //y = 160 - 255
              if z>159 then begin
                  if (u<-32) and (u>-112) and (v<157) and (v>-44.85)then
                      gelb:=gelb+1
                  else begin
                      if (u<-24) and (u>-32) and (v<22.42) and (v>-44.85)then
                          gelb:=gelb+1
                       else begin
                        if (u<112) and (u>-32 ) and (v<157) and (v>22.42)then
                            lila:=lila+1
                        else begin
                            if (u<112) and (u>24 ) and (v<22.42) and (v>-11.21)then
                                lila:=lila+1
                            else begin
                                if (u<112) and (u>-24) and (v<-11.21) and (v>-157)then
                                    blau:=blau+1
                                else begin

                                end;
                            end;
                        end;
                       end;
                  end;
              end;
              end;
            end;

    //ende Farbe verzweigungen
  end;
  end;
    Memo3.Lines.Add('Rot:' + inttostr(rot));
    Memo3.Lines.add(FloatToStr(rot * 100 / (Image1.Picture.Width * Image1.Picture.Height)) + '%');
    Memo3.Lines.Add('Violett:' + inttostr(lila));
    Memo3.Lines.add(FloatToStr(lila * 100 / (Image1.Picture.Width * Image1.Picture.Height)) + '%');
    Memo3.Lines.Add('Blau:' + inttostr(blau));
    Memo3.Lines.add(FloatToStr(blau * 100 / (Image1.Picture.Width * Image1.Picture.Height)) + '%');
    Memo3.Lines.Add('Grün:' + inttostr(gruen));
    Memo3.Lines.add(FloatToStr(gruen * 100 / (Image1.Picture.Width * Image1.Picture.Height)) + '%');
    Memo3.Lines.Add('Schwarz:' + inttostr(schwarz));
    Memo3.Lines.add(FloatToStr(schwarz * 100 / (Image1.Picture.Width * Image1.Picture.Height)) + '%');
    Memo3.Lines.Add('Orange:' + inttostr(orange));
    Memo3.Lines.add(FloatToStr(orange * 100 / (Image1.Picture.Width * Image1.Picture.Height)) + '%');
    Memo3.Lines.Add('Gelb:' + inttostr(gelb));
    Memo3.Lines.add(FloatToStr(gelb * 100 / (Image1.Picture.Width * Image1.Picture.Height)) + '%');

finally
  bmp.Free;
end;
end;
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
  Mit Zitat antworten Zitat