Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
clear
a1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\a\a_0.jpg');
agray = rgb2gray(a1);
%imhist(agray)
binaryImagea = agray > 100; % found from the image histogram
maska = imfill(binaryImagea, 'holes');
%imshow(maska)
maskedRgbImagea = bsxfun(@times, a1, cast(maska, 'like', a1));
%imshow(maskedRgbImagea)
graysegmenta = rgb2gray(maskedRgbImagea);
BW2a = edge(graysegmenta,'Canny', .7, 3);
%imshow(BW2a);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\b\b_0.jpg');
bgray = rgb2gray(b1);
%imhist(bgray)
binaryImageb = bgray > 100; % found from the image histogram
maskb = imfill(binaryImageb, 'holes');
%imshow(maskb)
maskedRgbImageb = bsxfun(@times, b1, cast(maskb, 'like', b1));
%imshow(maskedRgbImageb)
graysegmentb = rgb2gray(maskedRgbImageb);
BW2b = edge(graysegmentb,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\c\c_0.jpg');
cgray = rgb2gray(c1);
%imhist(bgray)
binaryImagec = cgray > 100; % found from the image histogram
maskc = imfill(binaryImagec, 'holes');
%imshow(maskb)
maskedRgbImagec = bsxfun(@times, c1, cast(maskc, 'like', c1));
%imshow(maskedRgbImageb)
graysegmentc = rgb2gray(maskedRgbImagec);
BW2c = edge(graysegmentc,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\d\d_0.jpg');
dgray = rgb2gray(d1);
%imhist(bgray)
binaryImaged = dgray > 100; % found from the image histogram
maskd = imfill(binaryImaged, 'holes');
%imshow(maskb)
maskedRgbImaged = bsxfun(@times, d1, cast(maskd, 'like', d1));
%imshow(maskedRgbImageb)
graysegmentd = rgb2gray(maskedRgbImaged);
BW2d = edge(graysegmentd,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\e\e_0.jpg');
egray = rgb2gray(e1);
%imhist(bgray)
binaryImagee = egray > 100; % found from the image histogram
maske = imfill(binaryImagee, 'holes');
%imshow(maskb)
maskedRgbImagee = bsxfun(@times, e1, cast(maske, 'like', e1));
%imshow(maskedRgbImageb)
graysegmente = rgb2gray(maskedRgbImagee);
BW2e = edge(graysegmente,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\f\f_0.jpg');
fgray = rgb2gray(f1);
%imhist(bgray)
binaryImagef = fgray > 100; % found from the image histogram
maskf = imfill(binaryImagef, 'holes');
%imshow(maskb)
maskedRgbImagef = bsxfun(@times, f1, cast(maskf, 'like', f1));
%imshow(maskedRgbImageb)
graysegmentf = rgb2gray(maskedRgbImagef);
BW2f = edge(graysegmentf,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
g1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\g\g_0.jpg');
ggray = rgb2gray(g1);
%imhist(bgray)
binaryImageg = ggray > 100; % found from the image histogram
maskg = imfill(binaryImageg, 'holes');
%imshow(maskb)
maskedRgbImageg = bsxfun(@times, g1, cast(maskg, 'like', g1));
%imshow(maskedRgbImageb)
graysegmentg = rgb2gray(maskedRgbImageg);
BW2g = edge(graysegmentg,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
h1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\h\h_0.jpg');
hgray = rgb2gray(h1);
%imhist(bgray)
binaryImageh = hgray > 100; % found from the image histogram
maskh = imfill(binaryImageh, 'holes');
%imshow(maskb)
maskedRgbImageh = bsxfun(@times, h1, cast(maskh, 'like', h1));
%imshow(maskedRgbImageb)
graysegmenth = rgb2gray(maskedRgbImageh);
BW2h = edge(graysegmenth,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
i1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\i\i_0.jpg');
igray = rgb2gray(i1);
%imhist(bgray)
binaryImagei = igray > 100; % found from the image histogram
maski = imfill(binaryImagei, 'holes');
%imshow(maskb)
maskedRgbImagei = bsxfun(@times, i1, cast(maski, 'like', i1));
%imshow(maskedRgbImageb)
graysegmenti = rgb2gray(maskedRgbImagei);
BW2i = edge(graysegmenti,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
k1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\k\k_0.jpg');
kgray = rgb2gray(k1);
%imhist(bgray)
binaryImagek = kgray > 100; % found from the image histogram
maskk = imfill(binaryImagek, 'holes');
%imshow(maskb)
maskedRgbImagek = bsxfun(@times, k1, cast(maskk, 'like', k1));
%imshow(maskedRgbImageb)
graysegmentk = rgb2gray(maskedRgbImagek);
BW2i = edge(graysegmenti,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
l1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\l\l_0.jpg');
lgray = rgb2gray(l1);
%imhist(bgray)
binaryImagel = lgray > 100; % found from the image histogram
maskl = imfill(binaryImagel, 'holes');
%imshow(maskb)
maskedRgbImagel = bsxfun(@times, l1, cast(maskl, 'like', l1));
%imshow(maskedRgbImageb)
graysegmentl = rgb2gray(maskedRgbImagel);
BW2l = edge(graysegmentl,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
m1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\m\m_0.jpg');
mgray = rgb2gray(m1);
%imhist(bgray)
binaryImagem = mgray > 100; % found from the image histogram
maskm = imfill(binaryImagem, 'holes');
%imshow(maskb)
maskedRgbImagem = bsxfun(@times, m1, cast(maskm, 'like', m1));
%imshow(maskedRgbImageb)
graysegmentm = rgb2gray(maskedRgbImagem);
BW2m = edge(graysegmentm,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
n1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\n\n_0.jpg');
ngray = rgb2gray(n1);
%imhist(bgray)
binaryImagen = ngray > 100; % found from the image histogram
maskn = imfill(binaryImagen, 'holes');
%imshow(maskb)
maskedRgbImagen = bsxfun(@times, n1, cast(maskn, 'like', n1));
%imshow(maskedRgbImageb)
graysegmentn = rgb2gray(maskedRgbImagen);
BW2n = edge(graysegmentn,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
o1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\o\o_0.jpg');
ogray = rgb2gray(o1);
%imhist(bgray)
binaryImageo = ogray > 100; % found from the image histogram
masko = imfill(binaryImageo, 'holes');
%imshow(maskb)
maskedRgbImageo = bsxfun(@times, o1, cast(masko, 'like', o1));
%imshow(maskedRgbImageb)
graysegmento = rgb2gray(maskedRgbImageo);
BW2o = edge(graysegmento,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
p1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\p\p_0.jpg');
pgray = rgb2gray(p1);
%imhist(bgray)
binaryImagep = pgray > 100; % found from the image histogram
maskp = imfill(binaryImagep, 'holes');
%imshow(maskb)
maskedRgbImagep = bsxfun(@times, p1, cast(maskp, 'like', p1));
%imshow(maskedRgbImageb)
graysegmentp = rgb2gray(maskedRgbImagep);
BW2p = edge(graysegmentp,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
q1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\q\q_0.jpg');
qgray = rgb2gray(q1);
%imhist(bgray)
binaryImageq = qgray > 100; % found from the image histogram
maskq = imfill(binaryImageq, 'holes');
%imshow(maskb)
maskedRgbImageq = bsxfun(@times, q1, cast(maskq, 'like', q1));
%imshow(maskedRgbImageb)
graysegmentq = rgb2gray(maskedRgbImageq);
BW2q = edge(graysegmentq,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
r1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\r\r_0.jpg');
rgray = rgb2gray(r1);
%imhist(bgray)
binaryImager = rgray > 100; % found from the image histogram
maskr = imfill(binaryImager, 'holes');
%imshow(maskb)
maskedRgbImager = bsxfun(@times, r1, cast(maskr, 'like', r1));
%imshow(maskedRgbImageb)
graysegmentr = rgb2gray(maskedRgbImager);
BW2r = edge(graysegmentr,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\s\s_0.jpg');
sgray = rgb2gray(s1);
%imhist(bgray)
binaryImages = sgray > 100; % found from the image histogram
masks = imfill(binaryImages, 'holes');
%imshow(maskb)
maskedRgbImages = bsxfun(@times, s1, cast(masks, 'like', s1));
%imshow(maskedRgbImageb)
graysegments = rgb2gray(maskedRgbImages);
BW2s = edge(graysegments,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\t\t_0.jpg');
tgray = rgb2gray(t1);
%imhist(bgray)
binaryImaget = tgray > 100; % found from the image histogram
maskt = imfill(binaryImaget, 'holes');
%imshow(maskb)
maskedRgbImaget = bsxfun(@times, t1, cast(maskt, 'like', t1));
%imshow(maskedRgbImageb)
graysegmentt = rgb2gray(maskedRgbImaget);
BW2t = edge(graysegmentt,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\u\u_0.jpg');
ugray = rgb2gray(u1);
%imhist(bgray)
binaryImageu = ugray > 100; % found from the image histogram
masku = imfill(binaryImageu, 'holes');
%imshow(maskb)
maskedRgbImageu = bsxfun(@times, u1, cast(masku, 'like', u1));
%imshow(maskedRgbImageb)
graysegmentu = rgb2gray(maskedRgbImageu);
BW2u = edge(graysegmentu,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
v1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\v\v_0.jpg');
vgray = rgb2gray(v1);
%imhist(bgray)
binaryImagev = vgray > 100; % found from the image histogram
maskv = imfill(binaryImagev, 'holes');
%imshow(maskb)
maskedRgbImagev = bsxfun(@times, v1, cast(maskv, 'like', v1));
%imshow(maskedRgbImageb)
graysegmentv = rgb2gray(maskedRgbImagev);
BW2v = edge(graysegmentv,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
w1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\w\w_0.jpg');
wgray = rgb2gray(w1);
%imhist(bgray)
binaryImagew = wgray > 100; % found from the image histogram
maskw = imfill(binaryImagew, 'holes');
%imshow(maskb)
maskedRgbImagew = bsxfun(@times, w1, cast(maskw, 'like', w1));
%imshow(maskedRgbImageb)
graysegmentw = rgb2gray(maskedRgbImagew);
BW2w = edge(graysegmentw,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\x\x_0.jpg');
xgray = rgb2gray(x1);
%imhist(bgray)
binaryImagex = xgray > 100; % found from the image histogram
maskx = imfill(binaryImagex, 'holes');
%imshow(maskb)
maskedRgbImagex = bsxfun(@times, x1, cast(maskx, 'like', x1));
%imshow(maskedRgbImageb)
graysegmentx = rgb2gray(maskedRgbImagex);
BW2x = edge(graysegmentx,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y1=imread('C:\ECE 4132\dataset\my_asl_alphabet_train\y\y_0.jpg');
ygray = rgb2gray(y1);
%imhist(bgray)
binaryImagey = ygray > 100; % found from the image histogram
masky = imfill(binaryImagey, 'holes');
%imshow(maskb)
maskedRgbImagey = bsxfun(@times, y1, cast(masky, 'like', y1));
%imshow(maskedRgbImageb)
graysegmenty = rgb2gray(maskedRgbImagey);
BW2y = edge(graysegmenty,'Canny', .7, 3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
testimage = imread('C:\ECE 4132\dataset\my_asl_alphabet_train\b\b_1.jpg');
testimagegray = rgb2gray(testimage);
testimagebinary = testimagegray > 100;
masktest = imfill(testimagebinary, 'holes');
maskedRgbImagetest = bsxfun(@times, testimage, cast(masktest, 'like', testimage));
graysegmenttest = rgb2gray(maskedRgbImagetest);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%imaqhwinfo('winvideo')
%obj = videoinput('winvideo', 1);
%start(obj);
%preview(obj);
compareImages = {graysegmenta, graysegmentb, graysegmentc, graysegmentd, graysegmente, graysegmentf, graysegmentg, graysegmenth,...
graysegmenti, graysegmentk, graysegmentl, graysegmentm, graysegmentn, graysegmento, graysegmentp, graysegmentq, graysegmentr,...
graysegments, graysegmentt, graysegmentu, graysegmentv, graysegmentw, graysegmentx, graysegmenty};
colorImages = {a1, b1, c1, d1, e1, f1, g1, h1, i1, k1, l1, m1, n1, o1, p1, q1, r1, s1, t1, u1, v1, w1, x1, y1};
corrList = [];
correctIndex = 0;
currentMaxCorr = 0;
for i = 1:numel(compareImages)
lettercorr = normxcorr2(compareImages{i},graysegmenttest);
maxcorrelation = max(abs(lettercorr(:)));
corrList(i) = maxcorrelation;
if maxcorrelation > currentMaxCorr
currentMaxCorr = maxcorrelation;
correctIndex = i;
end
end
disp(corrList)
%Uncomment below for stem plot of cross correlations%
% stem(corrList)
% set(gca, 'XTick', 1:24, 'XTickLabel', {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y'});
% title('Cross correlation of test input b')
% ylabel('normalized cross correlation')
% xlabel('letter')
%imshow(compareImages{correctIndex})
%Uncomment below for figure of image and mask
figure
subplot(1, 3, 1), imshow(testimage)
subplot(1, 3, 2), imshow(masktest)
subplot(1, 3, 3), imshow(colorImages{correctIndex})
%uncomment below for heat map of correlation matrix
%corrMatrix = [];
% for i = 1:numel(compareImages)
% for j = 1:numel(compareImages)
% crossCorr = normxcorr2(compareImages{i},compareImages{j});
% corrMatrix(i, j) = max(abs(crossCorr(:)));
% %disp(normxcorr2(compareImages{i},compareImages{j}));
% end
% end
% imagesc(corrMatrix)
% set(gca, 'XTick', 1:24, 'XTickLabel', {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y'});
% set(gca, 'YTick', 1:24, 'YTickLabel', {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y'});
% set(gca, 'XAxisLocation', 'top')
%C1 = normxcorr2(graysegmenta,graysegmentl);
%maxc = max(abs(C1(:)));
%disp(maxc)