Computer Vision and Pattern Recognition E xample tasks Prepared by Adam Świtoński Gliwice 2019 I mage processing - lab 1 Task 1 Following monochromatic image with 4 - bit scale is given: 1 2 3 4 5 1 0 1 2 1 1 2 1 14 15 12 2 3 1 15 12 12 1 4 1 3 3 2 1 5 0 0 0 1 0 Fig. 1 Determine new values of pix el s with coordinates (2,2) and (3,4) obtained by: a) The a verage filter with the symmetric mask of the size 3 × 3 and constant coefficients. b) The m edian filter with the symmetric window of the size 3 ×3. c) The g radient magnitude computed on the basis of Sobel masks. d) The l inear normalizat i on on 8 - bit grayscale. Solutions Ad a) For an average filter with a mask containing constant coefficients, the mean values of surroundings of the pixels determined by the mask placed in subsequent image points are calculated. The mask is symmetric and it has 3 × 3 size. It means all neighbour po ints a re averaged as depicted in Fig. 2, where by red and blue colors neighbo u rhood s of pix el s (2,2) and (3,4) are marked , respectively : 1 2 3 4 5 1 0 1 2 1 1 2 1 14 15 12 2 3 1 15 12 12 1 4 1 3 3 2 1 5 0 0 0 1 0 Fig . 2 Determined mean values for the pix el s (2,2) and (3, 4 ) are as follows: 𝐦𝐞𝐚𝐧 = 𝟎 + 𝟏 + 𝟐 + 𝟏 + 𝟏𝟒 + 𝟏𝟓 + 𝟏 + 𝟏𝟓 + 𝟏𝟐 𝟗 = 𝟔𝟏 𝟗 = 𝟔 𝟕 𝟗 → 𝟕 𝒎𝒆𝒂𝒏 = 𝟏𝟓 + 𝟏𝟐 + 𝟏𝟐 + 𝟑 + 𝟑 + 𝟐 + 𝟎 + 𝟎 + 𝟏 𝟗 = 𝟒𝟖 𝟗 = 𝟓 𝟑 𝟗 → 𝟓 The image has a 4 - bit scale with nonnegative integer values. Thus, the obtained result has to be round ed to the closest integer value. Answer New values of pixels (2,2) and (3,4) obtained by average filtering with the sy m metric mask of the size 3x3 , cont ain ing constant coefficients are 7 and 5 , respectively Ad b) Similarly to the previous case, the median s for the val u es of pixels of surroundings of the pixels determined by the window placed in subsequent image points are calculated. It requires to sort the value s and to take the middle one as depicted in Fig. 3 : 0 1 2 1 14 15 1 15 12 0 1 1 1 2 12 14 15 15 15 12 12 3 3 2 0 0 1 0 0 1 2 3 3 12 12 15 Fig . 3 Answer New values of pixels (2,2) and (3,4) obtained by median filter with the sy m metric window of the size 3 × 3 , are 2 and 3 , respectively Ad c) The Sobel mask s are defined as follows: 𝑀𝐻 = [ − 1 0 1 − 2 0 2 − 1 0 1 ] 𝑀𝑉 = [ − 1 − 2 − 1 0 0 0 1 2 1 ] The mask s are of the same size as in the previous cases. Thus, the neighbourhood of conv olu tion filtering is the same as presented in Fig. 2. The sums of products of masks coefficients and correspo nd ing pixel values are determined and they form a component of th e gradient. The gradient magnitude is the sum of absolute values of its components: 𝐺 𝑥 ( 2 , 2 ) = ( − 1 ) ∙ 0 + 0 ∙ 1 + 1 ∙ 2 + ( − 2 ) ∙ 1 + 0 ∙ 14 + 2 ∙ 15 + ( − 1 ) ∙ 1 + 0 ∙ 15 + 1 ∙ 12 = 41 Median Sorting Sorting Median 𝐺 𝑌 ( 2 , 2 ) = ( − 1 ) ∙ 0 + ( − 2 ) ∙ 1 + ( − 1 ) ∙ 2 + 0 ∙ 1 + 0 ∙ 14 + 0 ∙ 15 + 1 ∙ 1 + 2 ∙ 15 + 1 ∙ 12 = 39 | 𝐺 ( 2 , 2 ) | = | 𝐺 𝑥 ( 2 , 2 ) | + | 𝐺 𝑦 ( 2 , 2 ) | = 41 + 39 = 80 𝐺 𝑥 ( 3 , 4 ) = ( − 1 ) ∙ 15 + 0 ∙ 12 + 1 ∙ 12 + ( − 2 ) ∙ 3 + 0 ∙ 3 + 2 ∙ 2 + ( − 1 ) ∙ 0 + 0 ∙ 0 + 1 ∙ 1 = − 4 𝐺 𝑌 ( 3 , 4 ) = ( − 1 ) ∙ 15 + ( − 2 ) ∙ 12 + ( − 1 ) ∙ 12 + 0 ∙ 3 + 0 ∙ 3 + 0 ∙ 2 + 1 ∙ 0 + 2 ∙ 0 + 1 ∙ 1 = − 50 | 𝐺 ( 3 , 4 ) | = | 𝐺 𝑥 ( 3 , 4 ) | + | 𝐺 𝑦 ( 3 , 4 ) | = 54 Attention: The obtained values are out side of the 4 - bit scale of the image. However, in the task, there is no information about norma lization to process. Answer Calculated gradient magnitude on the basis of the Sobel masks for pixels (2,2) and (3,4) are 80 and 54 , respectively Ad d) The 8 - bit scale contains the value s of the ran g e (0,255). Mini mal and maximal values of the analyzed image are 0 and 15 , respectively. Hence 𝑁𝑜𝑟𝑚 ( 2 , 2 ) = 255 ∙ 14 − 0 15 − 0 = 238 𝑁𝑜𝑟𝑚 ( 3 , 4 ) = 255 ∙ 3 − 0 15 − 0 = 51 Answer As a result of the no rmalizati on of th e image depicted in Fig. 1 to the 8 - bit scale, values of the pixels (2,2) and (3,4) are 238 and 51 , respectively Task 2 For the image prese nted in Fig. 1 pe r form histogram equalization. Solution The histogram of the i mage is computed and utilized to determine transition function. The f ollowing formula is used: 𝑇 ( 𝑘 ) = ∑ 𝑛 𝑖 𝑛 ∙ 15 𝑘 𝑖 = 0 where n is the total num b er of pixels in the image, in our case 25 ( 5 ∙ 5 ) Grayscale value (i) Number of pixels (n i ) Transition function 𝑇 ( 𝑘 ) 0 5 𝑇 ( 0 ) = 5 25 ∙ 15 = 3 1 9 𝑇 ( 1 ) = 5 + 9 25 ∙ 15 = 8 10 25 → 8 2 3 𝑇 ( 2 ) = 5 + 9 + 3 25 ∙ 15 = 10 5 25 → 10 3 2 𝑇 ( 3 ) = 5 + 9 + 3 + 2 25 ∙ 15 = 11 10 25 → 11 4 0 𝑇 ( 4 ) = 5 + 9 + 3 + 2 + 0 25 + ∙ 15 = 11 10 25 → 11 5 0 𝑇 ( 5 ) = 5 + 9 + 3 + 2 + 0 + 0 25 ∙ 15 = 11 10 25 → 11 6 0 𝑇 ( 6 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 25 ∙ 15 = 11 10 25 → 11 7 0 𝑇 ( 7 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 + 0 25 ∙ 15 = 11 10 25 → 11 8 0 𝑇 ( 8 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 + 0 + 0 25 ∙ 15 = 11 10 25 → 11 9 0 𝑇 ( 9 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 + 0 + 0 + 0 25 ∙ 15 = 11 10 25 → 11 10 0 𝑇 ( 10 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 25 ∙ 15 = 11 10 25 → 11 11 0 𝑇 ( 11 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 25 ∙ 15 = 11 10 25 → 11 12 3 𝑇 ( 12 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 3 25 ∙ 15 = 13 5 25 → 13 13 0 𝑇 ( 13 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 3 + 0 25 ∙ 15 = 13 5 25 → 13 14 1 𝑇 ( 14 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 3 + 0 + 1 25 ∙ 15 = 13 20 25 → 14 15 2 𝑇 ( 15 ) = 5 + 9 + 3 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 3 + 0 + 1 + 2 25 ∙ 15 = 15 Finally, the trans ition function maps the values of the pixels of input and equalized image s : 1 2 3 4 5 1 3 8 10 8 8 2 8 14 15 13 10 3 8 15 13 13 8 4 8 11 11 10 8 5 3 3 3 8 3 Fig. 4 Task 3 In Fig. 5 the binary image is given. With the gr e y color pix el s of the object and with white color pixels of the background are marked. 1 2 3 4 5 1 2 3 4 5 Fig . 5 Based on internal morphologic al gradient determine contours : a) of the horizontal orientation , b) of the vertical orientation. Propose adeq ua te structuring elements, perform calculations and in successive stages present the image in the form of a set. Solution The i mage presented in Fig. 5 can be represented as a set A which contains coordinates of the object pixels : 𝐴 = { ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) } The i nternal morphological gradient of the image A calculated by structuring element B is defined a s the difference between input image A and eroded image A with structuring element B ( 𝐸 ( 𝐴 , 𝐵 ) ) : 𝐺 𝑖𝑛𝑡𝑒𝑟𝑛𝑎𝑙 ( 𝐴 , 𝐵 ) = 𝐴 \ 𝐸 ( 𝐴 , 𝐵 ) where erosion E(A,B) is a common part of translations of image A by subse quent opposite vectors of struct ur ing element B : 𝐸 ( 𝐴 , 𝐵 ) = ⋂ ( 𝐴 − ℎ ) ℎ ∈ 𝐵 Ad a) For detecting the horizontal contours the following stru c turing element can be used : 𝐵 1 = | 1 1 1 | = { ( 0 , − 1 ) , ( 0 , 0 ) , ( 0 , 1 ) } Hence, translated images by the opposite vectors of struct u ring element are determ ined : 𝐴 − ( 0 , − 1 ) = { ( 2 , 3 ) , ( 2 , 4 ) , ( 2 , 5 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 3 , 5 ) , ( 4 , 3 ) , ( 4 , 4 ) , ( 4 , 5 ) } 𝐴 − ( 0 , 0 ) = { ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) } 𝐴 − ( 0 , 1 ) = { ( 2 , 1 ) , ( 2 , 2 ) , ( 2 , 3 ) , ( 3 , 1 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 4 , 1 ) , ( 4 , 2 ) , ( 4 , 3 ) } a nd their product is calculated : 𝐸 ( 𝐴 , 𝐵 1 ) = { ( 2 , 3 ) , ( 2 , 4 ) , ( 2 , 5 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 3 , 5 ) , ( 4 , 3 ) , ( 4 , 4 ) , ( 4 , 5 ) } ∩ { ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) } ∩ { ( 2 , 1 ) , ( 2 , 2 ) , ( 2 , 3 ) , ( 3 , 1 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 4 , 1 ) , ( 4 , 2 ) , ( 4 , 3 ) } = { ( 2 , 3 ) , ( 3 , 3 ) , ( 4 , 3 ) } The result of the erosion is also depicted in Fig. 6. 1 2 3 4 5 1 2 3 4 5 Fig . 6 In the last stage , the difference between A and E(A,B 1 ) is calculated: 𝐺 𝑖𝑛𝑡𝑒𝑟𝑛𝑎𝑙 ( 𝐴 , 𝐵 1 ) = 𝐴 \ 𝐸 ( 𝐴 , 𝐵 1 ) = { ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) } \ { ( 2 , 3 ) , ( 3 , 3 ) , ( 4 , 3 ) } = = { ( 2 , 2 ) , ( 2 , 4 ) , ( 3 , 2 ) ( 3 , 4 ) , ( 4 , 2 ) ( 4 , 4 ) } Determined horizontal conto ur s are shown in Fig. 7. 1 2 3 4 5 1 2 3 4 5 Fig . 7 Ad b ) For detecting the vertical contours following stru c turing element can be used : 𝐵 2 = | 1 1 1 | = { ( − 1 , 0 ) , ( 0 , 0 ) , ( 1 , 0 ) } The processing is analogous like in the previous case: 𝐴 − ( − 1 , 0 ) = { ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) , ( 5 , 2 ) , ( 5 , 3 ) , ( 5 , 4 ) } 𝐴 − ( 0 , 0 ) = { ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) } 𝐴 − ( 1 , 0 ) = { ( 1 , 2 ) , ( 1 , 3 ) , ( 1 , 4 ) , ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) } 𝐸 ( 𝐴 , 𝐵 2 ) = { ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) , ( 5 , 2 ) , ( 5 , 3 ) , ( 5 , 4 ) } ∩ { ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) } ∩ { ( 1 , 2 ) , ( 1 , 3 ) , ( 1 , 4 ) , ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) } = { ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) } 1 2 3 4 5 1 2 3 4 5 Fig . 8 𝐺 𝑖𝑛𝑡𝑒𝑟𝑛𝑎𝑙 ( 𝐴 , 𝐵 2 ) = 𝐴 \ 𝐸 ( 𝐴 , 𝐵 2 ) = { ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) } \ { ( 3 , 2 ) , ( 3 , 3 ) , ( 3 , 4 ) } = = { ( 2 , 2 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 4 , 2 ) , ( 4 , 3 ) , ( 4 , 4 ) } 1 2 3 4 5 1 2 3 4 5 Fig . 9 Task 4 For the image from Fig. 10 compute frequency domain representation on the basis of the Fourier tr ansform. 0 1 0 1 0 1 0 1 Fig . 10 The Fourier transform for a two - dimensional discrete image is defined by the following formula : 𝐹 ( 𝑘 , 𝑙 ) = 1 √ 𝑤 ∙ ℎ ∙ ∑ ∑ 𝑓 ( 𝑥 , 𝑦 ) ∙ 𝑒 − 𝑖 ∙ 2 𝜋 ∙ ( 𝑘 ∙ 𝑥 𝑤 + 𝑙 ∙ 𝑦 ℎ ) ℎ − 1 𝑦 = 0 𝑤 − 1 𝑥 = 0 Because function 𝑓 ( 𝑥 , 𝑦 ) for pix el s (0, 1) and (1,0) has a zero value and resolution 𝑤 × ℎ of the image is 2 × 2, the formula is simplified: 𝐹 ( 𝑘 , 𝑙 ) = 1 2 ∙ ( 𝑓 ( 0 , 0 ) ∙ 𝑒 0 + 𝑓 ( 1 , 1 ) ∙ 𝑒 − 𝑖 ∙ 2 𝜋 ∙ ( 𝑘 ∙ 1 2 + 𝑙 ∙ 1 2 ) ) = 1 2 ∙ ( 1 + ∙ 𝑒 − 𝑖 ∙ 2 𝜋 ∙ ( 𝑘 + 𝑙 2 ) ) Hence , the values 𝐹 ( 𝑘 , 𝑙 ) for successive pix e l s ( 𝑘 , 𝑙 ) : 𝐹 ( 0 , 0 ) , 𝐹 ( 1 , 0 ) , 𝐹 ( 0 , 1 ) and 𝐹 ( 1 , 1 ) are calculated : 𝐹 ( 0 , 0 ) = 1 2 ∙ ( 1 + 𝑒 − 𝑖 ∙ 2 𝜋 ∙ ( 0 + 0 2 ) ) = 1 2 ∙ ( 1 + 𝑒 0 ) = 1 𝐹 ( 1 , 0 ) = 1 2 ∙ ( 1 + 𝑒 − 𝑖 ∙ 2 𝜋 ∙ ( 1 + 0 2 ) ) = 1 2 ∙ ( 1 + 𝑒 − 𝑖 ∙ 𝜋 ) = 1 2 ∙ ( 1 + cos ( − 𝜋 ) + 𝑖 ∙ sin ( − 𝜋 ) ) = = 1 2 ∙ ( 1 − 1 + 𝑖 ∙ 0 ) = 0 𝐹 ( 0 , 1 ) = 1 2 ∙ ( 1 + 𝑒 − 𝑖 ∙ 2 𝜋 ∙ ( 0 + 1 2 ) ) = 1 2 ∙ ( 1 + 𝑒 − 𝑖 ∙ 𝜋 ) = 𝐹 ( 1 , 0 ) = 0 𝐹 ( 1 , 1 ) = 1 2 ∙ ( 1 + 𝑒 − 𝑖 ∙ 2 𝜋 ∙ ( 1 + 1 2 ) ) = 1 2 ∙ ( 1 + 𝑒 − 𝑖 ∙ 2 𝜋 ) = 1 2 ∙ ( 1 + cos ( − 2 𝜋 ) + 𝑖 ∙ sin ( − 2 𝜋 ) ) = = 1 2 ∙ ( 1 + 1 + 𝑖 ∙ 0 ) = 1 The frequency domain rep r esentation of the image fro m Fig. 10 obtained by the Fourier transform is depicted in Fig. 11. 0 1 0 1 0 1 0 1 Fig . 11 Se gmentation of biomedical images. Task 5 In the following fi gure color image is givem. It utlizes RGB color space and it has resolution 3x3: 1 2 3 1 (30,101,200) (32,100,202) (15,80,187) 2 (45,89,178) (234,12,10) (245,1,8) 3 (12,103,200) (255,30,20) (210,40,20) Rys. 16 Perform segmentation of the image on the basis of clustering their pixel values by ISODATA algorithm. Assume initial division: 1 2 3 1 Cluster 1 Cluster 2 Cluster 1 2 Gr oup 2 Gr oup 1 Cluster 2 3 Cluster 1 Cluster 2 Cluster 1 Solution A t raining set is prepared. It contains RGB values of successive pixels : i Coordinates Color Initial group 1 (1,1) (30,101,200) Cluster 1 2 (1,2) (45,89,178) Cluster 2 3 (1,3) (12,103,200) Cluster 1 4 (2,1) (32,100,202) Cluster 2 5 (2,2) (234,12,10) Cluster 1 6 (2,3) (255 ,30,20) Cluster 2 7 (3,1) (15,80,187) Cluster 1 8 (3,2) (245,1,8) Cluster 2 9 (3,3) (210,40,20) Cluster 1 Clustering of the pixels values is carried out. Ini t ial division matrix : 𝑈 0 = [ 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ] Graphical vi sualization of initial division is depicted in the following figure. ( red color – cluster 1, green color – cluster 2 ; ‘X’ symbols denote clusters centroids Cluster centroids v 1 and v 2 are calcula ted: 𝑣 1 = ( 30 , 101 , 200 ) + ( 12 , 103 , 200 ) + ( 234 , 12 , 10 ) + ( 15 , 80 , 187 ) + ( 210 , 40 , 20 ) 5 = ( 100 2 , 67 2 , 123 4 ) 𝑣 2 = ( 45 , 89 , 178 ) + ( 32 , 100 , 202 ) + ( 255 , 30 , 20 ) + ( 245 , 1 , 8 ) 4 = ( 144 25 , 55 , 102 ) Square distances of the pixels to cluster centro id s are calculated and new clusters ar e determined: k Coordinates Color d 1 k d 2k New cluster 1 (1,1) (30,101,200) 11 938.34 24 773.06 Cluster 1 2 (1,2) (45,89,178) 6 503.44 16 782.56 Cluster 1 3 (1,3) (12,103,200) 14 928.44 29 398.06 Cluster 1 4 (2,1) (32,100,202) 11 905.04 24 625.06 Cluster 1 5 (2,2) (234,12,10) 33 809.04 18 368.06 Cluster 2 6 (2,3) (255 ,30,20) 36 349.04 19 614,56 Cluster 2 7 (3,1) (15,80,187) 11 467.84 24 555.56 Cluster 1 8 (3,2) (245,1,8) 38 666.64 21 902.56 Cluster 2 9 (3,3) (210,40,20) 23 487.44 11 272.25 Cluster 2 𝑈 1 = [ 1 1 1 1 0 0 1 0 0 0 0 0 0 1 1 0 1 1 ] Graphical vi sualisation of the new division: Similarly , the next iteration of the I SODATA algorithm is carried out : 𝑣 1 = ( 26 8 , 94 6 , 193 4 ) 𝑣 2 = ( 236 25 , 20 75 , 14 5 ) k Coordinates Color d 1 k d 2k New cluster 1 (1,1) (30,101,200) 97.76 83 286.31 Cluster 1 2 (1,2) (45,89,178) 599.76 67 871.31 Cluster 1 3 (1,3) (12,103,200) 333.16 91 351.31 Cluster 1 4 (2,1) (32,100,202) 130.16 83 052.81 Cluster 1 5 (2,2) (234,12,10) 83 390.16 100.8125 Cluster 2 6 (2,3) (255 ,30,20) 86 773.36 476.8125 Cluster 2 7 (3,1) (15,80,187) 393.36 82 107.81 Cluster 1 8 (3,2) (245,1,8) 90 754.36 513.3125 Cluster 2 9 (3,3) (210,40,20) 66 810.96 1076.813 Cluster 2 𝑈 2 = [ 1 1 1 1 0 0 1 0 0 0 0 0 0 1 1 0 1 1 ] The second iteration has not cause d any changes. Thus, the working of ISODATA is terminated. The final result is obtained. Answer Segmented i m age obtained in the results of clustering RGB pixels values by ISODATA algorithm is the following: 1 2 3 Task 6 Following monochromatic image is given: 1 2 3 4 5 1 234 123 186 193 227 2 211 143 195 172 221 3 212 34 12 13 17 4 198 14 213 221 198 5 201 17 210 212 199 Pe r form botHat operat i on with the structuring el ement 𝐵 = | 1 1 1 | Solution BotHat opera t ion determi n es the differen ce between an image obtained by closing operation and the input one. The c losing is ach ieved by a dilation followed by an erosion. Dilation : 1 2 3 4 5 1 234 234 193 227 227 2 211 211 195 221 221 3 212 212 34 17 17 4 198 213 221 221 221 5 201 210 212 212 212 Erosion (closing): 1 2 3 4 5 1 234 193 193 193 227 2 211 195 195 195 221 3 212 34 17 17 17 4 198 198 213 221 221 5 201 201 210 212 212 Difference with the input image ( botHat ) : 1 2 3 4 5 1 0 70 7 0 0 2 0 52 0 23 0 3 0 0 5 4 0 4 0 184 0 0 23 5 0 184 0 0 13 Stereovision and 3D reconstruction Task 7 Projection matrix P is given : 𝑃 = [ 1 0 1 4 0 1 3 5 0 0 1 1 ] Deter m ine image coordinates of 3D point 𝑋 = [ 2 1 3 ] Solution Homogen o us coordinates 𝑋 ̿ of the point X: 𝑋 ̿ = [ 2 1 3 1 ] Homogenous image coordinates : 𝑠 ∙ 𝑥 ̿ = 𝑃 ∙ 𝑋 ̿ = [ 1 0 1 4 0 1 3 5 0 0 1 1 ] ∙ [ 2 1 3 1 ] = [ 9 15 4 ] Hence s=4 and 𝑥 ̿ = [ 9 4 15 4 1 ] = [ 2 25 3 75 1 ] Answer Image coordinates of the point X for camera descri bed by the projection matrix P are 𝑥 = [ 2 25 3 75 ] Task 8 T wo perpendicular cameras with projection matr ic es P 1 i P 2 are given : 𝑃 1 = [ 1 0 0 0 0 1 0 0 0 0 0 1 ] 𝑃 2 = [ 1 0 0 0 0 0 1 0 0 0 0 1 ] A point in 3D global system has image coordinates (10,1 0) in the image of the first camera and (10,20) of the second camera. What are its 3D coordinates? Using properties of the projection 𝑠 ∙ 𝑥 ̿ = 𝑃 ∙ 𝑋 ̿ , l Inear equations for both cameras are prepared: 𝑠 1 ∙ 𝑥 1 = 𝑠 1 ∙ 10 = 𝑋 𝑠 1 ∙ 𝑦 1 = 𝑠 1 ∙ 10 = 𝑌 𝑠 1 = 1 𝑠 2 ∙ 𝑥 2 = 𝑠 2 ∙ 10 = 𝑋 𝑠 2 ∙ 𝑦 2 = 𝑠 2 ∙ 20 = 𝑍 𝑠 2 = 1 where (x 1 , y1) i (x2, y2) are image cooridnates - (10, 10) and (10,20) respecively. Thus, it can be noticed that (X,Y,Z)=(10,10,20). Answer 3D coordinates of the analyzed point are (10,10,20).