Azzera filtri
Azzera filtri

Problem In parfor loop

2 visualizzazioni (ultimi 30 giorni)
Amit
Amit il 24 Dic 2023
Commentato: Matt J il 24 Dic 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 Commento
Matt J
Matt J il 24 Dic 2023
sometime I am getting empty matrix D.
That most likely means that num_frames=0.

Accedi per commentare.

Risposta accettata

Matt J
Matt J il 24 Dic 2023
Modificato: Matt J il 24 Dic 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

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by