matlab找出图像(矩阵)中某个元素,并验证

matlab找出图像(矩阵)中某个元素,并验证

OriginImg = imread("test.png");  % 一种思路是找出黑白目标点,另一种是直接全局目标
OriginImg = double(rgb2gray(OriginImg));
OriginImg = 1 - OriginImg/255;  % 颜色反转   其实像素位置已经有了

ImgTargetInd = find(OriginImg==1);
[row, col] = ind2sub(size(OriginImg), ImgTargetInd)

yanzhengImg = ones(50,50);

for yanzhengi = 1:length(row)
        yanzhengImg(row(yanzhengi),col(yanzhengi))=0;  % perfect !
end

matlab找出图像(矩阵)中某个元素,并验证_第1张图片

你可能感兴趣的:(matlab笔记,笔记,matlab,矩阵,开发语言)