how to take the exact coordinates of non zero values of a matrix
1 view (last 30 days)
Show older comments
I'm trying to take the non zero values of gaussian spots that i generate random. I round my table but I don't take the exact coordinates I think. Could anybody help me with this? Here is my code in which I save the nonzero coordinates.
function[n_min,n_max,max_val,spot,x1,y1,n_z]=generate_spot_7(i,sigma_x,sigma_y,x0,y0,n,min_n,max_n)
new_min=min_n/255;
new_max=max_n/255;
n_min=new_min+(new_max-new_min).*rand;
n_max=(n_min)+(new_max-n_min).*rand;
Z=0;
t=0;
theta=0+i*pi/500;;%allazoume tixaia tis esties ton elipseon
a = cos(theta)^2/2/sigma_x^2 + sin(theta)^2/2/sigma_y^2;
%b=0;
b = -sin(2*theta)/4/sigma_x^2 + sin(2*theta)/4/sigma_y^2 ;
c = sin(theta)^2/2/sigma_x^2 + cos(theta)^2/2/sigma_y^2;
%%%c=1;
[X, Y] = meshgrid(-(n+2*4):.13:(n+2*4), -(n+2*4):.13:(n+2*4));
t=exp( - (a*(X-x0).^2 + 2*b*(X-x0).*(Y-y0) + c*(Y-y0).^2));
MAX=max(t);
o=round(t*100000)/100000;%epeidi einai double kano strogilopoiisi g na paro
n_z=find(o~=(0));
[x1,y1] = ind2sub(size(o),find(o~=0))
s=[n,n];
%[x1,y1] = ind2sub(s,n_z)
max_val=max(MAX);
spot=t;
I observe that when I add the generated spots and i'm going to zero the values of some spots, I zero more pixels than those I want to zero.
0 Comments
Answers (1)
See Also
Categories
Find more on Mathematics and Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!