Image Processing: Digital Assignment - 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Image Processing

Digital Assignment - 2
Slot: C1 + TC1

Submitted by

Name : Shivam Taparia


Registration ID: 17BCE2377

Submitted to

Prof. ANISHA M. LAL


Application chosen: This digital assignment has application in Aerial surveillance. Aerial
surveillance or other such applications can be a challenging task in hazy or foggy conditions.
Outdoor images taken in bad weather (e.g., foggy or hazy) usually lose contrast and fidelity. The
technique of image haze removal will beneficial for image understanding and computer vision
[1]. Image segmentation is the classification of an image into different groups. This can be done
by using clustering algorithms [2]. There are different methods and one of the most popular
methods is k-means clustering algorithm [2]. K-means clustering algorithm is an unsupervised
algorithm and it is used to segment the interest area from the background. This assignment also
has applications such as aerial imagery, image classification, image/video retrieval, remote
sensing and video analysis and recognition.

Key Terms—Dehazing, defog, image restoration, depth restoration, image-segmentation, k-


means clustering.

Input image: (Hazy or foggy image)

input.jpg
dehazed.jpg (input for segmentation)
Implementation code: (Written in python)

import numpy as np
import cv2
import sys

image1 = cv2.imread(sys.argv[1])
image2 = cv2.imread(sys.argv[2])
image3 = cv2.imread(sys.argv[3])

Z1 = image1.reshape((-1,3))
Z2 = image2.reshape((-1,3))
Z3 = image3.reshape((-1,3))

Z1 = np.float32(Z1)
Z2 = np.float32(Z2)
Z3 = np.float32(Z3)

criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0)

K1 = 5
K2 = 7
K3 = 7

# Apply kmeans
compactness_image1,clusterLabel_image1,clusterCenter_image1=cv2.kmeans(Z1,K1,
None,criteria,10,cv2.KMEANS_RANDOM_CENTERS)
compactness_image2,clusterLabel_image2,clusterCenter_image2=cv2.kmeans(Z2,K2,
None,criteria,10,cv2.KMEANS_RANDOM_CENTERS)
compactness_image3,clusterLabel_image3,clusterCenter_image3=cv2.kmeans(Z3,K3,
None,criteria,10,cv2.KMEANS_RANDOM_CENTERS)
# Now convert back into uint8, and make original image
clusterCenter_image1 = np.uint8(clusterCenter_image1)
res_image1 = clusterCenter_image1[clusterLabel_image1.flatten()]
clustered_image1 = res_image1.reshape((image1.shape))

clusterCenter_image2 = np.uint8(clusterCenter_image2)
res_image2 = clusterCenter_image2[clusterLabel_image2.flatten()]
clustered_image2 = res_image2.reshape((image2.shape))

clusterCenter_image3 = np.uint8(clusterCenter_image3)
res_image3 = clusterCenter_image3[clusterLabel_image3.flatten()]
clustered_image3 = res_image3.reshape((image3.shape))

cv2.imwrite('Clustered_image1.jpg',clustered_image1)
cv2.imwrite('Clustered_image2.jpg',clustered_image2)
cv2.imwrite('Clustered_image3.jpg',clustered_image3)

cv2.imshow('Clustered_image1', clustered_image1)
cv2.imshow('Clustered_image2', clustered_image2)
cv2.imshow('Clustered_image3', clustered_image3)

cv2.waitKey(0)
cv2.destroyAllWindows()

Output image:

When done segmentation on dehazed image:-


When done segmentation on dehazed image:-

Reference:

[1] For Digital Assignment 1


Research paper name: A Fast-Single Image Haze Removal Algorithm Using Color
Attenuation Prior

Published in: IEEE Transactions on Image Processing (Volume: 24, Issue: 11, Nov. 2015)

Citation: Zhu, Q., Mai, J., & Shao, L. (2015). A fast-single image haze removal algorithm
using color attenuation prior. IEEE transactions on image processing, 24(11), 3522-3533.

DOI: 10.1109/TIP.2015.2446191

[2] For Digital Assignment 2


Research paper name: Image Segmentation using K-means Clustering Algorithm and
Subtractive Clustering Algorithm

Published in: Procedia Computer Science Volume 54, 2015, Pages 764-771

Citation: Dhanachandra, N., Manglem, K., & Chanu, Y. J. (2015). Image segmentation
using K-means clustering algorithm and subtractive clustering algorithm. Procedia
Computer Science, 54, 764-771.

DOI: 10.1016/j.procs.2015.06.090

You might also like