Skip to content

Instantly share code, notes, and snippets.

@harshnandwana
Created July 2, 2022 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshnandwana/51aab342c3298bbc4d38e5475348d420 to your computer and use it in GitHub Desktop.
Save harshnandwana/51aab342c3298bbc4d38e5475348d420 to your computer and use it in GitHub Desktop.
def plot_final(Data,return_image=False):
image1=cv2.imread(Data)
image = aug.augment_image(image1)
image=image[:,:,1]
image[image <0.2]=0.5
image = image / 255
predicted = unet.predict(image[np.newaxis,:,:])
predicted[predicted <0.25]=0
img = predicted[0,:,:,0]
mean,std=cv2.meanStdDev(img)
pixels = cv2.countNonZero(img)
image_area = img.shape[0] * img.shape[1]
area_ratio = (pixels / image_area) * 100
img = img*255
img[img<1]=1
img[img>100]=255
M= cv2.moments(img)
cX = int(M["m10"] / M["m00"])
cY = int(M["m01"] / M["m00"])
if return_image:
return img,area_ratio,std,(cX,cY)
else:
return area_ratio,std,(cX,cY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment