Simple Image Processing Optimisation
显示 更早的评论
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 个评论
Walter Roberson
2016-7-9
Could you clarify what is special about im_stack(:,:,:,4) compared to im_stack(:,:,:,1:3) ? And what values is z ?
Ben Modra
2016-7-9
Ben Modra
2016-7-14
回答(1 个)
Walter Roberson
2016-7-9
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) );
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!