Problem In parfor loop

2 次查看(过去 30 天)
Amit
Amit 2023-12-24
评论: Matt J 2023-12-24
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 个评论
Matt J
Matt J 2023-12-24
sometime I am getting empty matrix D.
That most likely means that num_frames=0.

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2023-12-24
编辑:Matt J 2023-12-24
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by