COMP 4500-Computer Vision and Image Processing Lab Report- Sohar University .

Introduction to MATLAB Digital Image Processing Steps and Discussion: -First step : Write row vector v= 24 66 4 2 9 Figure 1: Creating Row Vector ( v) As shown in figure 1=> The syntax is as follows v= [24 66 4 2 9]. A row vector can be thought of as a 1*N-dimensional array. The output is a Row Vector V= 24 66 4 2 9 1 -Second step: Display the fourth element Figure 2: Displaying fourth element of Row Vector (v) As shown in figure 2 =>We use the following syntax to display the fourth element of Row Vector v [ v (4) ] . A single index value can be used to access the items of a Row Vector. The first element of a vector is v (1), the second element is v (2), and so on. As a result, we have: Ans= 2 2 – Third step: Change the row vector to column vector Figure 3: Converting Row Vector v to Column Vector (w) As shown in figure 3 => The basic syntax for converting Row Vector v to Column Vector w is w=v.’ To transform a row vector to a column vector, use the transpose operator (.’). As a result, we have: W= 24 66 4 2 9 3 – Fourth step: Display the first three element of v Figure 4: Displaying first three elements of Row vector (v) As shown in figure 4 => to make the first three components visible We use the following syntax for Row Vector v [ v (1:3) ]. The first three elements of Row Vector v. are 24, 66, and 4. As a result, we have: ans = 24 66 4 4 – Fifth step: Display the index will count started at the last element decreased by 2 and stop when it is reached the first element Figure 5 : Displaying last element of Row Vector v which is decreased by 2 until it reaches first element As shown in figure 5 => We use the basic syntax to display the last element Row Vector v and then decrease by two elements until we reach the first element: v(end: -2:1) The index count begins at the final element, decreases by two, and ends at the first element. As a result, we have: ans= 9 4 24 5 – Sixth step: Write 3×3 matrix A= 12 52 30 7 9 2 44 6 11 Figure 6: Creating 3*3 Matrix (A) As shown in figure 6 => A= [12 52 44; 30 7 6; 9 2 11] is the syntax for creating the needed Matrix. Matrixes can be represented as a series of row vectors separated by semicolons and enclosed by squared brackets. The syntax produces the following result: A= 12 52 44 30 7 6 9 2 11 6 – Seventh step: Write submatrix T2 which contain rows 1&2 and columns 1,2,3 of A Figure 7: Creating Sub-Matrix T2 contain Rows 1, 2 and Columns 1, 2, 3 of Matrix (A) As shown in figure 7 => By giving a vector of values for both the row and column indices, the T2 Sub-Matrix can be retrieved. The needed Sub-Matrix is built using the syntax indicated in figure 7 => T2=A ([1 2], [1 2 3]) . T2 is the Sub-Matrix containing rows 1 and 2 as well as columns 1, 2 and 3. The syntax produces the following result: T2= 12 52 44 30 7 6 7 – Eighth step: Write submatrix T3 which contain the entire 3rd column only of A Figure 8 : Creating Sub-Matrix T3 contain entire 3rd column of Matrix (A) As shown in figure 8 => A colon in the column index position selects all of a Matrix’s columns. The needed Sub-Matrix is produced using the syntax: T3= A(: ,3), as illustrated in figure (8). The syntax produces the following result: T3= 44 6 11 8 – Ninth step: Write submatrix T4 which contain the second row only of A Figure 9 : Creating Sub-Matrix T4 containing entire second row of Matrix (A) As shown in figure 9=> When a colon appears in the Row index position, it picks all of the rows in a Matrix. The needed Sub-Matrix is formed using the syntax: T4= A(2,:) , as seen in Figure 9. The syntax produces the following result: T4= 30 7 6 9 – Step tenth: Create a copy D of matrix A Figure 10 : Create a copy Matrix D of Matrix (A) As shown in figure 10 => The syntax for making a copy of a matrix is D=A; or when I want to show all of matrix D, I write D =A In addition, I will write in logical order and set the third column to one as follows D = logical ([0 0 1; 0 0 1; 0 0 1]) the result, D= 0 0 1 0 0 1 0 0 1 10 – Eleventh step: Assign zero to all elements in the 3rd column of D Figure 11 : Assign zero to all elements in 3rd Column of Matrix (D) As shown in figure 11=> A colon in the column index position selects all of a Matrix’s columns. Figure 11 shows how to use the syntax D (:,3) = 0. The Matrix is represented by the letter D. The value 0 will be assigned to all entries in D’s third column using this approach. The syntax produces the following result: 11 D= 12 52 0 30 7 0 9 2 0 But in logical do A(D) then, A(D)= [0 0 0]. 12 – Twelfth step: Using Hilbert matrix (5) Figure 12 : Using Hilbert 5×5 Matrix As shown in figure 12=> A linear indexing expression is one that indexes a matrix or higher-dimensional array with a single subscript. We’ll use a 5×5 Hilbert matrix to demonstrate the notion, as illustrated in figure 12 . The needed Hilbert is built using the syntax: H=hilb (5) 13 H= 1.00000 0.50000 0.33333 0.25000 0.20000 0.50000 0.33333 0.25000 0.20000 0.16667 0.33333 0.25000 0.20000 0.16667 0.14286 0.25000 0.20000 0.16667 0.14286 0.12500 0.20000 0.16667 0.14286 0.12500 0.11111 – Thirteenth step: Display the element #17 Figure 13 : Display the element number 17 As shown in figure 13=> Using the syntax H=(17) , display the element number 17 The syntax produces the following result: ans = 0.20000 14 – Fourteenth step: Here the pixel values at these row and column coordinates: Row= [2 1 5]; Col= [1 3 4]; to extract the desired pixel value Figure 14 : The pixel values at given Row and Column As shown in figure 14 => As demonstrated in Figure 14, required pixel values are retrieved using the Syntax: Row r= [2 1 5] and Column c= [1 3 4]. r= [2 1 5]; c= [1 3 4]; 15 H (r,c) ans= 0.50000 0.25000 0.20000 1.00000 0.33333 0.25000 0.20000 0.12500 0.14286 – Fifteenth step: Write the linear indexing equation Figure 15 : The linear indexing equation As shown in figure 15 => As we learned the following is the formula for the linear indexing equation: M = size(H, 1); linear_indices = M*(c − 1) + r linear_indices = 2 11 20 16 H(linear_indices) = M*(c − 1) + r = 2 linear indices of H is 0.50000 = M*(c − 1) + r = 11 linear indices of H is 0.33333 = M*(c − 1) + r = 20 linear indices of H is 0.12500 ans= Conclusion 0.50000 : 0.33333 0.12500 We noticed that in this experiment is how to use and how to deal with the main concepts of processing and understanded it include the indexing matrices, indexing vetoers and logical indexing on Octave. In short, this lap we used in work effectively without any problems or facing in doing and implemented this lap. 17 H(linear_indices) = M*(c-1) +r= 2 linear indices of H is 0.50000 = M*(c-1) +r= 11 linear indices of H is 0.33333 = = M*(c-1) +r= 20 linear indices of H is 0.12500 ans= 0.50000 0.33333 0.12500 We noticed that in this experiment is how to use and how to deal with the main concepts of processing and understanded it include the indexing matrices, indexing vetoers and logical indexing on Octave. In short, this lap we used in work effectively without any problems or facing in doing and implemented this lap TTIVI SP: WINU TIIU IMIOAI MUVAINIG vquanon Octave File Edit Debug Window Help News Current Directory: C:\Users\HP File Browser х Command Window C:/Users/Hp >> H- hilb(5) Name .config 3D Objects > 2 Contacts > Desktop > Documents >Downloads Workspace 1.00000 0.50000 0.33333 0.25000 0.20000 0.50000 0.33333 0.25000 0.20000 0.16667 0.33333 0.25000 0.20000 0.16667 0.14286 0.25000 0.20000 0.16667 0.14286 0.12500 0.20000 0.16667 0.14286 0.12500 0.lllll >> H(17) ans = 0.20000 >> r[2 i 5); >> c=(1 3 4); >> H(r, c) ans = Filter D Name Class Dimension Value Attribute double 5x 5 (1, 0.50000, 0.33… H M double 1×1 5 0.50000 1.00000 0.20000 0.25000 0.33333 0.14286 182932 0.20000 0.25000 0.12500 ans double 1×3 c double 1×3 [0.50000, 0.3333… (1,3,4] [2, 11,20] [2, 1,5] linear_indices double 1×3 >> M =size (H, 1); >> linear_indices – M* (C-1) +r linear_indices = r double 1×3 2 11 20 Command History Filter D >> H(linear_indices) ans- H= hilb(5) H(17) 0.50000 0.33333 0.12500 Figure 15
: The linear indexing equation As shown in figure 15 => As we learned the following is the formula for the linear indexing equation: M = size(H, 1); = linear_indices = M*(c − 1) +r linear indices = = 2. 11 20 16 – Fourteenth step: Here the pixel values at these row and column coordinates: Row= [2 1 5]; Col= [1 3 4]; to extract the desired pixel value Octave File Edit Debug Window Help News Current Directory: C:\Users\Hp File Browser Command Window C:/Users/Hp >> H=hilb(5) H = A Name .config > 3D Objects > 2 Contacts Desktop Documents >Downloads Workspace Filter o 1.00000 0.50000 0.33333 0.25000 0.20000 0.50000 0.33333 0.25000 0.20000 0.16667 0.33333 0.25000 0.20000 0.16667 0.14286 0.25000 0.20000 0.16667 0.14286 0.12500 0.20000 0.16667 0.14286 0.12500 0.lllll 5 x >> r=[2 1 5); >> c=(1 3 4); >> H(r,c) ans = Name Class Dimension Value Attribute А double 3×3 0.50000 1.00000 0.20000 0.25000 0.33333 0.14286 0.20000 0.25000 0.12500 D double 3×3 H double 5×5 >> [12, 52, 44; 30, 7… [12, 52,0; 30, 7, … [1, 0.50000, 0.33… [0.50000, 0.2500… (1,3,4) [2.1,5) ans double 3×3 C double 1×3 r double 1×3 Figure 14 : The pixel values at given Row and Column As shown in figure 14 => As demonstrated in Figure 14, required pixel values are retrieved using the Syntax: Row r= [2 1 5] and Column c= 1 [1 3 4]. r= = [2 1 5]; c= [1 3 4]; 15