赚外快啦:现金200悬赏用C语言实现图片查找的简单函数

2013-08-26 14:45:34 +08:00
 oneone
就是需要实现这样几个函数:

struct location {
float x;
float y;
};

1、从图片imageFindFrom中,查找所有的imageToFind,将找到的图片的左上角位置放在array<location>中返回。

array<location> findImages(imageToFind, imageFindFrom);

2、同上,只是查找中忽略colorValue这个颜色的像素点。

array<location> findImagesIgnoreColor(imageFoFind, imageFindFrom, colorValue);

3、从图片imageFindFrom中,按fuzzyValue模糊查找所有的imageToFind,将找到的图片的左上角位置放在array<location>中返回。模糊值为0到1,模糊查找即有多少百分比的“像素点-位置”匹配,即算匹配的。

array<location> findImagesFuzzily(imageToFind, imageFindFrom, fuzzyValue);

4、同上,只是查找中忽略colorValue这个颜色的像素点。
array<location> findImagesFuzzilyIgnoreColor(imageToFind, imageFindFrom, colorValue, fuzzyValue);

有意向的勇士可以加2744331610,期待!
5179 次点击
所在节点    程序员
22 条回复
dorentus
2013-08-26 15:12:28 +08:00
作业题?
Keyes
2013-08-26 15:20:16 +08:00
@dorentus 看似是,不过这没看很懂……根据什么搜索图片……条件呢
oneone
2013-08-26 15:28:34 +08:00
@Keyes 就是找图片,比如图片A的内容是一个围棋的棋盘,图片B是的内容是以一颗黑子。找图就是要从图片A中将所有的B图的坐标找出来。
icenan2
2013-08-26 15:41:02 +08:00
你这没说太明白嘛,用什么图像处理的库?
passluo
2013-08-26 15:44:35 +08:00
200。。。。外快。。。我觉得这还是发到猪八戒上去吧。。。
felix021
2013-08-26 15:51:59 +08:00
Python的话写起来应该会比较快。
LetFoxRun
2013-08-26 15:58:40 +08:00
需要图像处理的知识,不会。
oneone
2013-08-26 16:07:07 +08:00
@icenan2 随便
oneone
2013-08-26 16:08:17 +08:00
@passluo 你会吗?
oneone
2013-08-26 16:15:05 +08:00
@passluo 价钱可以商量
jesse_luo
2013-08-26 22:41:20 +08:00
为什么觉得是C++……
liuyl
2013-08-26 22:49:32 +08:00
模板匹配吧?拿opencv改一改就好了
msg7086
2013-08-27 04:41:30 +08:00
以前图像处理课上是用matlab的矩阵运算来做的。

如果是精确像素点匹配的话倒还是容易,直接像做strcmp那样比像素点就行了。

如果是相似匹配的话,我觉得200肯定是拿不下来的,2000到20000应该差不多吧。
raptor
2013-08-27 09:23:40 +08:00
精确匹配除非是无损图像格式,用JPEG之类有损的话,必须相似匹配
10iii
2013-08-27 10:24:44 +08:00
说个思路吧,不管时间复杂度:
struct image {
int w;
int h;
int* buf;
} imageFoFind, imageFindFrom;

findImagesFuzzilyIgnoreColor(imageToFind, imageFindFrom, colorValue, fuzzyValue) {
int i,j;
for (i=0;i<imageFindFrom.w-imageToFind.w;i++)
for (j=0;j<imageFindFrom.h-imageToFind.h;j++)
if match(imageToFind, imageFindFrom, colorValue, fuzzyValue,i,j) location.push([i,j]);
return location;
}

int match (imageToFind, imageFindFrom, colorValue, fuzzyValue,i,j) {
int max=imageToFind.w*imageToFind.h*(1-fuzzyValue);
int d=0,x,y;
for (x=0;x<imageToFind.w;x++)
for (y=0;y<imageToFind.h;y++) {
if ((imageToFind.buf[x][y]!=imageFindFrom[i+x][j+y])&&(imageFindFrom[i+x][j+y]!=colorValue)&&(imageToFind.buf[x][y]!=colorValue)) d++;
if d>max return 0;
}
return 1;
}

基本就这样吧。不排除语法错误,编译肯定通不过。
oneone
2013-08-27 20:42:59 +08:00
@10iii 实在是厉害又仗义,多谢了!
pubby
2013-08-27 20:47:07 +08:00
@oneone 难道B和A的比例是一样的,不用考虑缩放吗?
oneone
2013-08-27 21:20:04 +08:00
@pubby 如果考虑的话该怎么做呢?
linzhi
2013-08-27 22:04:30 +08:00
@oneone SIFT特征提取 OpenCV
msg7086
2013-08-28 03:01:15 +08:00
楼主有兴趣的话可以来读一下我们的课程PPT。有介绍最基本的SIFT和HOG算法之类的东西。

http://web.engr.oregonstate.edu/~sinisa/courses/OSU/CS556/CS556Slides.html

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/80259

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX