Matlab-在滑动窗口周围放置边框

时间:2014-04-22 14:23:09

标签: matlab image-processing matlab-cvst

嗨我有代码在Matlab中将图像放在图像上。如果滑动窗口内的像素满足某些条件,那么我需要通过在其周围放置一个矩形来突出显示原始图像上的滑动窗口。

任何人都可以向我解释如何做到这一点吗?

感谢。

 if average>200
         N2=8;
         info2 = repmat(struct, ceil(size(Z, 1) / N2), ceil(size(Z, 2) / N2)); 
         for row1 = 1:N2:size(Z, 1)%loop through each pixel in the 8x8 window
             for col1 = 1:N2:size(Z, 2)
                 x = (row1 - 1) / N2 + 1;
                 y = (col1 - 1) / N2 + 1;

                 imgWindow2 = Z(row1:min(end,row1+N2-1), col1:min(end,col1+N2-1));
                 average2 = mean(imgWindow2(:)); %calculate mean intensity of pixels
                 window2(x,y).average=average2;
                % display(window2(x,y).average);


                % if the intensity of the 8x8 window is greater than
                % 210 then considered suspicious-
                 if average2>210
                 %%%% THEN HIGHLIGH THIS WINDOW ON THE ORG IMAGE (Z)
                 end 
             end
         end

1 个答案:

答案 0 :(得分:0)

如果要在图中显示,可以使用imrect功能。如果要将矩形绘制到图像本身,并且拥有计算机视觉系统工具箱,则可以使用insertShapeinsertObjectAnnotation函数。