# Image Enhancement Techniques with Matlab code

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

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

- Image Negative
- Gray level slicing with and without background
- Bitplane Slicing with 3 and 7 bits
- Image Darkening or Lighting
- Thresholding

## 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 24 comments

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 ?

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

thank you

thank u for sharing ...

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.

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

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

can i get the image enhancemnet coding using GPCM

Thanks Rithesh.... Its working

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

sir i need d code for mri segmentation of osteoarthritic knees

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

kool ireng

Respected Sir,

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

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.

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

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.

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

thakns

my e-mail id is anshuldv001@gmail.com

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

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

sir above code is not running error at line 12 darkening

how the threshold value of the image will be chosen

24