Make code for svm region descriptors more efficient
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sandra Roth
el 9 de Mzo. de 2017
Comentada: Sandra Roth
el 16 de Mzo. de 2017
I'm having a rather large image (32000 x 32000) where I have detected regions of interest ("blobs" of approx. size of 150 cells). In the end I would like to have a Mean/Standard deviation descriptor for each region/blob to feed into a svm.
I've written the following function, which worked fine for smaller image subsets (6000x10000), to test the code. But when applying it on the whole image (32000x32000) it already takes ages to calculate the descriptor for 400 regions (and I will have to calculate it for over a million regions in the end).
dimDescriptor = size(Image,3)*2;
MeStdDescriptor = zeros(size(points,1),dimDescriptor);
for i = 1:size(points,1)
for band = 1:size(Image,3)
banddata = Image(:,:,band);
MeStdDescriptor(i,band) = mean(banddata(regionMask==i));
MeStdDescriptor(i,band+4) = std(banddata(regionMask==i));
end
end
"Points" is a vector with all the unique numbers of my regions/blobs (here 1:400). "regionMask" is a mask (same size as image), which I have created in advance, where every region/blob has a unique number and the rest is zero.
Does anybody have a suggestion of how to improve this code to make it faster? Thank you very much!
0 comentarios
Respuesta aceptada
Kushagr Gupta
el 15 de Mzo. de 2017
There are various different approaches that you could make use of to improve the speed, for example resizing, preprocessing the dataset into smaller segments among others.
Following are some ideas that may help:
1. Resizing the image into a smaller image which still contains useful information. Go through the documentation of the ' imresize ' function to see if it could help.
2. Extracting required information over segments. Another MATLAB Answers post discusses this: Extract Mean over segments
3. If you have access to GPU hardware, 'gpuArray' could help in making the code run faster. Go through the documentation of ' gpuArray ' to learn more.
4. There is also the Parallel Computing Toolbox which is again requires more hardware resources, but executes tasks in parallel (as the name suggests) and can prove to be handy for such applications.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!