Styles ECE 4850 Homework 1 Due 1/30/2018 Using Matlab software to find the follo
ID: 2267544 • Letter: S
Question
Styles ECE 4850 Homework 1 Due 1/30/2018 Using Matlab software to find the following information of the attached image (You need to save the image using either jgp or png format. Other formats will cause changes in pixels of the image): 1. Total number of pixels in the image in x and y directions 2. Find and plot the variation of R, G, and B vales of the image along x direction. 3. Find the pixel locations (measured from the left edge) of the dark lines in the image. 4. Change the dark lines to white color and display the new image.Explanation / Answer
% Read the image from the file
[filename, pathname] = uigetfile('*.bmp;*.tif;*.jpg;*.pgm','Pick an M-file');
img = imread(filename);
img = imresize((img),[256 256]);
[ row col p ] =size(img);
fprintf('size of this image is');
row
col
figure (1);
a=[row col 1];
a=a(:);
plot(a);
title('variation in red');
b=[row col 2];
b=b(:);
figure (2);
plot(b);
title('variation in green');
c=[row col 1];
c=c(:);
figure (3);
plot(c);
title('variation in blue');
if (p == 3)
d = rgb2gray(img);
end
g=medfilt2(d,[3 3]); % Median filtering to remove noise.
se=strel('disk',1); % Structural element (disk of radius 1) for morphological processing.
gi=imdilate(g,se); % Dilating the gray image with the structural element.
ge=imerode(g,se); % Eroding the gray image with structural element.
figure(4);
imshow(ge);
gdiff=imsubtract(gi,ge); % Morphological Gradient for edges enhancement.
imshow(gdiff); % HERE WE CAN ABLE TO SEE BLACK LINES HERE FROM LEFT TO RIGHT
figure(5);
p=gdiff(:);
plot(p);
fclose(fid)