1. Tutorial 1
Question 1
Assume that humans have the ability to tell the gender and approximate age by looking at
the picture of an unknown person? If a computer can be made to have the same ability,
what kinds of information the computer must possess?
Question 2
Write a program to reduce the size of an image by half.
Question 3
Write a program to count the number of bright pixels (pixel value >= 200) in an image.
Tutorial 1 Solution
Question 2
function halfim
% reduce the image size by half
image = imread('baboon64g.bmp');
imshow(image)
[height, width] = size(image);
y = 1;
for i = 1:2:height
x = 1;
for j = 1:2:width
halfimage(y, x) = image(i, j);
x = x + 1;
end
y = y + 1;
end
figure
imshow(halfimage)
end
Question 3
function [count] = countbrightpixels
% count the number of pixels >= 200
image = imread('lenna_gray.bmp');
[height, width] = size(image);
count = 0;
for i = 1:height
for j = 1:width
if image(i, j) >= 200
count = count + 1;
end
end
end
end