Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and...
Transcript of Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and...
![Page 1: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/1.jpg)
Computer VisionImage geometry and implementation
Juan Irving Vasquez
Consejo Nacional de Ciencia y Tecnologıa
5 de febrero de 2020
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 1 / 29
![Page 2: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/2.jpg)
Image geometry
The pinhole model
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 2 / 29
![Page 3: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/3.jpg)
Image geometry
There are two parts of the image formation:
Geometry. Determines where in the image plane a point of the realworld will be shown.Intensity of light. Determines the amount of brightness that a point inthe image will have.
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 3 / 29
![Page 4: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/4.jpg)
Image geometry (inverted)
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 4 / 29
![Page 5: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/5.jpg)
Image geometry
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 5 / 29
![Page 6: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/6.jpg)
Image geometry
Let us write,f
z=
r ′
r
x ′
x=
y ′
y=
r ′
r
Prove that (activity),
x ′ =f
zx
y ′ =f
zy
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 6 / 29
![Page 7: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/7.jpg)
What is an image?
A function.f (x , y) : R2 → R (1)
But computers are not so capable, then
I (i , j) : [a, b]× [c , d ]→ [min,max ] (2)
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 7 / 29
![Page 8: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/8.jpg)
What is an image?
A function.f (x , y) : R2 → R (1)
But computers are not so capable, then
I (i , j) : [a, b]× [c , d ]→ [min,max ] (2)
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 7 / 29
![Page 9: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/9.jpg)
Samplig and quantization
A discrete image
I (i , j) : [a, b]× [c , d ]→ [min,max ]
Samplig. The amount of pixels in the image.e.g. 640× 480 pixels
Quantization. The possibles values for each pixel.e.g. binary, 8 bits, or float (HDRI)
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 8 / 29
![Page 10: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/10.jpg)
Implementation
Figura: Gray scale imageJ. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 9 / 29
![Page 11: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/11.jpg)
Color images
A vector valued function or ”stacked”
f (x , y) =
r(x , y)g(x , y)b(x , y)
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 10 / 29
![Page 12: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/12.jpg)
Implementation
Figura: Color imageJ. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 11 / 29
![Page 13: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/13.jpg)
OpenCV
OpenCV
The Open Source Computer Vision Library is an open source computervision and machine learning software library.
Provides a common infrastructure for computer vision application
Accelerates the use of machine perception in the commercial products
BSD-licensed product
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 12 / 29
![Page 14: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/14.jpg)
Implementation
Create an image (matrix).
Mat a= Mat ( S i z e ( 5 , 5 ) , CV 32F ) ;
Data types
CV 8UC1CV 8UC3CV 8UC4CV 32FC1CV 32FC3CV 32FC4
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 13 / 29
![Page 15: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/15.jpg)
Data types
(Check by yourself)
Mat
Vec
Scalar
Point
Size
Rect
RotatedRect
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 14 / 29
![Page 16: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/16.jpg)
Lets go to code!!
Repository:
OpenCV Exampleshttps://github.com/irvingvasquez/vision_programas.git
Primer programa: leer y mostrar una imagen.
01_operaciones_basicas.ipynb
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 15 / 29
![Page 17: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/17.jpg)
Basic operations
Addition, C = A + Bci ,j = ai ,j + bi ,j (3)
Substraction, C = A− B
ci ,j = ai ,j − bi ,j (4)
Multiplication, C = AB. If A is an m × n matrix and B is an n × pmatrix,
ci ,j =n∑
k=1
ai ,kbk,j (5)
Element-wise multiplication
ci ,j = ai ,jbi ,j (6)
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 16 / 29
![Page 18: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/18.jpg)
Suma
Programa 03
Mat ImGray= imread ( ” . . / l e n a . j p g ” , 0 ) ;Mat ImGray2 = imread ( ” . . / monkey . j p g ” , 0 ) ;
Mat sum = Mat ( ImGray . s i z e ( ) , t y p e ) ;sum = ImGray + ImGray2 ;
imshow (”Suma” , sum ) ;
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 17 / 29
![Page 19: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/19.jpg)
Addition
Figura: Addition. Is this ok?
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 18 / 29
![Page 20: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/20.jpg)
Suma (Weighted)
Programa 04
Mat ImGray= imread ( ” . . / l e n a . j p g ” , 0 ) ;Mat ImGray2 = imread ( ” . . / monkey . j p g ” , 0 ) ;
Mat sum = Mat ( ImGray . s i z e ( ) , t y p e ) ;
f l o a t a l p h a = 0 . 5 ;sum = a l p h a ∗ ImGray + (1− a l p h a ) ∗ ImGray2 ;
imshow (” wighted sum ” , sum ) ;
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 19 / 29
![Page 21: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/21.jpg)
Suma (Weighted)
Figura:J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 20 / 29
![Page 22: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/22.jpg)
Region of Interest
A ROI allow us to work with certain parts of an image.
Figura: Regions of interest.
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 21 / 29
![Page 23: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/23.jpg)
Crop an image
// Read imagesMat ImGray= imread ( ” . . / l e n a . j p g ” , 0 ) ;Mat ImCropped ;
// x , yRect window ( 0 , 0 , ImGray . c o l s , 0 . 5∗ ImGray . rows ) ;
ImCropped = ImGray ( window ) ;
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 22 / 29
![Page 24: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/24.jpg)
Histograma
Muestra la frecuencia con la que aparece cada valor.
Una funcionf (i)
que cuenta cuantos pixeles tienen igual intensidad o en el intervalo i .
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 23 / 29
![Page 25: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/25.jpg)
Histogram
Figura: Red channel’s histogram
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 24 / 29
![Page 26: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/26.jpg)
Histogramas
Histograma normalizado
g(i) = f (i)/m
Histograma acumulado
g(i) =i∑
j=1
f (i)
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 25 / 29
![Page 27: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/27.jpg)
Histogram Modification
Histogram equalization.
Defines a mapping of gray levels p into gray levels q such that thedistribution of gray levels q is uniform.
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 26 / 29
![Page 28: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/28.jpg)
Equalizacion de histograma
Mapping
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 27 / 29
![Page 29: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/29.jpg)
Equalizacion de histograma
Mapping
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 28 / 29
![Page 30: Computer Vision - WordPress.com · 2020. 2. 5. · Computer Vision Image geometry and implementation Juan Irving V asquez Consejo Nacional de Ciencia y Tecnolog a 5 de febrero de](https://reader035.fdocuments.us/reader035/viewer/2022071608/61472b9bf4263007b135a5ec/html5/thumbnails/30.jpg)
Miniproject 1
Read this paper:BENDIG, Juliane, et al. Combining UAV-based plant height from crop surface
models, visible, and near infrared vegetation indices for biomass monitoring in
barley. International Journal of Applied Earth Observation and Geoinformation,
2015, vol. 39, p. 79-87.
Download this imagehttps://jivg.org/2016/10/05/mapa-del-campo-escom/
Compute the following idices:
GRVIMGRVI or RGBVI
Display your results
J. Irving Vasquez (jivg.org) Computer Vision 5 de febrero de 2020 29 / 29