is the basic binarization technique. It compares each pixel intensity with the user given threshold and sets the pixel to one of the two levels ( for example 0 and 1 ). (i, ) if I (i, ) Threshold Inew j = 0 old j < 1 Otherwise = (Fig 1.1 Original Image) (Fig 1.2 Thresholding applied to entire image) (Fig 1.3 Binarized image with 2 ROI) (Fig 1.4 Binarized image with 4 ROI)
better than the fixed thresholding since it factors the brightness of the local neighbourhood. This helps to isolate the background better. hreshold (i, ) k (i, ) k (i, ) Threshold T new j = 1 * μ j + 2 * σ j + old Where k1 and k2 are user supplied weights (in this assignment implement k1 = k2 = S) mean of the neighbourhood window μ → standard deviation of the neighbour window σ → (i , ) μ = 1 m n * ∑ m −m ∑ n −n I + m j + n σ = √ (i , ) ∑ m −m ∑ n −n I + m j + n − μ Where m and n are the window sizes.
Fixed Thresholding (win size =7, thres=70) (thres=70) Comparison of Variable thresholding vs Fixed thresholding For the same threshold value, Fixed thresholding does not perform well. The edges are not identified in fixed thresholding. Also when increasing the threshold for fixed thresholding the background mixes with the object. The left side images shown with threshold values increased in Fixed implementation. In Fig 2.3b the background mixes with object. Variable thresholding produces better results than fixed thresholding Fig 2.3a Fixed thresh(t=120) Fig 2.3b Fixed thresh (t=150)
to color images as well. Color images are usually represented in 3D color space. RGB is a frequently used representation. Here the implementation is based on the euclidean distance between the user defined color value and pixels in the image. When the distance is less than given threshold, the pixel is set to white and black otherwise. istance d = √(R ) G ) B ) s − Rd 2 + ( s − Gd 2 + ( s − Bd 2 Where R s G s B s Pixel in source image R d B d G d Color given by user (i, ) 0 if distance threshold in RGB channel I j = < 1 otherwise = Fig 3.1a Original Fig 3.2 b Thresholded image (parameters rgb = (60,60,60) threshold = 70)
There are several filters available to implement smoothing (Uniform smoothing, Median smoothing, Weighted smoothing, etc.,) . Gaussian smoothing is one such method which effectively reduces impulse noise. The weights are calculated using 1D gaussian functions, which is then convoluted with the original pixels in the window. The kernel weights are calculated using (x) e f = 1 √2Πσ2 − (x−μ) 1 2σ2 2 The property of the weights is such that they add to 1. The weights are then convoluted with source image. (i, ) I (i , ) IN j = ∑ m=k m=−k ∑ n=k n=−k amn O + m j + n Where > new pixel intensity IN − > original pixel intensity IO − > window size m * n − > Gaussian weight matrix of size m amn − * n Fig 4.1a. Gaussian smoothing applied without edge preservation. The edges are blurred with this approach. (Sigma = 0.9) 5. Edge Preserving Gaussian Smoothing:
other areas of the image. This is implemented using the user given threshold value. (i, ) I (i, ) if |I (i, ) I | threshold INN j = N j N j − O(i,j) < I (i, ) Otherwise = O j here I > New intensity after edge preserving operation W NN − > Pixel intensity after applying gaussian smoothing IN − > original pixel intensity IO − Fig 5.1a. Gaussian smoothing with edge preservation, the edges are more visible now. (Sigma =0.9 and threshold = 50) Some samples of images applied with edge preserving gaussian smoothing Fig 5.1 b (left) (sigma=0.9, threshold=) Fig 5.1 (right) (sigma=0.8, threshold=40) Original Images (Kodak True Color Images: http://r0k.us/graphics/kodak/ )
represents the frequency of pixel intensities the image. Image histogram equalization is a brightness transformation process. Through this process a better contrast is obtained for the image. The aim is to obtain a uniformly distributed brightness over the whole brightness scale. Image Source: http://en.wikipedia.org/wiki/Histogram_equalization 2. Grey Level Equalization Algorithm: 1. construct image histogram (p) g 1.1. For every pixel in M x N region, read each pixel and increase the count of relevant pixel level(255 levels in this case) in (p) g 2. construct cummulative histogram (p) c 2.1. = (p) c (p ) g(p) where p , ...255 g − 1 + = 0 1 3. construct a equalized histogram 3.1. (p) where M is the total number of pixels τ = M N * c(p) 255 * * N 4. obtain the new calculated pixel value by looking up in the equalized histogram (p) τ
less than a given threshold are set to zero. threshold: 60 threshold: 60 Sample Output: 3. Color Equalization 3.1 RGB Channel The histogram equalization is performed on individual RGB channels. This produces Pseudocolor in the image. The process is similar to gray level histogram equalization but applied to individual RGB channels. Red Channel:
HSI channels. This produces Pseudocolor in the image. The image is converted from RGB representation to HSI model using the previous formula and histogram equalization is performed on individual HSI channels and then converted back to RGB representation. Sample Output: Histogram: Hue: Original Equalized
one of the important dimension reduction/ feature extraction step in the preprocessing stage in the image processing pipeline. Edges contain important information about the important object or geometric shape in the image. There are many operators for edge detection, among them sobel operator is dealt in this assignment. Other operators include prewitt, roberts, canny, etc., Sobel Operator has two 3 X 3 kernels, one for along the x and y direction. Each kernel is convolved with the original image to find the gradient intensity along x and y direction respectively. The magnitude of the edge is given by The gradient direction is given by Formula Src: http://en.wikipedia.org/wiki/Sobel_operator Gray scale edge detection: Several gray scale images were convoluted with Sobel operator to find the edges. a) Original Image b) Edge amplitude image
on individual channels does not provide the desired results. This is a obvious behaviour since edges are defined by the changes in brightness intensities. RGB channels capture the color frequency better than pixel intensities. a) Original Image b) Red channel amplitude image c) Green channel amplitude image d) Blue Channel amplitude image 2) On Intensity channel The RGB color image is transformed to HSI and edge detection is performed on the Intensity channel. This provides the desired effect as compared to edge detection on RGB channels.
edges quite well. The variations in light are captured well by the intensity channel. Other samples: a) Original Image b) Edge amplitude image on Intensity Channel
is used to find geometric shapes(lines, circles and ellipses). Random shapes can be found using randomized hough transformation technique.The idea is to transform the image points to a parameter space (a,b,r) when the equation of line is given by (xa) 2 + (yb) 2 = r 2 Where x,y < Image edge points a,b < center of the circle r < radius The hough space is represented by a accumulator array and each pixel(image point), it is represented as a circle in the hough space, and there are number of circles created. A voting technique is used, where the circles intersect. This done by incrementing the accumulator array. Algorithm: • The 3d accumulator [a][b][r] space is set to 0. • For each(edge point in image(i, j)): Increment all cells which according to the equation of a circle( (ia)² + (jb)² = r² ) could be the center of a circle, for a,b,r values in the accumulator • Search for the local maxima cells, these cells represent the center of circle. • Using the local maxima, the circle is drawn in the original image using parametric equation x = a + rcos(theta) y = b + rsin(theta) since we have a,b,r values from the local maxima. Below is the sample of hough transform applied to image to find circles within radius 73 to 76
given for the circle to the detected. Otherwise if the exact radius is known, the accumulator space is converted to a two dimensional matrix. Also the threshold parameter for calculating the local maxima should be tuned to get the desired results and circle to be detected.
Transforms: Fourier function transforms the image from spatial domain to frequency domain. It decomposes the image into sine and cosine components. Fourier transforms has applications in image filtering and image compression. 2D fourier transform is given by 2D Inverse fourier transform is given by Original image Fourier domain amplitude image
and allows low frequencies to pass through. This removes noise but also blurs the image and edges. Low pass vs Regular smoothing: Low pass filter does not produce the ideal smoothing effect it causes the ringing effect High Pass Filter: High pass filter allows high frequencies to pass through. Examples are high frequencies are edges where pixel intensities change rapidly. High pass filter alone is not sufficient for edge detection. Edge detection is possible when the fourier domain is multiplied with edge detection kernel like Sobel, Prewitt and then applying Inverse fourier transform
of frequency to pass through. It keeps the medium frequencies. Band Stop Filter: Band pass filter cuts off a particular interval of frequency and allows the remaining frequency to pass through. Color Images: Fourier transforms were applied to RGB images by first converting them to HSI model. Then fourier transform function was applied to Intensity channel and then converted back from HSI to RGB model. Both fourier and inverse fourier transform were applied. Images obtained from microscope were used.
http://www.fftw.org/ . This provides faster implementation of the fourier transform with runtime of O(N log N). References: 1. http://docs.opencv.org/doc/tutorials/core/discrete_fourier_transform/discrete_fourier_tr ansform.html 2. http://www.fftw.org/ 3. http://homepages.inf.ed.ac.uk/rbf/HIPR2/fourier.htm