How to convert this code in vectorize form to be faster?
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
The code below is correct, but I want to vectorize it (and may convert to GPU) to increase the speed.
How can I convert it to vector form?
RF = 4;
inhibatory = 0;
overlap=3;
gap = RF-overlap;
Image1 = rand(30,22);
Image2 = rand(27,19);
Image3 = rand(30,22);
for u=1:size(Image1,1)
for v=1:size(Image1,2)
sum_val=0;
iLowMax=max(ceil((u-(receptiveFieldSize+inhibatory))/(gap-inhibatory)),1);
iHighMax=min(floor((u-1)/(gap-inhibatory))+1, UpperLayerSize(1));
jLowMax=max(ceil((v-(receptiveFieldSize+inhibatory))/(gap-inhibatory)),1);
jHighMax = min(floor((v-1)/(gap-inhibatory))+1, UpperLayerSize(2));
sum_sens = sum(sum(Image2(iLowMax:iHighMax,jLowMax:jHighMax)));
sum_val = sum_sens(:,:) .* Image3(u,v);
act_output = Image1(u,v);
result(u,v) = de_activate_Mat(act_output,act_funct) .* sum_val;
end
end
Réponses (0)
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!