我想分析一個.Jpeg圖像600x600,但這樣做我想告訴我,紅色值在230以上,綠色值在200以上。 現在我有這個項目正在進行,但迭代整個圖像需要很長時間,並且會獲得奇怪的像素顏色值(Color= + inttostr(RGB)
)。 任何人都可以借我一隻手嗎?顏色檢測和分析
type
PRGBTripleArray = ^TRGBTripleArray;
TRGBTripleArray = array[0..4095] of TRGBTriple;
procedure TForm2.Button1Click(Sender: TObject);
var
RGB: Byte;
X, Y: Integer;
R, G, B: Byte;
Bitmap1: TBitmap;
ColorRGB: LongInt;
Pixels: PRGBTripleArray;
begin
Memo1.Lines.Clear;
Bitmap1 := TBitmap.Create;
try
Bitmap1.Assign(Image1.Picture.Graphic);
for Y := 0 to Bitmap1.Height - 1 do
begin
Pixels:= Bitmap1.ScanLine[Y];
Memo1.Lines.Add('======================');
Memo1.Lines.Add('Line # ' + IntToStr(Y));
Memo1.Lines.Add('======================');
for X := 0 to Bitmap1.Width - 1 do
begin
ColorRGB := ColorToRGB(Bitmap1.Canvas.Pixels[x, y]);
R := GetRValue(ColorRGB);
G := GetGValue(ColorRGB);
B := GetBValue(ColorRGB);
RGB:= R*G*B;
Memo1.Lines.Add(
'line=' + IntToStr(Y)
+ ' row=' + IntToStr(X)
+ ' Colour=' + IntToStr(RGB)
+ ' Red=' + IntToStr (R) // red
+ ' Green=' + IntToStr (G) // blue
+ ' Blue=' + IntToStr (B) // green
)
end;
end;
finally
Bitmap1.free;
end;
end;
end.
我根本沒有得到'RGB:= R * G * B;'。你爲什麼要計算產品?另外,您可能需要設置像素格式。 – 2013-02-26 19:22:42
RGB值中的顏色從[0到16581375(255 * 255 * 255)]不等,我不應該使用該產品'R * G * B',但如果有時值爲0,解決方案如何? – Ammadeux 2013-02-26 19:33:04
@AndreasRejbrand如何設置像素格式? – Ammadeux 2013-02-26 19:34:06