Guest User

Untitled

a guest
Dec 12th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. Edge Detection
  2.  
  3.  
  4. Basic Convolution for CNN is also known as cross correlation , but the normal nomenclarture that we use is Convolution
  5. since actual mathematical convolution of an input with a filter , along with convolution with the filter
  6. another filter is also convoluted to narrow the output the second filter is the horizontal and vertical inverse of the original filter
  7.  
  8. How is convolution performed?
  9. When we have a filter of sxs and an input of nxn , we start of by taking the sxs filter and placing in the top left corner of the input matrix
  10. and multiplying each number in the sxs with each number that sxs is placed over, all these numbers are then added together and placed in the first element of the output
  11. matrix. the filter is then moved from the top left to one place to the right in matrix until the complete matrix has been convoluted.
  12.  
  13. Filters
  14.  
  15. The Three main filters that are used widely while doing CNN is the sobel filter the scharr filter
  16. and the basic filter.
  17.  
  18. Basic Filter - [[1,0,1],[0,0,0],[-1,0,-1]]
  19. Sobel Filter - [[1,2,1],[0,0,0],[-1,-2,-1]]
  20. Scharr Filter - [[3,10,3],[0,0,0],[-3,-10,-3]]
  21.  
  22. Vertical and Horizontal Filters
  23.  
  24. We can multiply our input matrices with horizontal and vertical filters they provide different outputs in either case. But most commonly used is the
  25. horizontal filters.
  26.  
  27. 2D Convolution
  28.  
  29. Whenever we do edge detection with an input of nxn filter along with a filter sxs the output matrix
  30. we will get is an n - s + 1 matrix output
  31.  
  32. Due to the fact that when we convolute with two matrices and the edges are most of the time diminished while convoluting
  33. we perform an extra step of preprocessing before convolution called padding
  34.  
  35. Padding is adding an extra layer around the input matrix so that the edges around the matrix are not diminished.
  36. To decide on the amount of padding layers needed we calculate this amount with p = (s-1)/2
  37.  
  38. When convoluting a matrix that is padded the output matrix will be equivalent with the input matrix allowing the persitinence of the edges in the matrix
  39. Due to the fact most of the information is lost during normal convolution , by padding we are preserving it.
  40.  
  41. Padded output = n + 2p - s + 1
  42.  
  43. Another method of convolution is called strided convolution
  44. Strided Convolution is basically convolution but instead of moving from the first matrix element we skip by a certain number of strides
  45. Using Strided convolution without padding leads to loss of alot of information hence padding is highly suggsted.
  46.  
  47. 3D Convolution
  48.  
  49. 3D convolution is more of what everyday images require , since all images we process consist of Red , Green and Blue Channel (RBG) therefore
  50. what is more used nowadays is 3D convolution, However converting them to Black and white and making them into a single channel can improve accuracy of our network but
  51. will make it difficult for the model to detect objects based on color.
  52.  
  53. 3D input matrix will be a nxnx3 matrix , therefore the filter it convulutes with will also be a sxsx3 matrix , however the output will remain as a oxo output.
  54. Similar to 2D convolution now the filter consists of 27 values as compared to the 9 values we had in a single filter. Now in 3D convolution
  55. the 27 values is multipled with the first top left part of the input matrix and moved on instead of the 9 values as seen earlier.
  56.  
  57. Incase we decide to multiply the input matrix with several filters , each output would be different and then we would have final output of oxoxnc
  58. where nc is the number of filters we convoluted with.
Add Comment
Please, Sign In to add comment