0% found this document useful (0 votes)
18 views2 pages

Basic Operations

Uploaded by

shashankgowda735
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Basic Operations

Uploaded by

shashankgowda735
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

% Load the grayscale image

image = imread('[Link]');
if size(image, 3) == 3
image = rgb2gray(image); % Convert to grayscale if the image is RGB
end

% Define parameters
L = 255;
conditions = [0, L/2; L/2, 3*L/4; 3*L/4, L];
gamma_values = [0.2, 0.8];

% Initialize figure
figure;

% Display original image


subplot(4,2,1);
imshow(image);
title('Original Grayscale Image');

% Apply intensity slicing for each condition and display


for i = 1:3
low = conditions(i, 1);
high = conditions(i, 2);

% Intensity slicing
sliced_image = zeros(size(image), 'uint8');
sliced_image(image >= low & image <= high) = L;

subplot(4,2,i+1);
imshow(sliced_image);
title(['Intensity Slicing: Condition ' num2str(i)]);
end

% Perform gamma correction and display


for j = 1:length(gamma_values)
gamma = gamma_values(j);
gamma_corrected_image = uint8(255 * (double(image) / 255).^gamma);

subplot(4,2,j+4);
imshow(gamma_corrected_image);
title(['Gamma Correction, \gamma = ' num2str(gamma)]);
end

% Display histogram of the original image


subplot(4,2,7);
imhist(image);
title('Histogram of Original Image');

% Create and display the negative image


negative_image = L - image;
subplot(4,2,8);
imshow(negative_image);
title('Negative Image');

You might also like