图像分割
点检测
先用线性滤波将图像进行处理,接着找出g的最大值,再将小于T的点去除(找出值为T的点)。
f = imread('img14.tif');
w = [-1 -1 -1; -1 8 -1; -1 -1 -1];
g = abs(imfilter(double(f), w));
T = max(g(:));
g = g >= T;
subplot(1, 2, 1), imshow(f), title('原图');
subplot(1, 2, 2), imshow(g), title('点分割后');
- 输入:
- 输出:
也可以用ordfilt2进行过滤
线检测
其中pixedup(f, n) 将图片放大n倍
f = imread('img15.tif');
subplot(2, 3, 1), imshow(f), title('原图');
w = [2 -1 -1 ; -1 2 -1; -1 -1 2];
g = imfilter(double(f), w);
subplot(2, 3, 2), imshow(g), title('掩模后');
gtop = g(1:120, 1:120);
gtop = pixeldup(gtop, 4);
subplot(2, 3, 3), imshow(gtop), title('左上角的放大图');
gbot = g(end-119:end, end-119:end);
gbot = pixeldup(gbot, 4);
subplot(2, 3, 4), imshow(gbot), title('右上角的放大图');
g = abs(g);
subplot(2, 3, 5), imshow(g), title('掩模后的绝对值');
T = max(g(:));
g = g >= T;
subplot(2, 3, 6), imshow(g), title('满足g >= T 的点');
- 输入:
- 输出: