diff options
author | prashantsinalkar | 2020-04-14 10:19:27 +0530 |
---|---|---|
committer | prashantsinalkar | 2020-04-14 10:23:54 +0530 |
commit | 476705d693c7122d34f9b049fa79b935405c9b49 (patch) | |
tree | 2b1df110e24ff0174830d7f825f43ff1c134d1af /Digital_Image_Processing_by_S_Jayaraman/7-Image_Segmentation.ipynb | |
parent | abb52650288b08a680335531742a7126ad0fb846 (diff) | |
download | all-scilab-tbc-books-ipynb-476705d693c7122d34f9b049fa79b935405c9b49.tar.gz all-scilab-tbc-books-ipynb-476705d693c7122d34f9b049fa79b935405c9b49.tar.bz2 all-scilab-tbc-books-ipynb-476705d693c7122d34f9b049fa79b935405c9b49.zip |
Initial commit
Diffstat (limited to 'Digital_Image_Processing_by_S_Jayaraman/7-Image_Segmentation.ipynb')
-rw-r--r-- | Digital_Image_Processing_by_S_Jayaraman/7-Image_Segmentation.ipynb | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/Digital_Image_Processing_by_S_Jayaraman/7-Image_Segmentation.ipynb b/Digital_Image_Processing_by_S_Jayaraman/7-Image_Segmentation.ipynb new file mode 100644 index 0000000..ccdb079 --- /dev/null +++ b/Digital_Image_Processing_by_S_Jayaraman/7-Image_Segmentation.ipynb @@ -0,0 +1,183 @@ +{ +"cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 7: Image Segmentation" + ] + }, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.23: Scilab_code_for_Differentiation_of_Gaussian_function.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Scilab code for Differentiation of Gaussian function\n", +"//Fig7.23\n", +"//page388\n", +"clc;\n", +"close;\n", +"sigma=input('Enter the value of sigma:')\n", +"i=-10:.1:10;\n", +"j=-10:.1:10;\n", +"r=sqrt(i.*i+j.*j);\n", +"y=(1/(sigma^2))*(((r.*r)/sigma^2)-1).*exp(-r.*r/2*sigma^2);\n", +"plot(i,y)\n", +"legend(sprintf('The sigma value is %g',sigma))\n", +"xtitle('Differentiation of Gaussian function')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.25: Scilab_code_for_Differentiation_of_Gaussian_Filter_function.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Scilab code for Differentiation of Gaussian Filter function\n", +"//Fig7.25\n", +"//page389\n", +"clc;\n", +"close;\n", +"sigma1 = input('Enter the value of sigma1:')\n", +"sigma2 = input('Enter the value of sigma2:')\n", +"i=-10:.1:10;\n", +"j=-10:.1:10;\n", +"r=sqrt(i.*i+j.*j);\n", +"y1 = (1/(sigma1^2))*(((r.*r)/sigma1^2)-1).*exp(-r.*r/2*sigma1^2);\n", +"y2 = (1/(sigma2^2))*(((r.*r)/sigma2^2)-1).*exp(-r.*r/2*sigma2^2);\n", +"y = y1-y2;\n", +"plot(i,y)\n", +"xtitle('Shape of DOG Filter')\n", +"//Result\n", +"//Enter the value of sigma1: 4\n", +"//Enter the value of sigma2: 1\n", +"// " + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.27: Scilab_code_for_Edge_Detection_using_Different_Edge_detectors.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Scilab code for Edge Detection using Different Edge detectors \n", +"//[1]. Sobel [2].Prewitt [3].Log [4].Canny\n", +"//Fig7.27\n", +"//page389\n", +"close;\n", +"clc;\n", +"a = imread('E:\DIP_JAYARAMAN\Chapter7\sailing.jpg');\n", +"a = rgb2gray(a);\n", +"c = edge(a,'sobel');\n", +"d = edge(a,'prewitt');\n", +"e = edge(a,'log');\n", +"f = edge(a,'canny');\n", +"ShowImage(a,'Original Image')\n", +"title('Original Image')\n", +"figure\n", +"ShowImage(c,'Sobel')\n", +"title('Sobel')\n", +"figure\n", +"ShowImage(d,'Prewitt')\n", +"title('Prewitt')\n", +"figure\n", +"ShowImage(e,'Log')\n", +"title('Log')\n", +"figure\n", +"ShowImage(f,'Canny')\n", +"title('Canny')" + ] + } +, +{ + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7.30: Scilab_code_to_perform_watershed_transform.sce" + ] + }, + { +"cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], +"source": [ +"//Caption: Scilab code to perform watershed transform\n", +"//Fig7.30\n", +"//Page396\n", +"clc;\n", +"close;\n", +"b = imread('E:\DIP_JAYARAMAN\Chapter7\teaset.png');\n", +"a = rgb2gray(b);\n", +"global EDGE_SOBEL;\n", +"Gradient = EdgeFilter(a, EDGE_SOBEL);\n", +"Threshold1 = CalculateOtsuThreshold(Gradient); // determine a threshold\n", +"EdgeImage = ~SegmentByThreshold(Gradient,Threshold1);\n", +"DistanceImage = DistanceTransform(EdgeImage);\n", +"Threshold2 = CalculateOtsuThreshold(DistanceImage) // determine a threshold\n", +"ThresholdImage = SegmentByThreshold(DistanceImage,Threshold2);\n", +"MarkerImage = SearchBlobs(ThresholdImage);\n", +"SegmentedImage = Watershed(Gradient,MarkerImage);\n", +"figure\n", +"ShowColorImage(b,'teaset')\n", +"title('teaset.png')\n", +"figure\n", +"ColorMapLength = length(unique(SegmentedImage));\n", +"ShowImage(SegmentedImage,'Result of Watershed Transform',jetcolormap(ColorMapLength)); " + ] + } +], +"metadata": { + "kernelspec": { + "display_name": "Scilab", + "language": "scilab", + "name": "scilab" + }, + "language_info": { + "file_extension": ".sce", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "scilab", + "version": "0.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} |