Professional Documents
Culture Documents
(K00371921)
IMAGE MEASUREMENT EXERCISES
E4.1 Develop a program that computes the extrema of the RGB components of
an unsigned integer, 8-bit, color image. Steps:
o (a) Display the source color image.
o (b) Compute extrema of the color image and print results for all
bands.
The PIKS API executable example_extrema_colour performs this exercise.
S = dbstack('-completenames');
[pathstr,name,ext] = fileparts(S(1).file)
Imgpath = strcat(pathstr, '\', 'roma.jpg');
Image = imread(Imgpath);
imshow(Image);
red_max = max(max(Image(:,:,1)))
red_min = min(min(Image(:,:,1)))
green_max = max(max(Image(:,:,2)))
green_min = min(min(Image(:,:,2)))
blue_max = max(max(Image(:,:,3)))
blue_min = min(min(Image(:,:,3)))
ROMA PATEL
(K00371921)
pathstr =C:\Users\K.D.Patel\Desktop
name =diptwoqne
ext =.m
red_maxima = 255
red_minima = 0
green_maxima = 255
green_minima = 11
blue_maxima = 255
blue_minima = 0
ROMA PATEL
(K00371921)
E4.2 Develop a program that computes the mean and standard deviation of an
unsigned integer, 8-bit, monochrome image. Steps:
o (a) Display the source monochrome image.
o (b) Compute moments of the monochrome image and print
results.
The PIKS API executable example_moments_monochrome performs this
exercise.
S = dbstack('-completenames');
[pathstr,name,ext] = fileparts(S(1).file)
Imgpath = strcat(pathstr, '\', 'roma.jpg');
Img = imread(Imgpath);
Img_bw = rgb2gray(Img);
imshow(Img_bw);
disp('Mean of Image');
Img_mean = mean2(Img_bw)
disp('Standard Deviation of Image');
Img_sd = std2(Img_bw)
% Calculate Ordinary Moments
p = 2; q = 2;
disp(' Ordinary Moment of Image');
Img_mom = mom(Img_bw, p,q)
% Calculate Central Moments
disp('Central Moment of Image');
central_mom = centmom(Img_bw,p,q)
% Normalize Moments
disp('Normalize Moment of Image');
gamma = (0.5*(p+q)) + 1;
Normalized = (centmom(Img_bw, p, q))/(mom(Img_bw, 0, 0)^gamma)
ROMA PATEL
(K00371921)
pathstr = C:\Users\K.D.Patel\Desktop
name =diptwotwo
ext =.m
Mean of Image
Img_mean = 138.0721
ROMA PATEL
(K00371921)
Central Moment of Image
central_mom = 2.7316e+14
S = dbstack('-completenames');
[pathstr,name,ext] = fileparts(S(1).file)
Imgpath = strcat(pathstr, '\', 'roma.jpg');
Image = imread(Imgpath);
Img_bw = rgb2gray(Image);
imshow(Img_bw);figure(1);
%compute first-order histogram
[counts,x] = imhist(Img_bw, 16);
counts'
x'
figure(2);
plot(x, counts, '*');
hold on;
plot(x, counts);
ROMA PATEL
(K00371921)
hold off;
ROMA PATEL
(K00371921)
>> Untitled5
pathstr =
C:\Users\K.D.Patel\Desktop
name =
Untitled5
ext =
.m
ans =
Columns 1 through 10
0
682105
3858
657016
320931 1046692
1164580
900608
685261
596449
Columns 11 through 16
887501
315178
332003
260736
92998
44356
ans =
0
255
17
34
51
68
ROMA PATEL
(K00371921)