Archive

Archive for the ‘probability’ Category

Gaussian Masks

April 8, 2008 1 comment

Gaussian Masks (2D Normal Distribution)

Just Placing Masks so that one does not have to generate again when wanting to use quickly.

For the Matlab Code  you can go to https://whatevericode.wordpress.com/2008/03/24/genrating-gaussian-mask/

Standard Deviation 1

0.0030    0.0133    0.0219    0.0133    0.0030
0.0133    0.0596    0.0983    0.0596    0.0133
0.0219    0.0983    0.1621    0.0983    0.0219
0.0133    0.0596    0.0983    0.0596    0.0133
0.0030    0.0133    0.0219    0.0133    0.0030

Standard Deviation 0.5

0.0113    0.0838    0.0113
0.0838    0.6193    0.0838
0.0113    0.0838    0.0113

Standard Deviation 0.25

0.0000    0.0003    0.0000
0.0003    0.9987    0.0003
0.0000    0.0003    0.0000

Advertisements

Hexagonal Sampling and Interpolation

April 3, 2008 Leave a comment

%Cartesian Sampling
x1 = -10:0.5:10;
y1 = -10:0.5:10;

[x y]= meshgrid(x1, y1);
f = cos(cos(sqrt(x.^2+y.^2)));
figure;
imagesc(f);
figure
mesh(x,y, f);

%the sampling lattice is
%[x y]’ = |sqrt(3)/2 0| |i|
% |1/2 1| |j|
%hexagonal smapling
i = x;
j = y;
x = i*sqrt(3)/2 +0;
y = i*1/2 + j;
%x = i*sqrt(3)/2 +0;
f = cos(cos(sqrt(x.^2+y.^2)));
figure;
imagesc(f);
figure
mesh(x,y, f);

%TRYING TO RECOVER ORIGNAL SAMPLING
%i = -20:0.1/1.5:20;
minx = min(x(:));
maxx = max(x(:));
miny = min(y(:));
maxy = max(y(:));

miny = y(1,end);
maxy = y(end,1);

i = minx:0.5/4:maxx;
j = miny:0.5/4:maxy;
%j = -20:0.1:20;

[x2d y2d]= meshgrid(i, j);
figure;
plot(x2d,y2d, ‘b.’);hold on; plot(x,y, ‘r*’)

v = zeros(size(x2d));
for i=1:size(x2d,1)
i
for j=1:size(x2d,2)
b = boxSplineD2(x-x2d(i,j),y- y2d(i,j));
v(i,j)= sum(sum(b.*f));

end
end

figure;
imagesc(v);
figure
mesh(x2d,y2d, v);

Genrating Gaussian Mask

March 24, 2008 Leave a comment

Matlab file for the Gaussian Mask

For some of the masks already generated you can go to https://whatevericode.wordpress.com/2008/04/08/gaussian-masks/

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function mask =gaussMask(stdIn)
varIn = stdIn*stdIn;
T = 0.1;
halfSize = round(sqrt(-2*log(T)*varIn))
[x y] = meshgrid(-halfSize:halfSize, -halfSize:halfSize);

mask = (1/(2*pi*varIn))*exp(-0.5*(x.^2 + y.^2)/varIn);
weight = sum(sum(mask));

mask = mask./weight;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%