Image Enhancement Techniques with Matlab code

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.

More by this Author

  • Promissory Note for Personal Loans
    0

    Promissory Notes: Personal Loans to Friends and Family Protecting yourself with a promissory note when making loans to family and friends. It is common to loan money to a family member or a friend when in need of...


Comments 24 comments

Njoud 5 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 ?


riteshkothari1990 profile image

riteshkothari1990 5 years ago Author

press f5 and it should work....


supriya 5 years ago

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


roshan 4 years ago

thank you


ng 4 years ago

thank u for sharing ...


Ahasan Habib 4 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.


angela 4 years ago

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


SANTOSH KUMAR MEHTA 4 years ago

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


rahul anand 4 years ago

can i get the image enhancemnet coding using GPCM


Saranyan 4 years ago

Thanks Rithesh.... Its working


Vijay 3 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


ashwini 3 years ago

sir i need d code for mri segmentation of osteoarthritic knees


Narayan 3 years ago

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


kevin g 3 years ago

kool ireng


senthilbabu.D 3 years ago

Respected Sir,

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


priti 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 preeti.cool03@gmail.com.


RESHMI VP 3 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


gfdd 3 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.


anshul yadav 3 years ago

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

thakns

my e-mail id is anshuldv001@gmail.com


Nikhil Xavier 2 years ago

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


Archana Kumari 2 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


sakshi 2 years ago

sir above code is not running error at line 12 darkening


Rincy 13 months ago

how the threshold value of the image will be chosen


mtabe 13 months ago

i need codes for counting bacteria saikimu@live.com

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working