Professional Documents
Culture Documents
LAB REPORT
Submitted to:
Ms. Taslima Binte Hossain
Submitted by:
Jahedul Islam CSE 01506411
import cv2 as cv
import numpy as np
img = cv.imread('a.png')
image_contours = np.zeros((img.shape[1],
img.shape[0], 1),np.uint8)
cv.CHAIN_APPROX_SIMPLE)[0]
cv.imshow('Binary', image_binary)
cv.destroyAllWindows()
Output:
import cv2 as cv
import numpy as np
img = cv.imread('b.png')
image_contours = np.zeros((img.shape[1],
img.shape[0], 1),np.uint8)
cv.CHAIN_APPROX_SIMPLE)[0]
cv.imshow('Binary', image_binary)
cv.destroyAllWindows()
Output:
For image (3)
import cv2 as cv
import numpy as np
img = cv.imread('c.png')
image_contours = np.zeros((img.shape[1],
img.shape[0], 1),np.uint8)
cv.CHAIN_APPROX_SIMPLE)[0]
cv.imshow('Binary', image_binary)
Output:
import cv2 as cv
import numpy as np
img = cv.imread('d.png')
image_contours = np.zeros((img.shape[1],
img.shape[0], 1),np.uint8)
cv.CHAIN_APPROX_SIMPLE)[0]
cv.imshow('Binary', image_binary)
cv.destroyAllWindows()
Output:
Question No: 2
1) Eccentricity…
2) Ratio1 = Minor Axis length/Major Axis length
3) Ratio2 = perimeter/area
1) Eccentricity: Eccentricity measures the shortest length of the paths from a
given vertex v to reach any other vertex w of a connected graph. ... For a
connected region of a digital image it is defined through its neighborhood graph
and the given metric. The formula to find out the eccentricity of any conic
section is defined as: Eccentricity, e = c/a. Where, c = distance from the center to
the focus. a = distance from the center to the vertex.
Here I have taken the given images again & calculated their eccentricities that are
given below:
import cv2
import mahotas
import numpy as np
from pylab import gray, imshow, show
import os
img = mahotas.imread('aaaaa.png')
img = img[:, :, 0]
print(img)
imshow(img)
show()
value = mahotas.features.eccentricity(img)
Output:
For Image(a):
For Image(c):
import numpy as np
# load image
img = cv2.imread("aaaaa.jpg")
# threshold on color
region = measure.regionprops(binary)
print(prop, region[0][prop])
Output:
Image1: 1.0586
Image2: 4.7061
Image3: 3.6204
Image4: 1.5425
Question No: 3
The End