【发布时间】:2025-12-08 05:00:02
【问题描述】:
我正在使用 matlab 来获取图像中特定像素值的计数。
读入 matlab 时图像为 RGBA (尽管我们可以忽略 alpha 通道)。
除了;
[width, height, depth] = size(im);
for x = 1 : width;
for y = 1: height;
r = im(x,y,1);
g = im(x,y,2);
b = im(x,y,3);
...
end
end
有没有办法使用矩阵运算来做到这一点?大致如下:
X = find(im(:,:,1) == 255 && im(:,:,2) == 255 && im(:,:,3) == 255);
count = length(X);
% Count being the number of pixels with RGB value (255,255,255) in the image.
我猜有不止几种方法可以做到这一点(查看相交、独特的函数),但我对 matlab 还不够聪明,无法做到这一点。有什么帮助吗?
【问题讨论】: