


Модератор: Модераторы
begin
max_value:=max_of(R,G,B);
min_value:=min_of(R,G,B);
diff:=max_value-min_value;
V:=max_value;
if max_value<>0 then s:=(diff / max_value) else S:=0;
if S=0 then h:=undefined
else
begin
r:=(max_value-R) / diff;
g:=(max_value-G) / diff;
b:=(max_value-B) / diff;
if R=max_value
then H:=b_dist-g_dist
else if G=Max_value
then H:=2+r_dist-b_dist
else if B=max_value
then H:=4+g_dist-r_dist;
H:=H*60;
if H<0 then H:=H+360;
end;
end;
Alex2013 писал(а):"Как однажды Жак звонарь городской сломал фонарь "
Брр в чём проблема ?
http://habrahabr.ru/post/181580/
Не кури бамбук !
ЗЫ
Или совсем уж просто
- Код: Выделить всё
begin
max_value:=max_of(R,G,B);
min_value:=min_of(R,G,B);
diff:=max_value-min_value;
V:=max_value;
if max_value<>0 then s:=(diff / max_value) else S:=0;
if S=0 then h:=undefined
else
begin
r:=(max_value-R) / diff;
g:=(max_value-G) / diff;
b:=(max_value-B) / diff;
if R=max_value
then H:=b_dist-g_dist
else if G=Max_value
then H:=2+r_dist-b_dist
else if B=max_value
then H:=4+g_dist-r_dist;
H:=H*60;
if H<0 then H:=H+360;
end;
end;
Сам цвет что-то вроде
Цвет = H / (360/7)
if (H >= 0) and (H <= 17) then begin p^[x].r := 255; p^[x].g := 0; p^[x].b := 0; inc(iRed); end
else if (H > 17) and (H <= 50) then begin p^[x].r := 255; p^[x].g := 128; p^[x].b := 0; inc(iOrange); end
else if (H > 50) and (H <= 83) then begin p^[x].r := 255; p^[x].g := 255; p^[x].b := 0; inc(iYellow); end
else if (H > 83) and (H <= 116) then begin p^[x].r := 0; p^[x].g := 255; p^[x].b := 0; inc(iGreeen); end
else if (H > 116) and (H <= 149) then begin p^[x].r := 0; p^[x].g := 255; p^[x].b := 255; inc(iLightBlue); end
else if (H > 149) and (H <= 185) then begin p^[x].r := 0; p^[x].g := 0; p^[x].b := 255; inc(iBlue); end
else if (H > 185) and (H <= 220) then begin p^[x].r := 128; p^[x].g := 0; p^[x].b := 255; inc(iPurple); end
else if (H > 220) and (H <= 240) then begin p^[x].r := 255; p^[x].g := 0; p^[x].b := 0; inc(iRed); end
Можно прокоментировать код. А то что-то не понятно что и к чему.
Или совсем уж просто
begin
max_value:=max_of(R,G,B); // Максимум из трех чисел
min_value:=min_of(R,G,B); .// Минимум из трех чисел
diff:=max_value-min_value;
V:=max_value; // Это и есть V в НSV
if max_value<>0 then s:=(diff / max_value) else S:=0;
// Это и есть S в НSV
if S=0 then h:=undefined
else
begin
r_dist:=(max_value-R) / diff;
g_dist:=(max_value-G) / diff;
b_dist:=(max_value-B) / diff;
if R=max_value
then H:=b_dist-g_dist
else if G=Max_value
then H:=2+r_dist-b_dist
else if B=max_value
then H:=4+g_dist-r_dist;
H:=H*60;
if H<0 then H:=H+360;
end;
// Это и есть .Н в НSV
end;
Сам цвет что-то вроде
Цвет = H / (360/7)
Сейчас этот форум просматривают: Yandex [Bot] и гости: 233