Вы находитесь на странице: 1из 6

GROUP NO: 50 ROLL NO: 1704108

EXPERIMENT 6: Implement image negative, gray level slicing and


thresholding

Theory:

Point Processing Techniques are among the simplest of all image enhancement techniques.

1. Negative of an Image:

The simple operation in image processing is to compute the negative of an image. It


can be done by reversing the pixel values from black to white and white to black.
Intensity of output image decreases as intensity of input image increases.

2. Thresholding:

It is a process of extracting a part of an image which contains information. In this


transformation, one threshold level is set and pixel values below threshold are to be
taken as 0 and above values are taken as 255.
Intermediate values of r1, r2, s1 and s2 produce various degrees of grey levels at
output which affects its contrast as shown in fig.

3. Gray Level Slicing with Background:

Grey level slicing is equivalent to band pass filtering. It manipulates groups of


intensity levels in an image up to specific range by diminishing rest or by leaving
them alone. This transformation is applicable in medical images and satellite images
such as X-ray flaws, CT scan. Two different approaches are adopted for grey level
slicing.
4. Gray Level Slicing without Background:

It displays high values in the specific region of an image and low values to other
regions by ignoring background.
NEGATIVE IMAGE
a = imread("My_photo.jpg");

img=rgb2gray(a);

sz = size(img);

for i = 1: sz(1)

for j = 1:sz(2)

b(i, j ) = 256 -1- a(i, j);

end
end

figure(1);

imshow(img);

figure(2);

imshow(b)

Original Image

Negative Index
THRESHOLDING
image = imread('My_photo.jpg');

image1=rgb2gray(image);

[r,c] = size(image1);

s = image1;

for i=1:r
for j=1:c

if(s(i,j)<100)

s(i,j) = 1;

end

end
end

figure(1),imshow(image1);title('Original image');

figure(2),imshow(s);title('Thresholding image');

Original Image Threshold Image


GRAY LEVEL SLICING
img = imread('My_photo.jpg');
img = rgb2gray(img);

without_background = uint8(img);

with_background = uint8(img);

[n,m] = size(without_background);

l = 256;

for i=1:n

for j=1:m
%With out BackGround

if(without_background(i,j)>120 & without_background(i,j)<220)

without_background(i,j) = l-1;

else
without_background(i,j) = 0;

end

%With BackGround

if(with_background(i,j)>120 & with_background(i,j)<220)


with_background(i,j) = l-1;

end

end

end
figure,imshow(img);title('Original Image');

figure;

imshow(without_background); title('Gray Level Slicing Without BackGround');

for i=1:n
for j=1:m
%With BackGround

if(without_background(i,j)>120 & without_background(i,j)<220)

without_background(i,j) = l-1;
end

end

end

figure;
imshow(with_background); title('Gray Level Slicing With BackGround');

Gray level Slicing without background Gray level Slicing with Background

Вам также может понравиться