remove pixels with certain rgb values
古いコメントを表示
Hi, I want to remove pixels with R value >100 and G value>100, here is my code:
[height width rgb] = size (I); % I is RGB image
for coloum = 1:width
for row =1:height
if (I(row,coloum,1)> 100 && I(row,coloum,2)> 100)
I(row,coloum,1)= 0;
I(row,coloum,2)= 0;
I(row,coloum,3)= 0;
end
end
The error is "Index exceeds matrix dimensions". Does anyone have an idea about this? Thanks in advance.
採用された回答
その他の回答 (1 件)
Jos (10584)
2018 年 2 月 16 日
1 投票
Is I really a 3D array or is the third dimension just 1?
Simply take a look at the value of rgb, after the size(I) command :)
6 件のコメント
Tian Tian
2018 年 2 月 16 日
Jos (10584)
2018 年 2 月 16 日
There is a difference between indexed images (2D, like yours) and true colour images (3D, with RGB triplets in the 3rd dimension). This is explained here:
Tian Tian
2018 年 2 月 16 日
Jos (10584)
2018 年 2 月 16 日
What does size(I) return?
What does a small portion of I, like I(1:4,1:4,:) contain?
Tian Tian
2018 年 2 月 17 日
Tian Tian
2018 年 2 月 17 日
カテゴリ
ヘルプ センター および File Exchange で Image Segmentation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!