Postagens

Mostrando postagens de novembro, 2021

Classical Computer Vision: Edge Detection II - The Canny Edge Detector

Imagem
    This edge detection technique is much newer and more complex than the previous image edge detectors.     Initially, Canny postulated 3 principles for an "ideal" edge detection:      1. Low error rate: an ideal edge detector shouldn't neither miss an edge nor detect anything else  as an edge that is not an edge.     2. Location: the distance between the edge pixels should be the lowest possible     3. Response: the detector shouldn't identify multiple edge pixels when there's only one.     To try to achieve this, Canny used the following process Apply Gaussian filter to smooth the image in order to remove the noise Find the intensity gradients of the image Apply gradient magnitude thresholding or lower bound cut-off suppression to get rid of spurious response to edge detection Apply double threshold to determine potential edges Track edge by hysteresis: Finalize the detection of edges by suppressing all the other e...

Classical Computer Vision: Edge Detection

Imagem
    What is an Edge?           An edge is a continuity break in an image. It represents areas in an image that marks when an object ends and another object starts.     There are a lot of techniques for edge detection, some make use of simple convolution operations while others use more advanced algorithms to perform it.     An edge is a abrupt variation of the image's texture, so m athematically, it is a strong image gradient (strong values of the first derivative)     Edge Detection Algorithms     1. Using Convolution Roberts Sobel Robinson     2. Multistage Gauss Convolution      Canny           3.  Salient Structures detection Sha'aShua     What is Edge Detection?         Edge detection is a "conditioning and simplification" approach, which means that, like previously saw when we talked about pre-...

Classical Computer Vision: The Spatial Domain II - Morphological Transformations

Imagem
   M orphological Transformations are simple operations generally applied to binary images using convolution as a base to transform the image.     T here are two basic operations: erosion and dilation. The other morphological transformations are a composition of those two operations and the image itself.     Erosion     The basic idea of erosion is to "erode" away the boundaries of the "white" image. It works by trying to expand the black area, consuming the foreground image edges. So,    all the pixels near boundary will be discarded depending upon the size of kernel. import numpy as np import skimage import skimage . io as io from skimage . color import rgb2gray from skimage . morphology import erosion import matplotlib . pyplot as plt import cv2 if __name__ == '__main__' : image = skimage .util.invert( rgb2gray ( io . imread ( 'plate.png' ))) plt . imshow ( image , cmap = 'gray' ) plt . show () k...

Classical Computer Vision: The Spatial Domain I - The Convolution Operation

Imagem
     The Spatial Domain for Image Processing is the domain where a pixel is seen as a member of a group of pixels, in opposition to the Value Domain, where a pixel was seen as a unique entity.     Therefore, when we work in the spatial domain, we try to extract geometrical information from the image. We are concerned about borders, segmentation, morphology, filters etc.        The Convolution Operation     What is a convolution?      Mathematically speaking, a convolution is a type of matrix operation involving  two matrices that are generally  bi-dimensional, where one matrix is the image and the other is  the convolution matrix , also known as  the structuring element .     The goal here is to transform the first matrix using the second one as a tool for changing its values.       We could think of the convolution matrix as a piece of code and the image as the input ...

Classical Computer Vision: Similarity Measures in Images

Imagem
 Why Measure Similarity?     One of the most important things we do when looking into an image is classification. We look at something and our brain tries to give it a meaning.     Sometimes, we classify things by inferring it based on something else. Something that is similar  to what we previously know.      The same thing happens to computer vision. Let's imagine that we have an image-A that we know what it is: it's a car. If image-B is another car, but with a different color. Don't we wish that computers, somehow, were able to infer that image-B is also a car, just because it's so similar to A?     Image Similarity tries to tackle with this problem. The goal here is to extract from two images  a comparable rank with which we could say that image-A is probably the same image as B, or at least it's very close to B.      One of the ways to do that is to use algorithms to calculate similarity or image distancing ...

Classical Computer Vision: Value Domain III: Point Operations

Imagem
What is a Point Operation?      We could see the value domain transformations as point operations. A point operation is an operation that modifies a pixel without affecting the neighboring ones. It doesn't change the size, structure or geometry of the image, and also, it isn't based on any particular aspect of the information inside the image. It just acts blindly upon every pixel. Point Operations with Scalars     By using point operations between pixels and scalars, we can make several simple changes in the image, such as modifying  brightness, contrast etc.     As an example of this, let's check the code below: from skimage import io import matplotlib . pyplot as plt def trunc ( px ): if px > 255 : return 255 if px < 0 : return 0 return px def point_op ( image , fn ): for row in range ( 0 , image .shape[ 0 ]): for col in range ( 0 , image .shape[ 1 ]): res = fn...