matlab图像处理的问题(图像分割保存)

2024-12-23 09:51:55
推荐回答(1个)
回答1:

问题描述不清,白点的区域不是矩形的,大小怎么定?
假设用最小的矩形包括:
index = find(I==0);
mostLeftPoint = index(1);
mostRightPoint = index(end);
[height,width]=size(I);

Y1 = mod(mostLeftPoint,height);
X1 = ceil(mostLeftPoint/height);
Y2 = mod(mostRightPoint,height);
X2 = ceil(mostRightPoint/height);
WhiteRegion = I(Y1:Y2,X1:X2);