Avoid for loop to increase processing in image processing.
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Muhammad Farhan Mughal
am 10 Jul. 2019
Kommentiert: Muhammad Farhan Mughal
am 10 Jul. 2019
I have three matrices
labelism is nr x nc binary matrix
colorim is nr x nc x 3 RGB matrix
and skin_img is also nr x nc x 3 RGB matrix with initially all the zeros on it (black image)
I want to use the labelism matrix to create skin_img matrix from colorim matrix.
Following is the code giving perfectly fine answer
for i = 1:nr
for j = 1:nc
if (labelim(i,j) == 1)
skin_img(i,j,:) = colorim(i,j,:);
end
end
end
imshow(uint8(skin_img));
But it is slow for big size images. Is there any way to avoid for loop?
0 Kommentare
Akzeptierte Antwort
Alex Mcaulley
am 10 Jul. 2019
Bearbeitet: Alex Mcaulley
am 10 Jul. 2019
It is just masking your RGB image. Isn't it?
skin_img = repmat(labelism,[1,1,3]).*colorim;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!