-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_pix_vs_dist.m
More file actions
40 lines (31 loc) · 1.33 KB
/
plot_pix_vs_dist.m
File metadata and controls
40 lines (31 loc) · 1.33 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
function x_rel_dist = plot_pix_vs_dist(pixel_width) %#codegen
%dist_x = [0.3; 0.4; 0.5; 0.6; 0.7; 0.8; 0.9; 1; 1.1; 1.2; 1.3; 1.4; 1.5; 1.6; 1.7; 1.8; 1.9; 2; 2.1; 2.2];
%width_pixels = [280; 181; 169; 140; 127; 100; 92; 84; 77; 72; 70; 64; 59; 54; 49; 48; 46; 45; 44; 42];
%plot (width_pixels, dist_x )
%ylabel('RELATIVE DISTANCE OF TURTLEBOT')
%xlabel('width of turtlebot in pixels')
%% According to the plot we can get the interpolating polynomial which can satisfy the value
% of the y= relative distance and x= width in pixels
%% Taking exponential function to fit the curve:
%x = [.18; .25; .335; .41; .50; .60; .70; .83; .90; 1.00; 1.10; 1.20; 1.30];
%x_rel_dist = 0.3809258 + 4.681089*e^(-0.02398154*pixel_width) use this or bottom one!!
if ~isempty(pixel_width)
%x_rel_dist = 0.04417456 + (1983352 - 0.04417456)/(1 +
%(pixel_width/0.0001949206)^1.120355); older equation
%x_rel_dist = -0.009777765 + (16.48311 + 0.009777765)/(1 +
%(pixel_width/6.138883)^1.024073); new one
% -- Moving Average Filter
%{
window = 20;
b = (1/window)*ones(1,window);
a = 1;
filt_pxl_width = filter(b,a,pixel_width);
%}
%x_rel_dist = 74.788*pixel_width^(-0.966); % 640X480 Image
x_rel_dist = 56.815*pixel_width^(-1.006); % 410X308 Image
%end
%hold on
%plot(x, y)
%xlabel('relative distance')
%ylabel('width in pixels')
end