Simple Image Processing Optimisation
7 views (last 30 days)
Show older comments
I have a simple image processing application that is working fine, but I think it could be vectorised and sped up substantially. I've had a shot but am having trouble with it.
The idea is to take a series of images and get
- timex: time exposure (the average of each pixel over time)
- immax: each pixel with the maximum intensity over time
- immix: each pixel with the minimum intensity over time
Working code:
im_stack=[timestep,x_pixel,y_pixel,[red,green,blue,intensity]]
timex = nan(x,y,3); immax = timex; immin = timex; %preallocate
for i = 1:x
for j = 1:y
for k = 1:z
timex(i,j,k)= mean(im_stack(:,i,j,k));
end
[~,a] = max(im_stack(:,i,j,4));%from intensity values
immax(i,j,1:3)= im_stack(a,i,j,1:3);
[~,a] = min(im_stack(:,i,j,4));
immin(i,j,1:3)= im_stack(a,i,j,1:3);
end
end
timex=uint8(timex);
immax=uint8(immax);
immin=uint8(immin);
3 Comments
Answers (1)
Walter Roberson
on 9 Jul 2016
As a start:
With no loops needed,
timex = squeeze( mean(im_stack(:,:,:,1:z)) );
And if z is the same as size(im_stack,4) then it would simplify to
timex = squeeze( mean(im_stack) );
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!