-
-
Save harshnandwana/51aab342c3298bbc4d38e5475348d420 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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