How can I vectorize the following code?
Ältere Kommentare anzeigen
main.m
I = imread('bear.png');
J = rgb2gray(imread('marked_bear.png'));
mask = I-J;
for r=1:size(I,1)
for c=1:size(I,2)
if(mask(r,c))
I = some_function(I, r, c);
end
end
end
imshow(I);
some_function.m
function I = some_function(I, r, c)
% some processing on image 'I'
I(r,c) = 255;
bear.png

marked_bear.png

Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Image Arithmetic finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!