MATLAB code to determine the size, maximum and minimum value of color or RGB image
The dimensions of an RGB or color image can be determined by using some of the inbuilt functions in MatLab.
The maximum value of an RGB image can be known by using the function max(max(max(original image))). It is very important to note that the word ‘max’ is to write three times for a color image.
Minimum value of an rgb image can be known by using the function min(min(min(original image))).It is very important to note that the word ‘min’ is to written three times for a colour image.
Size of an rgb image can be known by using the function size(original image).
Matlab code:
warning off;
clc;
clear all;
close all;
%% Reading Images
I2=imread('colourimage.jpg'); %colour image
%% Dimension of images
M2=max(max(max(I2)));
m2=min(min(min(I2)));
s2=size(I2);
fprintf('\n----------------------------------------')
fprintf('\nMaximum Value of image is %d\n',M2)
fprintf('Minimum Value of image is %d\n',m2)
fprintf('Size of image is %d %d %d\n',s2)
MATLAB Code for resizing a grayscale image and rgb image
A grayscale or an RGB image can be resized into 2X,5X,10X,0.25X and 0.1 X by using the function imresize(original image,scale of resize). At first, we should clear the command window, workspace containing variables, and the figure window if it is left open previously.
Matlab Code:
%% Image resize
warning off;
clc;
clear all;
close all;
x=imread('cameraman.tif');
figure,imshow(x),title('Original Image')
s=size(x)
%% Image Resize
a=imresize(x,2);
figure,imshow(a),title('Image resized by 2X')
b=imresize(x,5);
figure,imshow(b),title('Image resized by 5X')
c=imresize(x,10);
figure,imshow(c),title('Image resized by 10X')
d=imresize(x,0.25);
figure,imshow(d),title('Image resized by 0.25X')
e=imresize(x,0.1);
figure,imshow(e),title('Image resized by 0.1X')
More Matlab Tutorials
0 Comments