Introduction To Image Processing in MATLAB
Introduction To Image Processing in MATLAB
2. Introduction
Image processing is a method to perform some operations on an image, in order to get an enhanced
image or to extract some useful information from it. Image processing is a crucial field with applications
ranging from medical imaging to remote sensing. MATLAB provides powerful tools and functions for
performing various image processing tasks efficiently.
Code
Code
b=imread('img1.jpeg'); % Load the image into a variable
imshow(b); % For display the image
imwrite(b, 'D:/img2.jpg','jpg'); % For saving the image with new name
imwrite(b, 'D:/img2.png','png'); % For changing the image format while saving
% First image in the 1st subplot % Second image in the 2nd subplot % Third image in the 3rd subplot
In this example, we use subplot (1, 3, 1) to create a grid of one row and three columns of subplots, and
we specify the position of each subplot using the third argument. Each subplot is then populated with
an image using imshow, and titles are added to each subplot using the title function.
RGB (Red, Green, Blue): RGB is the most common color space used in digital imaging systems and
displays. In RGB, colors are represented as combinations of red, green, and blue light intensities.
HSV (Hue, Saturation, Value): HSV is often used for color-based image processing tasks, such as
segmentation, because it separates color information from intensity.
LAB (Lightness): LAB is a device-independent color space, meaning that it is not tied to specific display or
capture devices. It is often used for color correction, image processing, and color management tasks
where accurate color representation is important.
Code
% Conversion of RGB image into gray scale % Conversion of RGB image into HSC Space
Code
% Original RGB Image % Remove red effect from image
% Remove green effect from image % Remove blue effect from image
Output
2.6 Arithmetic operation on image using MATLAB
Performing arithmetic operations on images using MATLAB allows you to manipulate pixel values to
achieve various effects or perform specific tasks.
Code
image=imread('img1.jpeg');
Image Fusion: Addition and subtraction operations are commonly used in image fusion techniques to
combine information from multiple images into a single image.
Noise Reduction: Multiplication and division operations can be used to reduce noise in images.
Multiplying an image by a constant value can amplify the signal-to-noise ratio thus increasing the contrast,
while dividing by a constant can attenuate noise.
Code
image_1 = imread('image1.jpeg'); subplot(1,6,1); imshow(image_1);
image_2 = imread('image2.jpeg'); subplot(1,6,2); imshow(image_2)
image_addition = image_1 + image_2; subplot(1,6,3); imshow(image_addition)
image_subtract = image_1 - image_2; subplot(1,6,4); imshow(image_subtraction)
image_multiply = image_1 .* image_2; subplot(1,6,5); imshow(image_multiplication)
image_division = image_1 ./ image_2; subplot(1,6,6); imshow(image_division)