ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Computer Science & Programming

Image Enhancement Techniques with Matlab code

Updated on February 14, 2011
Source

Image Enhancement techniques that we will be looking at with matlab code:

 

  1. Image Negative
  2. Gray level slicing with and without background
  3. Bitplane Slicing with 3 and 7 bits
  4. Image Darkening or Lighting
  5. Thresholding
 
 

Source

Matlab Code

% Name: Ritesh Kothari
% Program 2
clear all;
close all;


% Image Reading

pic = imread('C:\Sample Pictures\Koala.jpg');

rp = imresize(pic,[500,600]);


%Image Negation of an image block
rp(1:100,201:400,:) = 255 -
pic(1:100,201:400,:);


%Darkening of the Image Block
rp(101:200,1:200,:) =
rp(101:200,1:200,:) - 100;


%Thresholding of the image block
for i = 101:200
for j = 401:600
if rp(i,j,1)>128
rp(i,j,1) = 255;
else
rp(i,j,1)=0;
end
if rp(i,j,2)>128
rp(i,j,2) = 255;
else
rp(i,j,2)=0;
end
if rp(i,j,3)>128
rp(i,j,3) = 255;
else
rp(i,j,3)=0;
end
end
end


%Graylevel Slicing with Background
for i = 301:400
for j = 1:200
if rp(i,j,1)>100 &&
rp(i,j,1)<=200
rp(i,j,1)<=200
rp(i,j,1) = 255;
end
if rp(i,j,2)>100 &&
rp(i,j,2)<=200
rp(i,j,2)<=200
rp(i,j,2) = 255;
end
if rp(i,j,3)>100 &&
rp(i,j,3)<=200
rp(i,j,3)<=200
rp(i,j,3) = 255;
end
end
end


%Graylevel Slicing without Background
for i = 301:400
for j = 401:600
if rp(i,j,1)>100 &&
rp(i,j,1)<=200
rp(i,j,1)<=200
rp(i,j,1) = 255;
else
rp(i,j,1) = 0;
end
if rp(i,j,2)>100 &&
rp(i,j,2)<=200
rp(i,j,2)<=200
rp(i,j,2) = 255;
else
rp(i,j,1) = 0;
end
if rp(i,j,3)>100 &&
rp(i,j,3)<=200
rp(i,j,3)<=200
rp(i,j,3) = 255;
else
rp(i,j,1) = 0;
end
end
end


%Bit Plane Slicing for plane no.3
for i = 401:500
for j = 201:400
if bitget(rp(i,j,1),3)==1
rp(i,j,1) = 255;
else
rp(i,j,1) = 0;
end
if bitget(rp(i,j,2),3)==1
rp(i,j,2) = 255;
else
rp(i,j,2) = 0;
end
if bitget(rp(i,j,3),3)==1
rp(i,j,3) = 255;
else
rp(i,j,3) = 0;
end
end
end


% Bit Plane Slicing for plane no.7
for i = 201:300
for j = 201:400
if bitget(rp(i,j,1),7)==1
rp(i,j,1) = 255;
else
rp(i,j,1) = 0;
end
if bitget(rp(i,j,2),7)==1
rp(i,j,2) = 255;
else
rp(i,j,2) = 0;
end
if bitget(rp(i,j,3),7)==1
rp(i,j,3) = 255;
else
rp(i,j,3) = 0;
end
end
end
imshow(rp);

The above enhancement techniques have been used on a part of image and the whole image. Please check the image above and the corresponding matrix with it. For any difficulties kindly leave your comment.

Comments

    0 of 8192 characters used
    Post Comment

    • profile image

      mtabe 2 years ago

      i need codes for counting bacteria saikimu@live.com

    • profile image

      Rincy 2 years ago

      how the threshold value of the image will be chosen

    • profile image

      sakshi 3 years ago

      sir above code is not running error at line 12 darkening

    • profile image

      Archana Kumari 3 years ago

      My project topic is "PDE-based enhancement of color images in RGB space" can u send me code for this in matlab. If u can pls mail me at

      archana.kumari1503@gmail.com

    • profile image

      Nikhil Xavier 3 years ago

      This code is user friendly but not executed .I have tried,,

    • profile image

      anshul yadav 4 years ago

      sir i need the code for image inhachment please send me the code

      thakns

      my e-mail id is anshuldv001@gmail.com

    • profile image

      gfdd 4 years ago

      Explain Bit-level slicing as applied on images. Which process of analog-to-digital conversion does it coincide with? Explain how can we perform bit level slicing using Bitwise AND operation. Also write a

      Matlab program to demonstrate the same.

    • profile image

      RESHMI VP 4 years ago

      respected sir,

      i would like to get opencv or matlab code as part by part or fully for my project titled an inpainting assisted stegnographic scheme using histogram shifting. pls do sent to my mail id reshmivp88@gmail.com

    • profile image

      priti 4 years ago

      My project topic is "PDE-based enhancement of color images in RGB space" can u send me code for this in matlab. If u can pls mail me at preeti.cool03@gmail.com.

    • profile image

      senthilbabu.D 4 years ago

      Respected Sir,

      i need the code for cotrast enhancement using wavelets. if u can, pls mail me. senthilbabu.d@gmail.om

    • profile image

      kevin g 4 years ago

      kool ireng

    • profile image

      Narayan 4 years ago

      Sir I need code for iris detection.........plz mail me at shri.07@gmail.com

    • profile image

      ashwini 4 years ago

      sir i need d code for mri segmentation of osteoarthritic knees

    • profile image

      Vijay 4 years ago

      Hello Sir,

      I need command used for image enhancement using FFT kindly help me out with this. I will be very thankful to you.

      pLease mail me the command on vjy.rwt@gmail.com

    • profile image

      Saranyan 5 years ago

      Thanks Rithesh.... Its working

    • profile image

      rahul anand 5 years ago

      can i get the image enhancemnet coding using GPCM

    • profile image

      SANTOSH KUMAR MEHTA 5 years ago

      This code is user friendly but not executed .I have tried.

    • profile image

      angela 5 years ago

      i hav tried grylevel slicing but it hides the other processes running on???

    • profile image

      Ahasan Habib 5 years ago

      This code is well.

      But I need a source code for Image resolution enhancement using Inter-subband Correlation in Wavelet Domain.

      I will be grateful to u ,if u send that code.Pls send it.

    • profile image

      ng 5 years ago

      thank u for sharing ...

    • profile image

      roshan 5 years ago

      thank you

    • profile image

      supriya 6 years ago

      i tried to exicute this prog, but i couldnt do it giving so many errors

    • riteshkothari1990 profile image
      Author

      riteshkothari1990 6 years ago

      press f5 and it should work....

    • profile image

      Njoud 6 years ago

      hi , i m trying to use matlab to make bit plane slicing , i copy the code but my question is how to show the result ?