Simple Image Processing Optimisation
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 9 Juil 2016
Could you clarify what is special about im_stack(:,:,:,4) compared to im_stack(:,:,:,1:3) ? And what values is z ?
Ben Modra
le 9 Juil 2016
Ben Modra
le 14 Juil 2016
Réponses (1)
Walter Roberson
le 9 Juil 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) );
1 commentaire
Ben Modra
le 9 Juil 2016
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!