Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pleae Use Matlab! 1. Testing the functionality of image segmentation techniques

ID: 646838 • Letter: P

Question

Pleae Use Matlab!

1. Testing the functionality of image segmentation techniques and comparing their accuracy requires us to work with images for which the correct segmentation is known. Develop some test images by:

(a) Create an image SEG1 containing artificial objects on a background of constant gray-level. Generate simple geometric objects such as squares, rectangles, diamonds, stars, circles, etc., each having a constant gray-level different from that of the background, some of them darker and some brighter than the background. Determine the area of each object and store it in an appropriate form.

(b) Superimpose additive Gaussian noise with a given standard deviation, thus creating an image SEG2.

(c) Superimpose random impulse noise of a given severity over the image SEG2, thus creating an image SEG3.

By varying the shapes of the objects, standard deviation of the Gaussian additive noise, and severity of the impulse noise, sets of controlled properties can be generated. To create a simple set of images for segmentation experiments, make a single image SEG1, apply three levels of Gaussian additive noise, and three levels of impulse noise. You will obtain a set of ten images that will be used in the segmentation problems below.

Explanation / Answer

% Create a black triangle

figure

x = [0.25, 1.0, 1.0];

y = [0.25, 0.25, 1.0];

fill(x, y, 'b')

hold on


% Create an black diamond

x = [2.0, 2.25, 2.0, 1.75];

y = [1.25, 1.55, 2.25, 1.5];

c = [0 0 0];

fill(x, y, c)


% Create a black rectangle

left = 3.0;

right = left + 0.5;

bottom = 1.0;

top = bottom + 1;

x = [left left right right];

y = [bottom top top bottom];

fill(x, y, 'b')


% Create a purple transparent circle

xc = 3.0;

yc = 1.0;

r = 0.5;

x = r*sin(-pi:0.1*pi:pi) + xc;

y = r*cos(-pi:0.1*pi:pi) + yc;

c = [0.6 0 1];

fill(x, y, c, 'FaceAlpha', 0.4)


% Create a black star

xc = 1.0;

yc = 3.0;

t = (-1/4:1/10:3/4)*2*pi;

r1 = 0.5;

r2 = 0.2;

r = (r1+r2)/2 + (r1-r2)/2*(-1).^[0:10];

x = r.*cos(t) + xc;

y = r2 - r.*sin(t) + yc;

c = [0 0 0];

fill(x, y, c)


% Create a black transparent ellipse

xc = 0.75;

yc = 2.5;

x = 0.4*sin(-pi:0.1*pi:pi) + xc;

y = 0.7*cos(-pi:0.1*pi:pi) + yc;

c = [0 0 0];

fill(x, y, c, 'FaceAlpha', 0.2)


% Create a black stop sign

t = (1/16:1/8:1)'*2*pi;

x = 0.4*sin(t) + 3;

y = 0.4*cos(t) + 3;

fill(x, y ,'b', 'FaceAlpha', 1)


% Set the axis limits

axis([0 4 0 4])

axis square


% Add a title

title('Filled Polygons')


colormap(gray) % use gray colors


a = rand(128);

imwrite(uint8(a * 255), gray(256), 'MyTiff.tif');