我设计了一个使用指纹匹配的系统,我使用的算法要求首先选择一个围绕核心点的区域,然后进行操作。现在我有了一个算法页92从这个链接中选择核心点。,它在核心点检测方面工作得很好,但我的问题与围绕核心点裁剪图像有关。假设我得到的核心点是错误的,或者位于图像的边缘,那么当我试图裁剪图像时,我得到的图像没有我所需要的区域,例如,让我尝试用图像来解释这一点。
假设我有这个图像,我想取它的核心点


我的算法给出了一个错误的核心点(用红色显示)
但这不是一个问题,因为我期望设计来处理这样错误的核心点检测。现在,正如我前面提到的,我需要在这个核心点周围有一个区域,我用来给我这个区域的命令是:
[XofCenter,YofCenter]=get_core(x);
x = imcrop(x,[(XofCenter-128/2) (YofCenter-128/2) 128 128]);其中,get_core给出了核心点,而印出了围绕核心点的128个交叉128个图像块,这给了我

但这不是我想要的。我希望我的图像包括更多的指纹区域,即使这意味着把我的核心点不要作为我的块图像的中心,这样的东西:

现在的问题是如何得到这样的东西而不手动剪切图像,有人能帮助我吗?
发布于 2017-04-06 11:05:28
这是使用imfilter解决问题的一种相当简单的方法
% read image and set wrong core point
im = im2double(imread('fingerprint.png'));
wrong_corepoint = [64 77];
cropsize = 128;
% filter image to get accumulated values in 128X128 rects
res = imfilter(im, ones(cropsize),'replicate');
% get possible cropping area
yxmin = max([1 1],wrong_corepoint([2 1]) - cropsize + 1);
yxmax = min(size(im),wrong_corepoint([2 1]) + cropsize - 1);
% crop filterd image
res_crop = res(yxmin(1):yxmax(1),yxmin(2):yxmax(2));
% get minimum value because fingerprint is black
[v,minidx] = min(res_crop(:));
[rMin,cMin] = ind2sub(size(res_crop),minidx);
% convert to original image coordinates
ymin = yxmin(1) + rMin - cropsize/2 - 1;
xmin = yxmin(2) + cMin - cropsize/2 - 1;
xmin = min([xmin,size(im,2) - cropsize,wrong_corepoint(1)]);
ymin = min([ymin,size(im,1) - cropsize,wrong_corepoint(2)]);
xmin = max([xmin,1,wrong_corepoint(1) - cropsize + 1]);
ymin = max([ymin,1,wrong_corepoint(2) - cropsize + 1]);
rect = [xmin ymin cropsize cropsize];
% plot
figure;
imshow(im);
hold on
plot(wrong_corepoint(1),wrong_corepoint(2),'xr','MarkerSize',20,'LineWidth',2);
rectangle('Position',rect,'LineWidth',2,'EdgeColor','g');错误的核心点用红色X标记,裁剪矩形用绿色:

https://stackoverflow.com/questions/43248210
复制相似问题