forked from marcusstenbeck/tnm034-qr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtnm034.m~
More file actions
71 lines (55 loc) · 2.71 KB
/
tnm034.m~
File metadata and controls
71 lines (55 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function strout = tnm034(imin)
% DESCRIPTION
% A function that removes noise from the supplied image
% PARAMETERS
% IN:
% imin: The input image of the captured QR-code.
% OUT:
% strout: The resulting character string of the coded message.
% The string must be in a pre-defined format given in the course description.
image = imread(imin); % reads the given image
double_image = im2double(image); % turning the pixel-values into double-values
normalized_image = double_image / max(double_image(:)); % normalizes between 0 and 1
[height, width] = size(normalized_image);
% Hård tröskling... ändra?
normalized_image(normalized_image<0.5) = 0;
normalized_image(normalized_image>=0.5) = 1;
im_edges = edge_detection(normalized_image);
% Hård tröskling... OK?
im_edges(im_edges<0.1) = 0;
im_edges(im_edges>=0.1) = 1;
% pre-allocate variables to speed up the program
T = zeros(height, width);
P = zeros(height, width);
Q = zeros(height, width);
B = zeros(height, width);
% Testning av hur man bygger "axlarna"
%tjena = [[400 300]; flipdim(find_edge_positions(im_edges, [400 300], [0 -1]), 1); find_edge_positions(im_edges, [400 300], [0 1])];
%tjena(:,2)
elements = 1:numel(im_edges);
% x_axis = 7 värden ifrån (y,x) i x-led där x[0]= (y,x)
%x_axis = arrayfun(create_axis, x, y, [0 1])
tic
%arrayfun(@(x) find_edge_positions(im_edges, [height, width], x, [0 1]), elements, 'UniformOutput', false);
arrayfun(@(x) find_edge_positions(im_edges, x, -[0 1]), elements, 'UniformOutput', false);
%find_edge_positions(im_edges, [height, width], 1601, [0 1])
toc
% x_axis = [yx; flipdim(find_edge_positions(im_edges, [y x], [0 -1]), 1); find_edge_positions(im_edges, [y x], [0 1])];
% x_axis = x_axis(:,2);
% y_axis = [[y x]; flipdim(find_edge_positions(im_edges, [y x], [-1 0]), 1); find_edge_positions(im_edges, [y x], [1 0])];
% y_axis = x_axis(:,1);
% use x- and y-axis as r- and s- axis temporarily
% r_axis = x_axis;
% s_axis = y_axis;
% r_axis = 7 värden ifrån (y,x) i r-led
% s_axis = 7 värden ifrån (y,x) i s-led
% T(y,x) = ( central_symmetry(x_axis) + central_symmetry(y_axis) + central_symmetry(r_axis) + central_symmetry(s_axis) )/4;
% P(y,x) = ( ratio_characteristic(x_axis) + ratio_characteristic(y_axis) + ratio_characteristic(r_axis) + ratio_characteristic(s_axis) )/4;
% Q(y,x) = ( square_characteristic(x_axis,y_axis) + square_characteristic(r_axis, s_axis) )/2;
% B(y,x) = ( T(y,x) + P(y,x) + Q(y,x) )/3;
%localization(normalized_image);
%noise(normalized_image); % calls a function to remove all the noise in the picture
%imshow(normalized_image);
%text = getinfo(img);
%strout=char(text); % the output
return;