JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

IP all practical | JustPaste.app
4 days ago18 views
👨‍💻Programming

IP all practical

% PRACTICAL NO: 1
% AIM: Image Enhancement in Spatial Domain.
% Apply Log Transformation to the given input image
% and display the resulting image.
clc;
clear all;
close all;
a = imread('C:\IP\images.jpg');
a = double(rgb2gray(a));
c = 255 / log(256);
b = c * log(1 + a);
b = uint8(b);
imshow(b);
title('Log Transformation');
% PRACTICAL NO: 1
% AIM: Image Enhancement in Spatial Domain.
% Apply Power Law Transformation to the given input image
% and display the resulting image.
clc;
clear all;
close all;
a = imread('C:\IP\images.jpg');
b = double(a);
subplot(1,2,1);
imshow(a);
title('Original Image');
k = 1;
gamma = 1;
[m,n] = size(b);
for i = 1:m
for j = 1:n
c(i,j) = k * (b(i,j)^gamma);
end
end
subplot(1,2,2);
imshow(uint8(c));
title('Power Law Image');
% PRACTICAL NO: 1
% AIM: Image Enhancement in Spatial Domain.
% Apply Negation to the given input image
% and display the resulting image.
clc;
clear all;
close all;
a = imread('C:\IP\images.jpg');
a = rgb2gray(a);
subplot(1,2,1);
imshow(a);
title('Original Image');
[m,n] = size(a);
for i = 1:m
for j = 1:n
c(i,j) = 255 - a(i,j);
end
end
subplot(1,2,2);
imshow(uint8(c));
title('Negation Image');
% PRACTICAL NO: 1
% AIM: Display dark, bright, low contrast and high contrast
% images by applying contrast stretching on an input image.
clc;
clear all;
close all;
a = imread('C:\IP\images.jpg');
a = im2double(a);
subplot(2,3,1);
imshow(a);
title('Original Image');
dark = a * 0.4;
subplot(2,3,2);
imshow(dark);
title('Dark Image');
bright = a * 1.5;
bright(bright > 1) = 1;
subplot(2,3,3);
imshow(bright);
title('Bright Image');
low = 0.5 * a + 0.25;
subplot(2,3,4);
imshow(low);
title('Low Contrast Image');
high = imadjust(a,[0.3 0.7],[0 1]);
subplot(2,3,5);
imshow(high);
title('High Contrast Image');
% PRACTICAL NO: 1
% AIM: Apply Gray-Level Slicing with and without
% background to the given input image.
clc;
clear all;
close all;
a = imread('C:\IP\images.jpg');
a = rgb2gray(a);
[m,n] = size(a);
b = zeros(m,n);
c = a;
for i = 1:m
for j = 1:n
if a(i,j) >= 100 && a(i,j) <= 200
b(i,j) = 255;
c(i,j) = 255;
end
end
end
subplot(1,3,1);
imshow(a);
title('Original Image');
subplot(1,3,2);
imshow(uint8(b));
title('Without Background');
subplot(1,3,3);
imshow(uint8(c));
title('With Background');
% PRACTICAL NO: 1
% AIM: Apply Bit-Plane Slicing to the given input image
% and display the resulting image.
clc;
clear all;
close all;
a = imread('C:\IP\images.jpg');
a = rgb2gray(a);
subplot(3,3,1);
imshow(a);
title('Original Image');
for k = 0:7
b = bitget(a,k+1) * 255;
subplot(3,3,k+2);
imshow(b);
title(['Bit Plane ',num2str(k)]);
end

% PRACTICAL NO: 2
% AIM: Image Enhancement in Frequency Domain.
% Program to apply Discrete Fourier Transform on an image.
clc;
clear all;
I = imread("C:\ip\images.jpg");
I1 = double(I);
J = fft2(I1);
L = fftshift(real(J));
subplot(1,3,1);
imshow(I);
title('Original Image');
subplot(1,3,2);
imshow(J);
title('Fourier transform');
subplot(1,3,3);
imshow(L);
title('shifted Fourier transform');


% PRACTICAL NO: 2
% AIM: Image Enhancement in Frequency Domain.
% Apply Butterworth Low Pass Filter.
clc;
clear all;
S = imread("C:\ip\images.jpg");
h = mkfftfilter(S,'gauss',0.4);
S2 = fft2(im2double(S));
S3 = S2.*fftshift(h);
S4 = real(ifft(S3));
subplot(2,2,1);
imshow(S);
title('Original Image');
subplot(2,2,2);
imshow(abs(S2));
title('Fourier Transform');
subplot(2,2,3);
imshow(abs(S3));
title('Shifted Fourier Transform');
subplot(2,2,4);
imshow(S4);
title('Filtered Image');

% PRACTICAL NO: 2
% AIM: Image Enhancement in Frequency Domain.
% Apply Ideal High Pass Filter.
clc;
clear all;
S = imread("C:\ip\images.jpg");
S2 = fft2(im2double(S));
h = ffilt('hp',3,0.2,0.3);
img = imfilter(S2,h);
S4 = real(ifft(img));
subplot(1,3,1);
imshow(S);
title('Original Image');
subplot(1,3,2);
imshow(abs(S2));
title('Fourier Image');
subplot(1,3,3);
imshow(S4);
title('Filtered Image');



% PRACTICAL NO: 2
% AIM: Image Enhancement in Frequency Domain.
% Apply Ideal Low Pass Filter.
clc;
clear all;
S = imread("C:\ip\images.jpg");
S2 = fft2(im2double(S));
h = ffilt('lp',3,0.2,0.3);
img = imfilter(S2,h);
S4 = real(ifft(img));
subplot(1,3,1);
imshow(S);
title('Original Image');
subplot(1,3,2);
imshow(abs(S2));
title('Fourier Image');
subplot(1,3,3);
imshow(S4,[]);
title('Filtered Image');




% PRACTICAL NO: 3
% AIM: Implement image averaging technique to remove
% noise from an image by using an averaging filter.
clc;
clear all;
image = imread("C:\ip\image.jpg");
NoisyImage = imnoise(image,'salt & pepper',0.02);
F1 = fspecial('average',3);
FilterImage = imfilter(NoisyImage,F1);
subplot(1,3,1);
imshow(image);
title('Original Image');
subplot(1,3,2);
imshow(NoisyImage);
title('Noisy Image');
subplot(1,3,3);
imshow(FilterImage);
title('Filtered Image');


% PRACTICAL NO: 3
% AIM: Apply the smoothing effect to an input image
% by using appropriate filter masks.
clc;
clear all;
a = imread("C:\ip\image.jpg");
a = rgb2gray(a);
NoisyImage = imnoise(a,'gaussian',0.02);
wienerfilter = imwiener2(NoisyImage,[5,5],0.02);
subplot(1,3,1);
imshow(a);
title('Original Image');
subplot(1,3,2);
imshow(NoisyImage);
title('Noisy Image');
subplot(1,3,3);
imshow(wienerfilter);
title('Wiener Filter');



% PRACTICAL NO: 3
% AIM: Program to study the effects of varying the
% number of intensity levels in a digital image.
clc;
clear;
a = imread("C:\ip\image.jpg");
a = double(rgb2gray(a));
subplot(2,2,1);
imshow(uint8(a));
xtitle("Original Image");
subplot(2,2,2);
imshow(uint8(floor(a/128)*128));
xtitle("2 Intensity Levels");
subplot(2,2,3);
imshow(uint8(floor(a/64)*64));
xtitle("4 Intensity Levels");
subplot(2,2,4);
imshow(uint8(floor(a/32)*32));
xtitle("8 Intensity Levels");



% PRACTICAL NO: 3
% AIM: Program to perform image averaging
% (image addition) for noise reduction.
clc;
clear;
a = double(imread("C:\ip\image.jpg"));
b = double(imread("C:\ip\image.jpg"));
avg = uint8((a+b)/2);
subplot(1,3,1);
imshow(uint8(a));
xtitle("Image 1");
subplot(1,3,2);
imshow(uint8(b));
xtitle("Image 2");
subplot(1,3,3);
imshow(avg);
xtitle("Averaged Image");


% PRACTICAL NO: 3
% AIM: Program to compare images using subtraction
% for enhancing the difference between images.
clc;
clear;
a = double(imread("C:\ip\image.jpg"));
b = double(imread("C:\ip\image.jpg"));
c = uint8(abs(a-b));
subplot(1,3,1);
imshow(uint8(a));
xtitle("Image 1");
subplot(1,3,2);
imshow(uint8(b));
xtitle("Image 2");
subplot(1,3,3);
imshow(c);
xtitle("Subtracted Image");


