Filter löschen
Filter löschen

create image from timeseries data

13 Ansichten (letzte 30 Tage)
Turbulence Analysis
Turbulence Analysis am 24 Jan. 2024
Kommentiert: Mathieu NOE am 2 Feb. 2024
Hi,
I have time stamp (in microseconds) of the image data stored in array AA and arrays x,y and I contains x,y co-ordinats and intensity. I need to accumulate the data over 200 microseconds to create each image.
x pixel size - 1280;
y pixel size - 720;
  2 Kommentare
DGM
DGM am 24 Jan. 2024
Bearbeitet: DGM am 24 Jan. 2024
The only thing in the mat file is AA.
Turbulence Analysis
Turbulence Analysis am 25 Jan. 2024
I couldn't attached it because of the big size. Now, limited the time and attached the same here.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 25 Jan. 2024
hum , maybe it's because image processing is not my everyday activity but unless I have misunderstood the project you want to create images of size 1280 * 720 (= 921600 pixels) but only specifying the intensity for 200 of them for each image.
so the remaining portion of the image is what ? I decided to init each image with zero valued array , but I may be completely off topic
this is what I can offer, if that makes sense to you
load('matlab1.mat')
data = cd_data.AA;
x = cd_data.x;
y = cd_data.y;
intensity = cd_data.I;
samples = numel(data);
x = x+1 ; % x range must be changed from (0:1279) to (1:1280)
y = y+1 ; % x range must be changed from (0:719) to (1:720)
dt = 1; % sample rate (micro s)
t = dt*(0:samples-1); % time vector
%% home made solution (you choose the amount of overlap)
buffer_size = 200; % how many samples
overlap = 0; % overlap expressed in samples
shift = buffer_size-overlap; % nb of samples between 2 contiguous buffers
nb_of_loops = fix((samples-buffer_size)/shift +1);
im_empty = zeros(1280,720);
for k=1:nb_of_loops
start_index = 1+(k-1)*shift;
stop_index = min(start_index+ buffer_size-1,samples);
xx = x(start_index:stop_index);
yy = y(start_index:stop_index);
Intens = intensity(start_index:stop_index);
im = im_empty; % init im with zeros
% now use the data
for m = 1:buffer_size
im(xx(m),yy(m),k) = Intens(m);
end
% display (optionnal)
imshow(im(:,:,k))
end
  5 Kommentare
Mathieu NOE
Mathieu NOE am 25 Jan. 2024
ok , first I was not aware that on your side the time index start at 844304 , on my side it will be 1
so running my code only for the first iteration will generate this image (attached also)
for k=1:1%nb_of_loops
start_index = 1+(k-1)*shift;
stop_index = min(start_index+ buffer_size-1,samples);
xx = x(start_index:stop_index);
yy = y(start_index:stop_index);
Intens = intensity(start_index:stop_index);
im = im_empty; % init im with zeros
% now use the data
for m = 1:buffer_size
im(xx(m),yy(m),k) = Intens(m);
end
% display (optionnal)
imshow(im(:,:,k))
end
it's not completely blank , the non zero elements are exactly 200 in this first iteration (buffer), but only 200 for 921600 pixels that is only 0.0217 % of the entire image
Turbulence Analysis
Turbulence Analysis am 25 Jan. 2024
I just started playing around with the code which was originally created (long ago) by the supplier of my device. With this I am getting the desired image (also attached here), unfortunately, for one accumulation itselft it takes much longer time.
Attached is the data for just one accumulation (i.e. 844304 - 844504)
Here cd_img is my final output which contains the image
clear mov frame_idx last_frame_ts cd_img
width = 1280;
height = 720;
acc_time = 200;
framerate = 10000;
frame_time = 100 % in microseconds
% Initialize state storage
cd_img = 0.5*ones(height, width);
ts_img = zeros(height, width);
last_frame_ts = 0;
frame_idx = 1;
%% Build a figure for movie display and store the first empty frame
figure();
image(cd_img);
colormap jet;
colormap_size = size(colormap, 1);
frame_idx = frame_idx+1;
%%
for i=1:length(cd_data.ts)
% Get timestamp of current event
cur_ts = cd_data.ts(i);
% Check if images should be generated
while (cur_ts > last_frame_ts + frame_time)
% Update frame by removing old events
last_frame_ts = last_frame_ts + frame_time;
cd_img(ts_img < last_frame_ts - acc_time) = 0.5;
% scale and display image
ax = gca;
image(colormap_size*cd_img);
set(gca,'TickLabelInterpreter','latex')
set(gca, 'FontSize', 20);
set(gca, 'fontweight', 'bold');
xlabel('x(pixel)','fontweight','bold','FontSize',20,'Interpreter','latex');
ylabel('y(pixel)','fontweight','bold','FontSize',20,'Interpreter','latex');
%mov(frame_idx) = getframe();
%writeVideo(mov(frame_idx))
frame_idx = frame_idx+1;
end
% Add event to state
if cd_data.p(i) == 1
% Put a white dot for ON events
cd_img(cd_data.y(i), cd_data.x(i)) = 1;
else
% Put a black dot for OFF events
cd_img(cd_data.y(i), cd_data.x(i)) = 0;
end
ts_img(cd_data.y(i), cd_data.x(i)) = cur_ts;
% thisBaseFileName = sprintf('SS%4.5d.bmp', i); % Base output file name.
% saveas(gcf,thisBaseFileName)
%clf
% i
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Turbulence Analysis
Turbulence Analysis am 25 Jan. 2024
Actually your code sums up first 200 rows, but not 200 micro seconds that's why intensity appeared only in the small portion of the image. What I looking for is summing up data correponds to 200 microseconds, which means in the recently attached data set this corresponds to row 1 - row 6105 ( i.e. 844504 - 844304 = 200 microseconds).
  15 Kommentare
Turbulence Analysis
Turbulence Analysis am 2 Feb. 2024
Thank you very much for your kind support!
Mathieu NOE
Mathieu NOE am 2 Feb. 2024
as always, my pleasure !

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by