code help for alternate pixel value calculation

2 views (last 30 days)
Hello,
i already have a code running which calculates the value for each pixel in the experiment.
I now want to calculate the same values but for alternate pixels. Can anyone provide me with feedback about how to develop a code for that?
for example, if i have a 5x5 grid, which has 25 pixels. originally the code calculates the value for all the 25 pixels.I now wish to calculate values for only alternate pixels like pixel 1,3,5,11,13,15,21,23,25.
the code used for calculating the values for all pixel is as follows : function [I,A,P,Q,O,m,n,o]= optim1edited(Y_s, sigma_s, delta_x, delta_y, b, s, d, R, H)
%determing the value of the objective function by the variable dwell time appraoch.
% Input Parameters :
%for a 3-D hemispherical shape to be machined,
% R = radius of the 3-D hemisphere
% H = total hieght of the block given
% delta x = delta y = pixel size
%b = beam width diameter (nm)
%s = lenght of cube in x direction (micro m)
%d = length in y direction (micro m)
% Output :
% column matrix comprising of the values of the objective function
% Model Parameters :
n = floor(((d*10^3)/delta_x));
m = floor(((s*10^3)/delta_y));
%o = floor(b/sigma_s);
o=ceil(3*sigma_s/delta_x);
I = zeros(n*m,1);
for j = 1 : 1 :n
for i = 1: 1: m
index_ij = (j-1)*n + i;
index_i = ((i-n/2)-0.5)*delta_x;
index_j = ((j-m/2)-0.5)*delta_y;
I(index_ij,1) = H - (sqrt((R^2-index_i^2-index_j^2)));
%C(index_ij,1) = sqrt((R^2-index_i^2-index_j^2));
end
end
%O = C;
%Determining the row index matrix
%Inputs :
%b = beam width diameter (nm)
%s = lenght of cube in x direction (micro m)
%d = length in y direction (micro m)
% Y_s = the erosion rate (micro m/sec)
% sigma = standard deviation
% xx = co ordiantes of th point being machined
% yy = the co ordinates of the point where the effects of machining are
% observed due to actual process going on at point x_ij
% delta x = delta y = pixel size (nm)
%Outputs :
% a N x 1 matrix comprising of the constant terms. (row matrix)
% a 25 x n matrix comprising of the constant terms. (column index matrix)
% a 5 x 5 matrix comprising of the concerned vlaues which are within the radius of effect of point of application. (25 values)
%Model Parameters :
%n = floor((d*10^3)/b);
%m = floor((s*10^3)/b);
A = [1:m*n];
B = repmat(A,(o+o+1)^2,1);
%Determining the column index matrix
C = zeros(m,n);
i = 0;
for index_i = 1:1:m
for index_j = 1:1:n
C(index_i,index_j) = (i*m) + index_j;
end
i = i+1;
end
C = reshape(1:m*n,m,n);
%K = R;
D = padarray(C,[o o], m*n+1);
%K = E;
E = im2col(D,[o+o+1 o+o+1],'sliding');
%Determining the Value of the 5 x 5 (concerned values) matrix by %the optimal dwell time approach.
%n = floor((d*10^3)/b);
F = zeros(o+o+1,o+o+1);
index_ij = 0; % initilising the value of variable index_ij as zero
for i = -2:1:2
for j = -2:1:2
index_ij = index_ij+1;
F(index_ij) = Y_s/(2*pi)*exp(-((i*delta_x)^2+(j*delta_y)^2)/(2*sigma_s^2));
%F(index_ij) = Y_s/(2*pi)*exp(-(((i-1)+.5)*delta_x)^2+((j-1)+.5)*delta_y)^2)/(2*sigma_s^2));
% value of the concerned terms within the radius of effect
end
end
G = F(:);
H1 = repmat(G,1,m*n);
%L =P;
% Sparse Matrix %
A = sparse(B(:),E(:),H1(:),m*n,m*n+1);
A = A(:,1:m*n);

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!