idx = ~ismember(color_array,[color_1; color_2; color_3],'rows'); color_array(idx,:) = repmat(color_4,nnz(idx),1);
Replace all rows of an array not equal to any row of another array by a particular row vector
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
atharva aalok
am 14 Aug. 2023
Beantwortet: Voss
am 14 Aug. 2023
I import an image and have ordered the rgb values in a n-by-3 array with columns as r, g, b respectively. This is named:
color_array
I also have 3 other row vectors that store r, g, b values for 3 different colors as:
color_1 = [r1, g1, b1];
color_2 = [r2, g2, b2];
color_3 = [r3, g3, b3];
I want to replace all the rows of my original color_array that are not equal to any of color_1, color_2 or color_3 with a fourth color:
color_4 = [r4, g4, b4];
and keep those that are equal to one of these 3 colors intact.
How can I do this as computationally fast as possible?
0 Kommentare
Akzeptierte Antwort
Voss
am 14 Aug. 2023
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!