// PRACTICAL NO: 4
// AIM: Image Enhancement Statistical Filters.
// Apply Mean Filter to the input image and display
// the resulting image.

clc;
clear;
close;

// Read grayscale image
img = imread("D:\gray.jpeg");
img = double(img);
[m, n] = size(img);
filtered = zeros(m, n);

// 3x3 Mean Filter
for i = 2:m-1
    for j = 2:n-1
        window = img(i-1:i+1, j-1:j+1);
        filtered(i,j) = sum(window) / 9;
    end
end

filtered = uint8(filtered);

// Display images
figure();
subplot(1,2,1);
imshow(uint8(img));
title("Original Image");

subplot(1,2,2);
imshow(filtered);
title("Mean Filtered Image");

// PRACTICAL NO: 4
// AIM: Apply Median Filter to the input image
// and display the resulting image.

clc;
clear;
close;

// Read grayscale image
img = imread("D:\gray.jpeg");
img = double(img);

[m, n] = size(img);
filtered = img;

// 3x3 Median Filter
for i = 2:m-1
    for j = 2:n-1
        window = img(i-1:i+1, j-1:j+1);
        pixels = matrix(window, 1, 9);
        filtered(i,j) = median(pixels);
    end
end

filtered = uint8(filtered);

// Display images
figure();
subplot(1,2,1);
imshow(uint8(img));
title("Original Image");

subplot(1,2,2);
imshow(filtered);
title("Median Filtered Image");
// PRACTICAL NO: 4
// AIM: Apply Max-Min and Min-Max Filters
// to the input image and display the results.

clc;
clear;
close;

// Read grayscale image
img = imread("D:\gray.jpeg");
img = double(img);

[m, n] = size(img);

max_filtered = img;
min_filtered = img;
maxmin_filtered = img;

// Max-Min Filter (3x3)
for i = 2:m-1
    for j = 2:n-1
        window = img(i-1:i+1, j-1:j+1);

        max_filtered(i,j) = max(window);
        min_filtered(i,j) = min(window);

        maxmin_filtered(i,j) = (max(window) + min(window)) / 2;
    end
end

// Convert to uint8
max_filtered = uint8(max_filtered);
min_filtered = uint8(min_filtered);
maxmin_filtered = uint8(maxmin_filtered);

// Display results
figure();

subplot(2,2,1);
imshow(uint8(img));
title("Original Image");

subplot(2,2,2);
imshow(max_filtered);
title("Max Filter");

subplot(2,2,3);
imshow(min_filtered);
title("Min Filter");

subplot(2,2,4);
imshow(maxmin_filtered);
title("Max-Min Filter");

% PRACTICAL NO: 5
% AIM: Perform Erosion operation on an input image
% and display the resulting image.
clc;
clear all;
a = imread('E:\IMGPROCESSING\erosion.png');
structEle = imcreatese('ellipse',5,5);
erosion = imerode(a,structEle);
subplot(1,2,1);
imshow(a);
title('Original Image');
subplot(1,2,2);
imshow(erosion);
title('Eroded Image 1');


% PRACTICAL NO: 5
% AIM: Perform Dilation operation on an input image
% and display the resulting image.
clc;
clear all;
a = imread('E:\IMGPROCESSING\erosion.png');
structEle = imcreatese('ellipse',15,15);
dilation = imdilate(a,structEle);
subplot(1,2,1);
imshow(a);
title('Original Image');
subplot(1,2,2);
imshow(dilation);
title('Dilated Image 1');


% PRACTICAL NO: 5
% AIM: Perform Opening operation on an input image
% and display the resulting image.
clc;
clear all;
I = imread("C:\ip\images.png");
sturctEle = imcreatese('ellipse',20,20);
erosion = imerode(I,sturctEle);
opening = imdilate(erosion,sturctEle);
subplot(1,2,1);
imshow(I);
title('Original Image');
subplot(1,2,2);
imshow(opening);
title('Opening Image');



% PRACTICAL NO: 5
% AIM: Perform Closing operation on an input image
% and display the resulting image.
clc;
clear all;
I = imread("C:\ip\image.JPG");
sturctEle = imcreatese('ellipse',20,20);
dilation = imdilate(I,sturctEle);
closing = imerode(dilation,sturctEle);
subplot(1,2,1);
imshow(I);
title('Original Image');
subplot(1,2,2);
imshow(closing);
title('Closing Image');



% PRACTICAL NO: 5
% AIM: Perform Boundary Extraction on an input image.
clc;
clear all;
I = imread("C:\ip\images.png");
sturctEle = imcreatese('ellipse',30,30);
erosion = imerode(I,sturctEle);
boundry = I - erosion;
subplot(2,2,1);
imshow(I);
title('Original Image');
subplot(2,2,2);
imshow(erosion);
title('Eroded Image');
subplot(2,2,3);
imshow(boundry);
title('Boundary Image');



% PRACTICAL NO: 5
% AIM: Perform Morphological Gradient on an input image.
clc;
clear all;
I = imread("C:\ip\images.png");
sturctEle = imcreatese('ellipse',30,30);
dilation = imdilate(I,sturctEle);
erosion = imerode(I,sturctEle);
gradient = dilation - erosion;
subplot(2,2,1);
imshow(I);
title('Original Image');
subplot(2,2,2);
imshow(dilation);
title('Dilated Image');
subplot(2,2,3);
imshow(erosion);
title('Eroded Image');
subplot(2,2,4);
imshow(gradient);
title('Morphological Gradient');


% PRACTICAL NO: 5
% AIM: Perform Top-hat transformation on an input image.
clc;
clear all;
I = imread("C:\ip\images.png");
sturctEle = imcreatese('ellipse',30,30);
erosion = imerode(I,sturctEle);
opening = imdilate(erosion,sturctEle);
tophat = I - opening;
subplot(2,2,1);
imshow(I);
title('Original Image');
subplot(2,2,2);
imshow(opening);
title('Opening Image');
subplot(2,2,3);
imshow(tophat);
title('Top-hat Image');


% PRACTICAL NO: 6
% AIM: Write a program to input an image and fill
% the empty region inside the image using Region Filling procedure.
clc;
clear;
S = imread("C:\ip\images.jpg");
S = rgb2gray(S);
BW = im2bw(S);
subplot(1,3,1);
imshow(S);
xtitle("Original Image");
subplot(1,3,2);
imshow(BW);
xtitle("Binary Image");
Filled = imfill(BW, "holes");
subplot(1,3,3);
imshow(Filled);
xtitle("Region Filled Image");


# PRACTICAL NO: 7
# AIM: Read and Display an Image using OpenCV.

import cv2
import numpy as np

img = cv2.imread("C:\\ip\\img.png")
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
# PRACTICAL NO: 7
# AIM: Access Pixel Values of an Image using OpenCV.

import cv2
import numpy as np

img = cv2.imread("C:\\ip\\img.png", 1)
pixel = img[100, 100]
print(pixel)
# PRACTICAL NO: 7
# AIM: Display Image Properties using OpenCV.
import cv2
import numpy as np
img = cv2.imread("C:\\ip\\img.png", 1)
height = img.shape[0]
width = img.shape[1]
channels = img.shape[2]
size1 = img.size
dimensions = img.shape
print("Height:", height)
print("Width:", width)
print("Channels:", channels)
print("Size:", size1)
print("Dimensions:", dimensions)


# PRACTICAL NO: 7
# AIM: Convert an Image into Grayscale using OpenCV.

import cv2
import numpy as np

img = cv2.imread("C:\\ip\\img.png", 1)

cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

cv2.imshow('Gray Image', gray)
cv2.waitKey(0)
cv2.destroyAllWindows()
# PRACTICAL NO: 7
# AIM: Rotate an Image using OpenCV.

import cv2
import numpy as np

img = cv2.imread("C:\\ip\\img.png", 1)

(h, w) = img.shape[:2]

center = (w // 2, h // 2)

M = cv2.getRotationMatrix2D(center, 45, 1.0)

rotated = cv2.warpAffine(img, M, (h, w))

cv2.imshow('Rotated Image', rotated)
cv2.waitKey(0)
cv2.destroyAllWindows()

# PRACTICAL NO: 7
# AIM: Draw a Circle on an Image using OpenCV.

import cv2
import numpy as np

img = cv2.imread("C:\\ip\\img.png", 1)

cv2.circle(img, (80, 80), 55, (0, 255, 0), -1)

cv2.imshow('Circle', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

# PRACTICAL NO: 7
# AIM: Draw a Square on an Image using OpenCV.

import cv2
import numpy as np

img = cv2.imread('C:\\IPMSIT\\img2.jpg', 1)

cv2.rectangle(img, (15,25), (200,150), (0,255,255), 15)

cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

# PRACTICAL NO: 7
# AIM: Draw an Ellipse on an Image using OpenCV.

import cv2
import numpy as np

img = cv2.imread('C:\\IPMSIT\\img2.jpg', 1)

cv2.ellipse(img, (250,150), (80,20), 5, 0, 360, (0,0,255), 15)

cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

# PRACTICAL NO: 7
# AIM: Draw a Line on an Image using OpenCV.

import cv2
import numpy as np

img = cv2.imread('C:\\IPMSIT\\img2.jpg', 1)

cv2.line(img, (10,0), (150,150), (0,0,255), 15)

cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

# PRACTICAL NO: 7
# AIM: Add Text to an Image using OpenCV.

import cv2
import numpy as np

img = cv2.imread("C:\\ip\\img.png", 1)

font = cv2.FONT_HERSHEY_SIMPLEX

cv2.putText(img, 'Hello', (100, 100), font, 1,
            (255, 255, 255))

cv2.imshow('Text', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
# PRACTICAL NO: 7
# AIM: Perform Edge Detection on an Image using OpenCV.

import cv2
import numpy as np

img = cv2.imread('C:\\IPMSIT\\img2.jpg', 1)

cv2.imshow('image', img)

edges = cv2.Canny(img, 100, 200)

cv2.imshow("Edge Detected Image", edges)
cv2.waitKey(0)
cv2.destroyAllWindows()
# PRACTICAL NO: 7
# AIM: Apply Blur (Image Smoothing) using OpenCV.

import cv2
import numpy as np

img = cv2.imread('C:\\IPMSIT\\img5.jpg', 1)

cv2.imshow('image', cv2.blur(img, (5,5)))

cv2.waitKey(0)
cv2.destroyAllWindows()
# PRACTICAL NO: 7
# AIM: Perform Image Thresholding using OpenCV.

import cv2
import numpy as np

img = cv2.imread('C:\\IPMSIT\\img1.jpg', 1)

retval, threshold = cv2.threshold(img, 62, 255, cv2.THRESH_BINARY)

cv2.imshow('Image', threshold)
cv2.waitKey(0)
cv2.destroyAllWindows()

# PRACTICAL NO: 8
# AIM: Perform Video Blurring using OpenCV.

import cv2
import numpy as np

cap = cv2.VideoCapture("C:\\ip\\vid.mp4")

while(cap.isOpened()):

    ret, frame = cap.read()

    if not ret:
        break

    frame = cv2.resize(frame, (540, 380), fx=0, fy=0,
                       interpolation=cv2.INTER_CUBIC)

    cv2.imshow('Frame', frame)

    blur = cv2.GaussianBlur(frame, (5, 5), 0)
    cv2.imshow('Blur', blur)

    if cv2.waitKey(25) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

# PRACTICAL NO: 8
# AIM: Capture Video Frames using OpenCV.

import cv2

vid = cv2.VideoCapture(0)

while(True):

    ret, frame = vid.read()

    cv2.imshow('frame', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

vid.release()
cv2.destroyAllWindows()

# PRACTICAL NO: 8
# AIM: Process Images of Video using OpenCV.

import cv2
import numpy as np

cap = cv2.VideoCapture("C:\\ip\\vid.mp4")

while(cap.isOpened()):

    ret,frame = cap.read()

    if not ret:
        break

    frame = cv2.resize(frame,(540,380),fx=0,fy=0,
                       interpolation = cv2.INTER_CUBIC)

    cv2.imshow('Frame',frame)

    gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)

    Thresh = cv2.adaptiveThreshold(
        gray,255,
        cv2.ADAPTIVE_THRESH_MEAN_C,
        cv2.THRESH_BINARY_INV,11,2
    )

    cv2.imshow('Thresh',Thresh)

    if cv2.waitKey(25)& 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

# PRACTICAL NO: 8
# AIM: Generate Video from Images using OpenCV.

import os
import cv2
from PIL import Image

print(os.getcwd())

os.chdir("C:\\imgFolder")
path = "C:\\imgFolder"

mean_height = 0
mean_width = 0

num_of_images = len(os.listdir('.'))

for file in os.listdir('.'):
    im = Image.open(os.path.join(path,file))
    width,height = im.size
    mean_width += width
    mean_height += height
    im.show()

mean_width = int(mean_width / num_of_images)
mean_height = int(mean_height / num_of_images)

for file in os.listdir('.'):
    if file.endswith(".jpg") or file.endswith(".jpeg") or file.endswith("png"):
        im = Image.open(os.path.join(path,file))
        width_height = im.size
        print(width,height)
        imResize = im.resize((mean_width,mean_height))
        imResize.save(file,'JPEG',quality=95)
        print(im.filename.split('\\')[-1],"is resized")

def generate_video():

    image_folder = '.'
    video_name = 'generatedVideo.avi'

    os.chdir("C:\\imgFolder")

    images = [img for img in os.listdir(image_folder)
              if img.endswith(".jpg") or
              img.endswith(".jpeg") or
              img.endswith("png")]

    print(images)

    frame = cv2.imread(os.path.join(image_folder,images[0]))

    height,width,layers = frame.shape

    video = cv2.VideoWriter(video_name,0,1,(width,height))

    for image in images:
        video.write(cv2.imread(os.path.join(image_folder,image)))

    cv2.destroyAllWindows()
    video.release()

generate_video()

% PRACTICAL NO: 9
% AIM: Read a colour image and segment it into
% RGB planes and display the colour components.
clc;
clear all;
I = imread('E:\IP Prac\original.jpg');
// rows and columns in the image
r = size(I,1);
c = size(I,2);
// creating zero matrices
R = zeros(r,c,3);
G = zeros(r,c,3);
B = zeros(r,c,3);
// storing the corresponding color plane
// red plane
R(:,:,1) = I(:,:,1);
// green plane
G(:,:,2) = I(:,:,2);
// blue plane
B(:,:,3) = I(:,:,3);
subplot(2,2,1);
imshow(I);
title('Original Image');
subplot(2,2,2);
imshow(uint8(R));
title('Red Component');
subplot(2,2,3);
imshow(uint8(G));
title('Green Component');
subplot(2,2,4);
imshow(uint8(B));
title('Blue Component');


% PRACTICAL NO: 9
% AIM: Convert the image from one colour model
% to another colour model (RGB to HSV).
clc;
clear all;
rgb = imread('E:\IP Prac\original.jpg');
hsv = rgb2hsv(rgb);
subplot(2,3,1);
imshow(rgb);
title('Original RGB Image');
subplot(2,3,2);
imshow(hsv);
title('HSV Image');
subplot(2,3,3);
imshow(hsv(:,:,3));
title('Intensity Component');
subplot(2,3,4);
imshow(hsv(:,:,1));
title('Hue Component');
subplot(2,3,5);
imshow(hsv(:,:,2));
title('Saturation Component');


% PRACTICAL NO: 9
% AIM: Convert the image from one colour model
% to another colour model (RGB to YCbCr).
clc;
clear all;
rgb = imread('E:\IP Prac\original.jpg');
ycbcr = rgb2ycbcr(rgb);
subplot(2,3,1);
imshow(rgb);
title('Original RGB Image');
subplot(2,3,2);
imshow(ycbcr);
title('YCBCR Image');
subplot(2,3,3);
imshow(ycbcr(:,:,1));
title('Luminance');
subplot(2,3,4);
imshow(ycbcr(:,:,2));
title('Chrominance Cb');
subplot(2,3,5);
imshow(ycbcr(:,:,3));
title('Chrominance Cr');


% PRACTICAL NO: 9
% AIM: Apply false colouring (pseudo colouring)
% on a grayscale image.
clc;
clear all;
RGB = imread('E:\IP Prac\Original.jpg');
Image = rgb2gray(RGB);
subplot(1,3,1);
imshow(RGB);
title('Original RGB Image');
subplot(1,3,2);
imshow(Image);
title('Gray RGB Image');
subplot(1,3,3);
imshow(Image, jetcolormap(256));
title('Pseudo Color Image');
Histogram = imhist(Image);
figure();
plot(0:255, Histogram);

⚠️Content was pasted as plain text and auto-formatted as a code block. Use the Code Block button in the editor for proper formatting.

← Back to timeline