Effacer les filtres
Effacer les filtres

Problem In parfor loop

2 vues (au cours des 30 derniers jours)
Amit
Amit le 24 Déc 2023
Commenté : Matt J le 24 Déc 2023
Hello All.
Here, k is image matrix with size of 2920x3756x501; 501= frame number. I want to get the intensity profile for all of these frames from the the specific X and Y co-ordinates value. In 2nd for loop, I was trying to align signals. I was trying the computation in parfor lop for both of the for loop. Getting continoulsy error , sometimw showing warning of broadcast variable, or sometime I am getting empty matrix D.
Assistance is genuinely appreciated !!!
Thank you
function [D] = ReducedData_DelayShift_Calculate(x_coordinates, y_coordinates,c_ref,num_frames)
% Initialize a matrix to store improfile data
improfile_data_matrix = [];
D = zeros(1,num_frames);
k = load("reduced_data.mat");
for i = 1:num_frames
% Extract the i-th frame from the image matrix
current_frame = k.images_resized(:, :, i);
% Compute the improfile
improfile_data = squeeze(improfile(current_frame, x_coordinates, y_coordinates));
% Append the improfile data to the matrix
improfile_data_matrix = [improfile_data_matrix improfile_data(:,1)];
end
for i = 1:num_frames
current_frame = improfile_data_matrix(:, i);
[~ ,~ ,D(i)] = alignsignals((c_ref(:)),(current_frame(:)),Method="xcorr");
end
end
  1 commentaire
Matt J
Matt J le 24 Déc 2023
sometime I am getting empty matrix D.
That most likely means that num_frames=0.

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 24 Déc 2023
Modifié(e) : Matt J le 24 Déc 2023
I would get rid of the first for-loop and use interp3
function [D] = ReducedData_DelayShift_Calculate(x_coordinates, y_coordinates,c_ref,num_frames)
k = load("reduced_data.mat");
[xq,zq]=ndgrid( linspace( x_coordinates(1), x_coordinates(2),2000 ), 1:num_frames );
yq=repmat( linspace( y_coordinates(1), y_coordinates(2),2000 )' ,1,width(xq));
improfile_data_matrix = ...
reshape( interp3(k.images_resized, xq(:),yq(:),zq(:)) ,[],num_frames);
D = zeros(1,num_frames);
parfor i = 1:num_frames
current_frame = improfile_data_matrix(:, i);
[~ ,~ ,D(i)] = alignsignals( c_ref(:), current_frame(:) ,Method="xcorr");
end
end

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by