Bitwise color filter in MATLAB

夙愿已清 提交于 2019-12-08 06:01:16

问题


Is there a MATLAB function that does the following:

For an image input, it tells me what proportion of the bits are darker than a particular color of my choosing.

So if I entered an image of a chess board and used the color gray, the output would be roughly one half. (the image I need to process in this way is not that simple, though)


回答1:


function CompareMap = BitWiseCompare('filename',c) % c = [R , G , B];
A = imread('filename');
CompareMap = zeros([size(A,1),size(A,2)]);
CompareMap = (A(:,:,1) < c(1)).*(A(:,:,2) < c(2)).*(A(:,:,3) < c(3));
end

for example,

with CompareMap = BitWiseCompare('filename',[220 100 120]); gives,

and CompareMap = BitWiseCompare('filename',[220 130 150]);



来源:https://stackoverflow.com/questions/26617221/bitwise-color-filter-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!