SlideShare a Scribd company logo
1 of 28
Download to read offline
© Primož Weingerl
TEORIJA BARVNE REPRODUKCIJE
Pretvarjanje barvnih vrednosti in izvajanje barvnih preslikav s
pomočjo programa OCTAVE/MATLAB
Primož Weingerl, mag. graf. inž.

primoz.weingerl@ntf.uni.lj
© Primož Weingerl
http://wiki.octave.org/Octave_for_MacOS_X
https://www.gnu.org/software/octave/
© Primož Weingerl
OSNOVNI PODATKOVNI TIPI
Števila (numbers): int (8, 16, 32, 64), uint (8, 16, 32, 64), double, single, double
complex, single complex.
a = 1.879384;

b = 125;
Znakovni niz (string) – char
str = ‘This is string’;

str2 = “This is string”;
Logična vrednost (boolean) – logical
true / false
Polja (arrays) – matrike
M = [1 2 3; 4 5 6; 7 8 9];
M = [1, 2, 3; 4, 5, 6; 7, 8, 9];

v = [1:2:10];
© Primož Weingerl
Cell Array – seznam vrednosti različnih podatkovnih tipov
cell1 = {[1 2 3], “Lorem ipsum”, 125};

Structures
students(1).name  = 'Janez';

students(1).age   = 21; 

students(2).name  = 'Metka';

students(2).age   = 33;
Koristne funkcije:
class()
cast()
typeinfo()
y = typecast (x, “class”)
isa()
whos
clear
clc
© Primož Weingerl
POIMENOVANJE SPREMENLJIVK

Začeti se mora s poljubno črko in se lahko nadaljuje s črko, številko ali podčrtajem.
KOMENTARJI

# Octave and #{Block comment}#

%Matlab and %{ Multilines Matlab comments%}
© Primož Weingerl
INDEKSIRANJE
Vektorji:
b = [0:3:30]
b(3)

b(3:6)

b(1:3:end)

b(end:-3:1)

b([1 3 4])
Matrike:
A = [ 1 2 3; 4 5 6; 7 8 9]
A(2,3)

A(1:2, 1:2)

A(end,end)

A([1 2],[1 2])

A(:,3)
C = logical([1 0 0; 0 0 1; 0 0 0])

A(C)

A(C) = [10 20]

A(C) = 100
© Primož Weingerl
OPERATORJI
© Primož Weingerl
LOGIČNI OPERATORJI
&(element-wise), && logični in
~, ! (octave) negacija
| (element-wise), || logični ali
== ekvivalentno
~=, != (octave) ni enako
< manjše
<= manjše ali enako
> večje
>= večje ali enako
all true if all the elements are nonezero
any true if any of the elements are nonezero
© Primož Weingerl
POGOJNI STAVKI
IF STAVEK
if <condition>
do_something();
elseif <condition>
do_something_else();
else
do_something_else();
end
SWITCH STAVEK
switch (variable)
case 1
do_something ();
case 2
do_something_else ();
otherwise
do_something_else ();
end
© Primož Weingerl
ZANKE
WHILE
while <condition>
do_something();
end
i = 1;
while (i <= 10)
disp(i);
i++;
end
FORM
for i = <sequence>
do_something();
end
for i = 1:1:10
disp(i);
end
break – ustavi izvajanje zanke, 

continue – nadaljuje z naslednjo iteracijo
© Primož Weingerl
VEKTORIZACIJA (izogibanje zankam)
UPORABA ZANKE
i = 0;
for t = 0:.01:10
i = i + 1;
y(i) = sin(t);
end
VEKTORIZACIJA
t = 0:.01:10;
y = sin(t);
© Primož Weingerl
FUNKCIJE (M-FILES)
function [outputs] = name (inputs)
.
.
.
end
function name (inputs)
.
.
.
end
function name
.
.
.
end
z vhodnimi in

izhodnimi podatki
z vhodnimi podatki
brez vhodnih in izhodnih
podatkov
© Primož Weingerl
Funkcija mora imeti predpisano obliko in shranjena kot “golo besedilo” v datoteko,
ki se imenuje enako kot funkcija in ima končnico .m
Funkcije se morajo nahajati v definiranem direktoriju, uporabi addpath() za
dodajanje direktorijev, po katerih bo program iskal funkcije.
UPORABA FUNKCIJE
[outputs] = name (inputs)

name (inputs)

name
© Primož Weingerl
VEČ INFORMACIJ

Uporabi pomoč programa: help().
Computational colour science using MATLAB / Stephen Westland, Caterina
Ripamonti, Vien Cheung
Digital image processing : using MATLAB / Rafael C. Gonzalez, Richard E. Woods,
Steven L. Eddins

VGRAJENE FUNKCIJE
MATRIKE: eye(), ones(), zeros(), rand(), diag() ...
SPREMENLJIVKE: size(),whos, clear...
MATEMATIČNE FUNKCIJE: sin(), cos(), tan(), atan(), abs(), sqrt(), max(), min(), mean(),
sum()
INTERAKTIVNOST: save, load, fprint(), disp(), input()...
GRAFIKA: plot(), mesh(), surf()...
© Primož Weingerl
NALOGE
1. Napiši funkcijo za izračun ΔEab. Vhodna podatka naj bosta vektorja LAB1 in LAB2,
izhodni podatek pa ΔEab.
2. Funkciji dodajte interpretacijo izračunane barvne razlike:

če je delta E manjša ali enaka 1 izpiše razlika je minimalna,

če je deltaE večja od 1 in enaka ali manjša od 3 izpiše razlika je sprejemljiva,

če je deltaE večja 3 in manjša ali enaka 5 izpiše razlika je vidna,

če je deltaE večja od 5 izpiše razlika je očitna.
© Primož Weingerl
DOMAČA NALOGA
1. Funkcija za izračun CIE XYZ vrednosti. Vhodni podatki so: refleksija, emisijski
spekter svetlobnega vira in funkcije spektralnih vrednosti. Izhodni podatek so
vrednosti CIE XYZ. 















2. Napiši funkcijo, ki izračuna barvno razliko CIE 2000.
X = k S ( )R( )x
_
( )
380
780
Y = k S(λ)R(λ)y
_
(λ)
380
780
∑ Z = k S(λ)R(λ)z
_
(λ)
380
780
∑
k =
100
S(λ)y
_
(λ)
380
780
∑
© Primož Weingerl
PRETVARJANJE BARVNIH VREDNOSTI
© Primož Weingerl
RGB ⟷ XYZ
1. Izračun X, Y, Z za vsak primarni barvni dražljaj (r, g, b).









2. Izračun Sr, Sg, Sb.











3. Izračun transformacijske matrike.
M⎡⎣ ⎤⎦=
Sr
Xr
Sg
Xg
Sb
Xb
Sr
Yr
Sg
Yg
Sb
Yb
Sr
Zr
Sg
Zg
Sb
Zb
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
Xr
= xr
/ yr
Yr
= 1
Zr
=(1−xr
−yr
)/ yr
Xg
= xg
/ yg
Yg
= 1
Zg
=(1−xg
−yg
)/ yg
Xb
= xb
/ yb
Yb
= 1
Zb
=(1−xb
−yb
)/ yb
Sr
Sg
Sb
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
=
Xr
Xg
Xb
Yr
Yg
Yb
Zr
Zg
Zb
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
−1
XW
YW
ZW
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
© Primož Weingerl
X
Y
Z
⎡
⎣
⎢
⎢
⎤
⎦
⎥
⎥
= M⎡⎣ ⎤⎦
R
G
B
⎡
⎣
⎢
⎢
⎤
⎦
⎥
⎥
R
G
B
⎡
⎣
⎢
⎢
⎤
⎦
⎥
⎥
= M⎡⎣ ⎤⎦
−1
X
Y
Z
⎡
⎣
⎢
⎢
⎤
⎦
⎥
⎥
RGB → XYZ XYZ → RGB
• X, Y, Z vrednosti morajo biti normalizirane med 0 in 1.
• RGB vrednosti morajo biti linearne in normalizirane med 0 in 1.
• Izračunane X, Y, Z ali R, G, B vrednosti so v območju med 0 in 1.
© Primož Weingerl
NALOGE
1. Napiši funkcijo getM, ki vrne matriko M, glede na podane xy vrednosti primarnih
dražljajev in XYZ vrednosti bele točke.



M = getM(xyR, xyG, xyB, xyzw)

2. Napiši funkcijo xyz2rgb, ki dane XYZ vrednosti pretvori v vrednosti RGB. Podprti
naj bodo barvni prostori: Adobe RGB, sRGB, Wide Gamut RGB.



rgb = xyz2rgb(xyz, ‘sRGB’)

3. Napiši funkcijo rgb2xyz, ki dane RGB vrednosti pretvori v vrednosti XYZ. Podprti
naj bodo barvni prostori: Adobe RGB, sRGB, Wide Gamut RGB.



xyz = rgb2xyz(rgb, ‘sRGB’)
© Primož Weingerl
KROMATIČNA PRILAGODITEV
© Primož Weingerl
Kromatična prilagoditev je linearna transformacija vhodnih XYZs vrednosti v izhodne XYZD
vrednosti, izvedena s pomočjo matrike [M], ki je odvisna od bele točke vhodnega (XYZWS)
in izhodnega (XYZWD) barvnega prostora ter od vrste kromatične prilagoditve [MA].
1. Pretvorba vhodnih X, Y, Z vrednosti v ρ, γ, β:







2. Izračun transformacijske matrike [M]:











3. Izračun izhodnih X, Y, Z vrednosti:
ρS
γS
βS
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
=[MA
]
XWS
YWS
ZWS
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
ρD
γD
βD
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
=[MA
]
XWD
YWD
ZWD
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
[M]=[MA
]−1
ρD
ρS
γD
γS
βD
βS
⎡
⎣
⎢
⎢
⎢
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
⎥
⎥
⎥
[MA
]
XD
YD
ZD
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
=[M]
XS
YS
ZS
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
© Primož Weingerl
NALOGA
Napiši funkcijo chromAdapt, ki opravi kromatično prilagoditev:



xyzD = chromAdapt(xyzS, ws, wd, cm)



xyzS – vhodne XYZ vrednosti (vektor, 3 × 1)

ws – bela točka vhodnega barvnega prostora (string). Podprte bele točke: 

‘d50’, ‘d65’ in ‘A’.

wd – bela točka izhodnega barvnega prostora (string). Podprte bele točke: 

‘d50’, ‘d65’ in ‘A’.

cm – način kromatične prilagoditve (string). Podprte metode: 

‘XYZ Scaling’, ‘Bradford’ in ‘Von Kries’.
© Primož Weingerl
CIECAM02
© Primož Weingerl
Okolica
Ozadje
Dražljaj
Neposredna
okolica
© Primož Weingerl
Ozadje R: 200 G: 200 B: 200
#88A8B8
© Primož Weingerl
Ozadje R: 70 G: 70 B: 70
#78929f
© Primož Weingerl
CIECAM02
1. Izračun vrednosti XYZ vzorca (XYZ1) iz znanih vrednosti RGB1
2. Izračun vrednosti XYZ iz znanih vrednosti RGB:
• izhodiščno ozadje (XYZb1)
• ciljno ozadje (XYZb2)
3. Pretvorba vrednosti XYZ vzorca (XYZ1) v vrednosti JCh. Vhodni parametri:
• XYZ1
• XYZw (bela točka D65)
• Svetlost zaslona
• Yb1
4. Pretvorba vrednosti JCh v XYZ2 z upoštevanjem ozadja XYZb2. Vhodni parametri:
• JCh
• XYZw (bela točka D65)
• Svetlost zaslona
• Yb2
5. Pretvorba XYZ2 v nove vrednosti RGB2

More Related Content

Featured

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

TBR

  • 1. © Primož Weingerl TEORIJA BARVNE REPRODUKCIJE Pretvarjanje barvnih vrednosti in izvajanje barvnih preslikav s pomočjo programa OCTAVE/MATLAB Primož Weingerl, mag. graf. inž.
 primoz.weingerl@ntf.uni.lj
  • 3. © Primož Weingerl OSNOVNI PODATKOVNI TIPI Števila (numbers): int (8, 16, 32, 64), uint (8, 16, 32, 64), double, single, double complex, single complex. a = 1.879384;
 b = 125; Znakovni niz (string) – char str = ‘This is string’;
 str2 = “This is string”; Logična vrednost (boolean) – logical true / false Polja (arrays) – matrike M = [1 2 3; 4 5 6; 7 8 9]; M = [1, 2, 3; 4, 5, 6; 7, 8, 9];
 v = [1:2:10];
  • 4. © Primož Weingerl Cell Array – seznam vrednosti različnih podatkovnih tipov cell1 = {[1 2 3], “Lorem ipsum”, 125};
 Structures students(1).name  = 'Janez';
 students(1).age   = 21; 
 students(2).name  = 'Metka';
 students(2).age   = 33; Koristne funkcije: class() cast() typeinfo() y = typecast (x, “class”) isa() whos clear clc
  • 5. © Primož Weingerl POIMENOVANJE SPREMENLJIVK
 Začeti se mora s poljubno črko in se lahko nadaljuje s črko, številko ali podčrtajem. KOMENTARJI
 # Octave and #{Block comment}#
 %Matlab and %{ Multilines Matlab comments%}
  • 6. © Primož Weingerl INDEKSIRANJE Vektorji: b = [0:3:30] b(3)
 b(3:6)
 b(1:3:end)
 b(end:-3:1)
 b([1 3 4]) Matrike: A = [ 1 2 3; 4 5 6; 7 8 9] A(2,3)
 A(1:2, 1:2)
 A(end,end)
 A([1 2],[1 2])
 A(:,3) C = logical([1 0 0; 0 0 1; 0 0 0])
 A(C)
 A(C) = [10 20]
 A(C) = 100
  • 8. © Primož Weingerl LOGIČNI OPERATORJI &(element-wise), && logični in ~, ! (octave) negacija | (element-wise), || logični ali == ekvivalentno ~=, != (octave) ni enako < manjše <= manjše ali enako > večje >= večje ali enako all true if all the elements are nonezero any true if any of the elements are nonezero
  • 9. © Primož Weingerl POGOJNI STAVKI IF STAVEK if <condition> do_something(); elseif <condition> do_something_else(); else do_something_else(); end SWITCH STAVEK switch (variable) case 1 do_something (); case 2 do_something_else (); otherwise do_something_else (); end
  • 10. © Primož Weingerl ZANKE WHILE while <condition> do_something(); end i = 1; while (i <= 10) disp(i); i++; end FORM for i = <sequence> do_something(); end for i = 1:1:10 disp(i); end break – ustavi izvajanje zanke, 
 continue – nadaljuje z naslednjo iteracijo
  • 11. © Primož Weingerl VEKTORIZACIJA (izogibanje zankam) UPORABA ZANKE i = 0; for t = 0:.01:10 i = i + 1; y(i) = sin(t); end VEKTORIZACIJA t = 0:.01:10; y = sin(t);
  • 12. © Primož Weingerl FUNKCIJE (M-FILES) function [outputs] = name (inputs) . . . end function name (inputs) . . . end function name . . . end z vhodnimi in
 izhodnimi podatki z vhodnimi podatki brez vhodnih in izhodnih podatkov
  • 13. © Primož Weingerl Funkcija mora imeti predpisano obliko in shranjena kot “golo besedilo” v datoteko, ki se imenuje enako kot funkcija in ima končnico .m Funkcije se morajo nahajati v definiranem direktoriju, uporabi addpath() za dodajanje direktorijev, po katerih bo program iskal funkcije. UPORABA FUNKCIJE [outputs] = name (inputs)
 name (inputs)
 name
  • 14. © Primož Weingerl VEČ INFORMACIJ
 Uporabi pomoč programa: help(). Computational colour science using MATLAB / Stephen Westland, Caterina Ripamonti, Vien Cheung Digital image processing : using MATLAB / Rafael C. Gonzalez, Richard E. Woods, Steven L. Eddins
 VGRAJENE FUNKCIJE MATRIKE: eye(), ones(), zeros(), rand(), diag() ... SPREMENLJIVKE: size(),whos, clear... MATEMATIČNE FUNKCIJE: sin(), cos(), tan(), atan(), abs(), sqrt(), max(), min(), mean(), sum() INTERAKTIVNOST: save, load, fprint(), disp(), input()... GRAFIKA: plot(), mesh(), surf()...
  • 15. © Primož Weingerl NALOGE 1. Napiši funkcijo za izračun ΔEab. Vhodna podatka naj bosta vektorja LAB1 in LAB2, izhodni podatek pa ΔEab. 2. Funkciji dodajte interpretacijo izračunane barvne razlike:
 če je delta E manjša ali enaka 1 izpiše razlika je minimalna,
 če je deltaE večja od 1 in enaka ali manjša od 3 izpiše razlika je sprejemljiva,
 če je deltaE večja 3 in manjša ali enaka 5 izpiše razlika je vidna,
 če je deltaE večja od 5 izpiše razlika je očitna.
  • 16. © Primož Weingerl DOMAČA NALOGA 1. Funkcija za izračun CIE XYZ vrednosti. Vhodni podatki so: refleksija, emisijski spekter svetlobnega vira in funkcije spektralnih vrednosti. Izhodni podatek so vrednosti CIE XYZ. 
 
 
 
 
 
 
 
 2. Napiši funkcijo, ki izračuna barvno razliko CIE 2000. X = k S ( )R( )x _ ( ) 380 780 Y = k S(λ)R(λ)y _ (λ) 380 780 ∑ Z = k S(λ)R(λ)z _ (λ) 380 780 ∑ k = 100 S(λ)y _ (λ) 380 780 ∑
  • 17. © Primož Weingerl PRETVARJANJE BARVNIH VREDNOSTI
  • 18. © Primož Weingerl RGB ⟷ XYZ 1. Izračun X, Y, Z za vsak primarni barvni dražljaj (r, g, b).
 
 
 
 
 2. Izračun Sr, Sg, Sb.
 
 
 
 
 
 3. Izračun transformacijske matrike. M⎡⎣ ⎤⎦= Sr Xr Sg Xg Sb Xb Sr Yr Sg Yg Sb Yb Sr Zr Sg Zg Sb Zb ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ Xr = xr / yr Yr = 1 Zr =(1−xr −yr )/ yr Xg = xg / yg Yg = 1 Zg =(1−xg −yg )/ yg Xb = xb / yb Yb = 1 Zb =(1−xb −yb )/ yb Sr Sg Sb ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ = Xr Xg Xb Yr Yg Yb Zr Zg Zb ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ −1 XW YW ZW ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥
  • 19. © Primož Weingerl X Y Z ⎡ ⎣ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ = M⎡⎣ ⎤⎦ R G B ⎡ ⎣ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ R G B ⎡ ⎣ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ = M⎡⎣ ⎤⎦ −1 X Y Z ⎡ ⎣ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ RGB → XYZ XYZ → RGB • X, Y, Z vrednosti morajo biti normalizirane med 0 in 1. • RGB vrednosti morajo biti linearne in normalizirane med 0 in 1. • Izračunane X, Y, Z ali R, G, B vrednosti so v območju med 0 in 1.
  • 20. © Primož Weingerl NALOGE 1. Napiši funkcijo getM, ki vrne matriko M, glede na podane xy vrednosti primarnih dražljajev in XYZ vrednosti bele točke.
 
 M = getM(xyR, xyG, xyB, xyzw)
 2. Napiši funkcijo xyz2rgb, ki dane XYZ vrednosti pretvori v vrednosti RGB. Podprti naj bodo barvni prostori: Adobe RGB, sRGB, Wide Gamut RGB.
 
 rgb = xyz2rgb(xyz, ‘sRGB’)
 3. Napiši funkcijo rgb2xyz, ki dane RGB vrednosti pretvori v vrednosti XYZ. Podprti naj bodo barvni prostori: Adobe RGB, sRGB, Wide Gamut RGB.
 
 xyz = rgb2xyz(rgb, ‘sRGB’)
  • 22. © Primož Weingerl Kromatična prilagoditev je linearna transformacija vhodnih XYZs vrednosti v izhodne XYZD vrednosti, izvedena s pomočjo matrike [M], ki je odvisna od bele točke vhodnega (XYZWS) in izhodnega (XYZWD) barvnega prostora ter od vrste kromatične prilagoditve [MA]. 1. Pretvorba vhodnih X, Y, Z vrednosti v ρ, γ, β:
 
 
 
 2. Izračun transformacijske matrike [M]:
 
 
 
 
 
 3. Izračun izhodnih X, Y, Z vrednosti: ρS γS βS ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ =[MA ] XWS YWS ZWS ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ ρD γD βD ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ =[MA ] XWD YWD ZWD ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ [M]=[MA ]−1 ρD ρS γD γS βD βS ⎡ ⎣ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ [MA ] XD YD ZD ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ =[M] XS YS ZS ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥
  • 23. © Primož Weingerl NALOGA Napiši funkcijo chromAdapt, ki opravi kromatično prilagoditev:
 
 xyzD = chromAdapt(xyzS, ws, wd, cm)
 
 xyzS – vhodne XYZ vrednosti (vektor, 3 × 1)
 ws – bela točka vhodnega barvnega prostora (string). Podprte bele točke: 
 ‘d50’, ‘d65’ in ‘A’.
 wd – bela točka izhodnega barvnega prostora (string). Podprte bele točke: 
 ‘d50’, ‘d65’ in ‘A’.
 cm – način kromatične prilagoditve (string). Podprte metode: 
 ‘XYZ Scaling’, ‘Bradford’ in ‘Von Kries’.
  • 26. © Primož Weingerl Ozadje R: 200 G: 200 B: 200 #88A8B8
  • 27. © Primož Weingerl Ozadje R: 70 G: 70 B: 70 #78929f
  • 28. © Primož Weingerl CIECAM02 1. Izračun vrednosti XYZ vzorca (XYZ1) iz znanih vrednosti RGB1 2. Izračun vrednosti XYZ iz znanih vrednosti RGB: • izhodiščno ozadje (XYZb1) • ciljno ozadje (XYZb2) 3. Pretvorba vrednosti XYZ vzorca (XYZ1) v vrednosti JCh. Vhodni parametri: • XYZ1 • XYZw (bela točka D65) • Svetlost zaslona • Yb1 4. Pretvorba vrednosti JCh v XYZ2 z upoštevanjem ozadja XYZb2. Vhodni parametri: • JCh • XYZw (bela točka D65) • Svetlost zaslona • Yb2 5. Pretvorba XYZ2 v nove vrednosti RGB2