ASIP-Pract-7December28,2021[]:#AdvancedSignalandImageProcessingPractical#CodecompiledandrunbyR.K.Maurya#Credittooriginalauthorsandprogrammers.#Formorelearningresourcesvisithttps://www.rajeshmaurya.in[1]:#WriteaprogramtoApplyedgedetectiontechniquessuchasSobelandCannyto,extractmeaningfulinformationfromthegivenimagesamples[4]:importnumpyasnpfromscipyimportsignal,misc,ndimagefromskimageimportfilters,feature,img_as_floatfromskimage.ioimportimreadfromskimage.colorimportrgb2grayfromPILimportImage,ImageFilterimportmatplotlib.pylabaspylab[5]:defplot_image(image,title):pylab.imshow(image),pylab.title(title,size=20),pylab.axis('off')[6]:#Differentedgedetectorswithscikit-image–Prewitt,Roberts,Sobel,Scharr,,andLaplace#im=imread('images/taj.png')#RGBimagetograyscaleim=Image.open('images/rajesh.png').convert('L')pylab.gray()pylab.figure(figsize=(15,15))pylab.subplot(3,2,1),plot_image(im,'original')edges=filters.roberts(im)pylab.subplot(3,2,2),plot_image(edges,'roberts')edges=filters.scharr(im)pylab.subplot(3,2,3),plot_image(edges,'scharr')edges=filters.sobel(im)pylab.subplot(3,2,4),plot_image(edges,'sobel')edges=filters.prewitt(im)pylab.subplot(3,2,5),plot_image(edges,'prewitt')edges=np.clip(filters.laplace(im),0,1)pylab.subplot(3,2,6),plot_image(edges,'laplace')pylab.subplots_adjust(wspace=0.1,hspace=0.1)pylab.show()1
<Figuresize432x288with0Axes>[8]:#Sobeledgedetectorwithscikit-image#im=rgb2gray(imread('../images/tajmahal1.jpg'))#RGBimagetograyscaleim=Image.open('images/rajesh.png').convert('L')pylab.gray()2
pylab.figure(figsize=(15,15))pylab.subplot(2,2,1)plot_image(im,'original')pylab.subplot(2,2,2)edges_x=filters.sobel_h(im)plot_image(np.clip(edges_x,0,1),'sobel_x')pylab.subplot(2,2,3)edges_y=filters.sobel_v(im)plot_image(np.clip(edges_y,0,1),'sobel_y')pylab.subplot(2,2,4)edges=filters.sobel(im)plot_image(np.clip(edges,0,1),'sobel')pylab.subplots_adjust(wspace=0.1,hspace=0.1)pylab.show()<Figuresize432x288with0Axes>3