Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import cv2
- import matplotlib.pyplot as plt
- %matplotlib inline
- img = cv2.imread('C:/Users/Sergey/Sanya/komputernoe_zrenie/CV_SOS-master/less_03/bin_ship/task_img/test_image_00.jpg')
- img_plt = cv2.cvtColor(img.copy(), cv2.COLOR_BGR2GRAY)
- ret,thresh1 = cv2.threshold(img_plt,88,255,cv2.THRESH_BINARY)
- titles = ['Original Image','BINARY']
- images = [img_plt, thresh1]
- plt.figure(figsize=(20,20))
- for i in range(2):
- plt.subplot(2,3,i+1),plt.imshow(images[i],'gray')
- plt.title(titles[i])
- plt.xticks([]),plt.yticks([])
- thresh1.shape = (thresh1.shape[0]*256, 3)
- s = 0
- a = np.array(([[255, 255, 255]]))
- for i in range(thresh1.shape[0]):
- if (thresh1[i] == a).all():
- s += 1
- plt.show()
- print("Площадь корабля = ",s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement