This function converts the user image to Gray Scale
return: Gray scale Image
"""
image_gray=color.rgb2gray(image)
image_gray=resize(image_gray,(1572,2213))
returnimage_gray
defDividingLeads(self,image):
"""
This Function Divides the Ecg image into 13 Leads including long lead. Bipolar limb leads(Leads1,2,3). Augmented unipolar limb leads(aVR,aVF,aVL). Unipolar (+) chest leads(V1,V2,V3,V4,V5,V6)
# thresholding to distinguish foreground and background
# using otsu thresholding for getting threshold value
global_thresh=threshold_otsu(blurred_image)
print(global_thresh)
# creating binary image based on threshold
binary_global=blurred_image<global_thresh
ax3.imshow(binary_global,cmap='gray')
ax3.set_title("Leads 13")
ax3.axis('off')
# fig3.savefig('Preprossed_Leads_13_figure.png')
defSignalExtraction_Scaling(self,Leads):
"""
This Function Performs Signal Extraction using various steps,techniques: convert to grayscale, apply gaussian filter, thresholding, perform contouring to extract signal image and then save the image as 1D signal
"""
fig4,ax4=plt.subplots(4,3)
# fig4.set_size_inches(10, 10)
x_counter=0
y_counter=0
forx,yinenumerate(Leads[:len(Leads)-1]):
# converting to gray scale
grayscale=color.rgb2gray(y)
# smoothing image
blurred_image=gaussian(grayscale,sigma=0.7)
# thresholding to distinguish foreground and background
# using otsu thresholding for getting threshold value