You are on page 1of 2

KIỂM TRA

Question 1: The two texture images shown below are quite different, but their histograms are identical.
Both images have size 80 × 80, with black (0) and white (1) pixels.

Suppose that both images are blurred with a 3× 3 smoothing mask. Would the resultant
histograms still be the same? Draw the two histograms and explain your answer.

Solution
m=[0 0 0 0 1 1 1 1;
0 0 0 0 1 1 1 1;
0 0 0 0 1 1 1 1;
0 0 0 0 1 1 1 1;
0 0 0 0 1 1 1 1;
0 0 0 0 1 1 1 1;
0 0 0 0 1 1 1 1;
0 0 0 0 1 1 1 1;]
n=[0 1 0 1 0 1 0 1;
1 0 1 0 1 0 1 0;
0 1 0 1 0 1 0 1;
1 0 1 0 1 0 1 0;
0 1 0 1 0 1 0 1;
1 0 1 0 1 0 1 0;
0 1 0 1 0 1 0 1;
1 0 1 0 1 0 1 0;]
subplot(1,2,1),imhist(m);
subplot(1,2,2),imhist(n);

Question 2: Given a gray image I, we want to find all its pixels that are in the domain [a, b]. Design
a matlab function F = f(I, a, b) that returns a binary matrix F that is of the same size as I,
where 1 for pixels satisfying the domain condition and 0 otherwise.

Solution
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................

Question 3: Viết Matlab script thực hiện đếm số đối tượng (5 đối tượng) trong hình sau:

(“Objects must contain at least 50 pixels.”)

Solution
Isp = imread('question3.png');
k=fspecial('gaussian',[5 5],2);
Isp_g=imfilter(Isp,k);
level = graythresh(Isp_g);
bwImg = 1 - im2bw(Isp_g, level);

L = bwlabel(bwImg, 4);
rgbLabel = label2rgb(L, 'jet','k');

subplot(1, 3, 1), imshow(img);


subplot(1, 3, 2), imshow(bwImg);
subplot(1, 3, 3), imshow(rgbLabel);

Question 4: Write a matlab script code to: Detecting a Cell Using Image Segmentation:
- Read in 'cell.tif' , which is an image of a prostate cancer cell.

Solution
I = imread('cell.tif');
figure();

[~,threshold] = edge(I, 'sobel');


A = edge(I, 'sobel',threshold*m);

SE90 = strel('line', 3, 90);

SE3 = strel('line', 3, 0);


B = imdilate(A,[SE90 SE3]);
holefill = imfill(B,'holes');
subplot(2, 2, 1), imshow(I), title('Original Image');
subplot(2, 2, 2), imshow(A), title('Binary Gadient Mask');
subplot(2, 2, 3), imshow(B), title('Dilate Dradient Mask');
subplot(2, 2, 4), imshow(holefill), title('Binary Image with filled holes');

You might also like