0以外の値を平均したいです
조회 수: 38 (최근 30일)
이전 댓글 표시
画像のRGB値からR値、G値、B値(それぞれ0以外の値)の平均値を算出したいです。ご教授よろしくお願いいたします。
下記のプログラムでは0も含んだ平均値となってしまいます
I = imread("");
R = double(I(:,:,1));
G = double(I(:,:,2));
B = double(I(:,:,3));
Rmean = mean2(R);
Gmean = mean2(G);
Bmean = mean2(B);
댓글 수: 0
채택된 답변
Kenjiro Sugimoto
2023년 12월 5일
こちらでいかがでしょうか。
R = [ 1, 0, 0; 0, 1, 0; 0, 0, 1 ];
Rmean = mean(R, "all")
idx = (R ~= 0) % 非ゼロの箇所を取得
Rmean = mean(R(idx), "all")
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 FPGA, ASIC, and SoC Development에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!