Filter löschen
Filter löschen

Problem In parfor loop

2 Ansichten (letzte 30 Tage)
Amit
Amit am 24 Dez. 2023
Kommentiert: Matt J am 24 Dez. 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 Kommentar
Matt J
Matt J am 24 Dez. 2023
sometime I am getting empty matrix D.
That most likely means that num_frames=0.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 24 Dez. 2023
Bearbeitet: Matt J am 24 Dez. 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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by