summaryrefslogtreecommitdiff
path: root/Digital_Image_Processing_by_S_Jayaraman/5-Image_Enhancement.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Digital_Image_Processing_by_S_Jayaraman/5-Image_Enhancement.ipynb')
-rw-r--r--Digital_Image_Processing_by_S_Jayaraman/5-Image_Enhancement.ipynb256
1 files changed, 256 insertions, 0 deletions
diff --git a/Digital_Image_Processing_by_S_Jayaraman/5-Image_Enhancement.ipynb b/Digital_Image_Processing_by_S_Jayaraman/5-Image_Enhancement.ipynb
new file mode 100644
index 0000000..8d67e2f
--- /dev/null
+++ b/Digital_Image_Processing_by_S_Jayaraman/5-Image_Enhancement.ipynb
@@ -0,0 +1,256 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 5: Image Enhancement"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.13: Scilab_code_to_determine_image_negative.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:Scilab code to determine image negative\n",
+"//Fig.5.13\n",
+"//page 252\n",
+"clc;\n",
+"close;\n",
+"a = imread('E:\DIP_JAYARAMAN\Chapter5\label.jpg');\n",
+"k = 255-double(a);\n",
+"k = uint8(k);\n",
+"imshow(a); \n",
+"title('Original onca Image')\n",
+"imshow(k); \n",
+"title('Negative of Original Image')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.16: Scilab_code_that_performs_threshold_operatio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:Scilab code that performs threshold operation\n",
+"//Fig5.16\n",
+"//page 254\n",
+"clc;\n",
+"close;\n",
+"a = imread('E:\Digital_Image_Processing_Jayaraman\Chapter5\lena.png');\n",
+"a = rgb2gray(a);\n",
+"[m n] = size(a);\n",
+"t = input('Enter the threshold parameter');\n",
+"for i = 1:m\n",
+" for j = 1:n\n",
+" if(a(i,j)<t)\n",
+" b(i,j)=0;\n",
+" else\n",
+" b(i,j)=255;\n",
+" end\n",
+" end\n",
+"end\n",
+"figure(1)\n",
+"ShowImage(a,'Original Image'); \n",
+"title('Original Image')\n",
+"figure(2)\n",
+"ShowImage(b,'Thresholded Image'); \n",
+"title('Thresholded Image')\n",
+"xlabel(sprintf('Threshold value is %g',t))\n",
+"//Result\n",
+"//Enter the threshold parameter 140"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.20: Program_performs_gray_level_slicing_without_background.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption: Program performs gray level slicing without background\n",
+"//Fig.5.20\n",
+"//page256\n",
+"clc;\n",
+"x = imread('E:\Digital_Image_Processing_Jayaraman\Chapter5\lena.png');\n",
+"x = rgb2gray(x);\n",
+"y = double(x);\n",
+"[m,n]= size(y);\n",
+"L = max(max(x));\n",
+"a = round(L/2);\n",
+"b = L;\n",
+"for i =1:m\n",
+" for j =1:n\n",
+" if(y(i,j)>=a & y(i,j)<=b)\n",
+" z(i,j) = L;\n",
+" else\n",
+" z(i,j)=0;\n",
+" end\n",
+" end\n",
+"end\n",
+"z = uint8(z);\n",
+"figure(1)\n",
+"ShowImage(x,'Original Image');\n",
+"title('Orginal Image')\n",
+"figure(2)\n",
+"ShowImage(z,'Gray Level Slicing');\n",
+"title('Gray Level Slicing without preserving background')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.5: Scilab_code_for_brightness_enhancement.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:Scilab code for brightness enhancement \n",
+"//Fig5.5\n",
+"//page 246\n",
+"clc;\n",
+"close;\n",
+"//a = imread('E:\DIP_JAYARAMAN\Chapter5\plate.GIF'); //SIVP toolbox\n",
+"a = imread('E:\DIP_JAYARAMAN\Chapter4\baboon.png');\n",
+"a = rgb2gray(a);\n",
+"b = double(a)+50;\n",
+"b = uint8(b);\n",
+"figure(1)\n",
+"ShowImage(a,'Original Image'); \n",
+"title('Original Image')\n",
+"figure(2)\n",
+"ShowImage(b,'Enhanced Image'); \n",
+"title('Enhanced Image')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.7: Scilab_code_for_brightness_suppression.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:Scilab code for brightness suppression\n",
+"//Fig5.7\n",
+"//page 247\n",
+"clc;\n",
+"close;\n",
+"a = imread('E:\DIP_JAYARAMAN\Chapter4\baboon.png');\n",
+"a = rgb2gray(a);\n",
+"b = double(a)-50;\n",
+"b = uint8(b);\n",
+"figure(1)\n",
+"ShowImage(a,'Original Image'); \n",
+"title('Original Image')\n",
+"figure(2)\n",
+"ShowImage(b,'Brightness Supressed Image'); \n",
+"title('Brightness Supressed Image')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9: Scilab_code_for_Contrast_Manipulation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:Scilab code for Contrast Manipulation\n",
+"//Fig5.9\n",
+"//page 248\n",
+"clc;\n",
+"close;\n",
+"a = imread('E:\DIP_JAYARAMAN\Chapter4\lena.png');\n",
+"a = rgb2gray(a);\n",
+"b = double(a)*0.5;\n",
+"b = uint8(b)\n",
+"c = double(b)*2;\n",
+"c = uint8(c)\n",
+"figure(1)\n",
+"ShowImage(a,'Original Image'); \n",
+"title('Original Image')\n",
+"figure(2)\n",
+"ShowImage(b,'Decrease in Contrast'); \n",
+"title('Decrease in Contrast')\n",
+"figure(3)\n",
+"ShowImage(c,'Increase in Contrast'); \n",
+"title('Increase in Contrast')"
+ ]
+ }
+],
+"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
+}