积分图像

原理

代码

close all;
clear all;
clc;

I=imread('C:\Users\luoqi\Desktop\图片\影院\tree.jpg');
if ndims(I)==3
I=rgb2gray(I);
end
[M,N]=size(I);
img=zeros(M,N);

for i=1:M
for j=1:N
if(i1&&j1)
img(i,j)=I(i,j);
elseif (i1&&j~=1)
img(i,j)=I(i,j)+img(i,j-1);
elseif (i~=1&&j
1)
img(i,j)=I(i,j)+img(i-1,j);
else
img(i,j)=I(i,j)+img(i-1,j)+img(i,j-1)-img(i-1,j-1);
end
end
end

figure;
subplot(121),imshow(I);
subplot(122),imshow(img);

posted @ 2020-07-30 11:47  luoqi123456  阅读(128)  评论(0)    收藏  举报