Autor Beitrag
klezmor
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: Sa 16.12.06 23:00 
Zur zeit verwende ich einen primitiven Algorithmus, der in einem Bild alle nicht roten Pixel eliminiert(RGB system). Dies funktioniert mehr oder weniger nicht so gut, da die toleranz für rote pixel ziemlich stark eingeschränkt ist. Deshalb frage ich mich, ob es nicht einen solchen Alorithmus schon gibt. Man übergibt z.b. einen RGB-Wert und eine Toleranz. Dieser Algorithmus schmeißt dann alle Pixel, welche nicht diesen ungefähren wert haben heraus.
Spontan fällt einem da wahrscheinlich eine abfrage der 3 Kanäle in Verbindung mit der Toleranzgrenze ein, aber sowas funzt ja nicht wirklich. Kennt jemand einen solchen Algorithmus?

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth


Zuletzt bearbeitet von klezmor am So 17.12.06 10:41, insgesamt 1-mal bearbeitet
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 16.12.06 23:12 
Hallo!

Wähle doch bitte einen Titel, der Dein Problem besser beschreibt. "Bildverarbeitung" kann nun wirklich ziemlich viel sein ;-)

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: So 17.12.06 05:58 
Hallo,

vielleicht ist die Umsetzung von RGB in einen anderen Farbraum die Lösung.
de.wikipedia.org/wiki/HSV-Farbraum
www.delphi-forum.de/viewtopic.php?t=65518

Gruss Horst
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 17.12.06 10:39 
Möglicherweise könnte mir die Portierung in einen anderen Farbraum nützlich sein, jedoch hat dies nichts mit den einezelnen Kanälen zu tun. Also, ich meine jetzt, dass deshalb nicht vordefinierte Farben verschwinden.

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: So 17.12.06 10:49 
user profile iconklezmor hat folgendes geschrieben:

Spontan fällt einem da wahrscheinlich eine abfrage der 3 Kanäle in Verbindung mit der Toleranzgrenze ein, aber sowas funzt ja nicht wirklich.

Wieso denn nicht? Notfalls kannst du ja auch für RGB drei einzelne Toleranz-Werte nehmen. Wenn die richtig gesetzt sind, müssten auch alle roten Pixel korrekt gefiltert werden.
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 17.12.06 11:07 
Ich habe es schon getestet, aber es hat nicht funktioniert. Aber wenn du glaubst es könnte funktionieren dann werde ich mich noch mal auf die Fehlersuche machen, also der PseudoCode könnte meiner Ansicht nach so aussehen.

const RGB:TFarbwert = 255^2*(155)+255*(200)+(123)//RGB= 155 200 123
const Toleranz:integer = 20;

Geh alle pixel durch und frage ab:

if (pixel.rot=155+-toleranz & pixel.grün=200+-toleranz & pixel.gelb=123+-toleranz) then
pixel ist die gesuchte Farbe
else
lösche pixel


Das Problem ist meiner Meinung nach das menschliche Sehen. Wenn ich z.B. einen bestimmten Rotton mit einer gewissen Toleranz herausfiltere, dann ist die Schranke bei den einzelnen Kanälen beim menschlichen Sehen nicht unbedingt gleich.

// edit Gibt es eigentlich einen Datentyp in welchem man die einzelnen Kanäle eines Pixels abfragen kann?

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: So 17.12.06 11:43 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function FilterPixel(C1, C2: TColor; Tol: Byte): Boolean;
begin
  FilterPixel := ((Abs(GetRValue(C2) - GetRValue(C1)) <= Tol)  and 
                  (Abs(GetGValue(C2) - GetGValue(C1)) <= Tol)) and 
                  (Abs(GetBValue(C2) - GetBValue(C1)) <= Tol);
end;

C1 ist die Farbe des aktuellen Pixels, C2 ist z.B. ein Rot-Ton, und Tol ist die Toleranz als Byte. Du musst halt jeden Pixel des Bildes per FilterPixel prüfen und dann dementsprechend reagieren.
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 17.12.06 11:50 
Jo danke kann es gerade nicht testen, aber funktioniert es so? Wie gesagt das menschliche Sehen wägt meiner Meinung nach nicht so ab, wie wir uns das mechanisch vorstellen.

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: Fr 22.12.06 20:11 
Kennt jemand irgendwelche Bibliotheken in Object Pascal, die verschiedene Bildverarbeitungsalgorithmen schon implementiert haben.
So etwas ähnliches wie Opencv.

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 22.12.06 22:12 
Es gibt Farbräume, die auf das menschliche Sehsystem angepasst sind, sodass man in diesem transformierten Raum Distanzen via einer Vektornorm (z.B. via Pythagoras) schätzen kann. Schau dir z.B. "CIE Lab" an.
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: Sa 23.12.06 16:06 
Also gibt es für delphi keine fertigen bibliotheken oder?

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth