我打进去一直说代码是错的,研究好久都不知道哪有错,红 {MOD}字体那些不太了解,可以的话加我QQ1377150071给我解释下,谢谢clcclear all;close all;I=imread('chel2.bmp');B=rgb2gray(I);subplot(2,2,1);imshow(B)
title('
原图像之一')G=imread('chel.bmp');subplot(2,2,2);imshow(G)title('
背景图像')
M=double(I); J=M; fori=1:H-1 for j=1:W-1 J(i,j)=abs(M(i,j)-M(i+1,j+1))+abs(M(i+1,j)-M(i,j+1)); figure; fori=1:m-1 for j=1:n-1 robertsNum = abs(f(i,j)-f(i+1,j+1)) + abs(f(i+1,j)-f(i,j+1)); if(robertsNum> threshold) f2(i,j)=255; else f2(i,j)=0; figure; Dk=imsubtract(image_gray,image_background); image_bw=im2bw(Dk,0.2);subplot(2,2,3); imshow(image_bw)
M=double(I); 是数据类型的转换
J=M;
fori=1:H-1
for j=1:W-1
J(i,j)=abs(M(i,j)-M(i+1,j+1))+abs(M(i+1,j)-M(i,j+1)); 像素运算abs为绝对值
figure;
fori=1:m-1
for j=1:n-1
robertsNum = abs(f(i,j)-f(i+1,j+1)) + abs(f(i+1,j)-f(i,j+1));
if(robertsNum> threshold)
f2(i,j)=255;
else f2(i,j)=0;
figure;
Dk=imsubtract(image_gray,image_background);
image_bw=im2bw(Dk,0.2);
subplot(2,2,3);
imshow(image_bw)
一周热门 更多>