How to assign rgb values to multiple row,col of a matrix ?

3 Ansichten (letzte 30 Tage)
RuiQi
RuiQi am 17 Jan. 2017
Beantwortet: Guillaume am 17 Jan. 2017
for i=1:2%max(label(:))
[rows, cols] = find(label == i);
image(rows,cols,:) = [0,0,0];
end
but I get the error subscripted assignment dimension mismatch

Antworten (2)

Adam
Adam am 17 Jan. 2017
doc sub2ind

Guillaume
Guillaume am 17 Jan. 2017
If the R, G and B values are identical:
image(sub2ind(size(image), repmat(rows, 1, 3), repmat(cols, 1, 3), repmat([1 2 3], numel(rows), 1)) = 0;
If not,
image(sub2ind(size(image), repmat(rows, 1, 3), repmat(cols, 1, 3), repmat([1 2 3], numel(rows), 1)) = repmat([R G B], numel(rows), 1);
unfortunately, neither is particularly straightforward.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by