史蒂夫(Steve)与MATLAB进行图像处理

图像处理概念,算法和MATLAB

PokémonGo遇到Matlab

直到大约两周前,我绝对没有考虑过Matlab和PokémonGo之间的关系,这是今年夏天的全球移动游戏现象。但是后来我听说有人使用一些基本的图像处理技术来通过自动搜索Pokéstops来破解游戏。

好吧,我不玩《神奇宝贝》,我不知道是什么是神奇宝贝,但是我了解搜索自动化背后的基本思想。

这是游戏的屏幕截图。

URL ='https://blogs.mathworks.com/steve/files/pokemon-go-screen.jpg';rgb = imread(url);IMShow(RGB)

(非常感谢那些向我发送屏幕截图的人,尤其是Haripriya和Chris。)

That geometric pattern of nested blue circles is a PokéStop. Our task is to find those. I'm going to show the basic outline of a solution with these steps:

1.按颜色分割图像。

2.使用形态结束清理分割。

3.计算分割中连接组件的区域和质心。

4.选择最大的对象。

为了快速了解如何按颜色分割图像,我喜欢使用颜色阈值,通常使用实验室颜色空间。这是一个屏幕截图,显示了我如何调整A*和B*滑块以挑选与Pokéstop相关的颜色范围。

这是我从颜色Thresholder

imshow(BW)

现在,让我们使用形态闭合将Pokéstop图案转变为一个连接的斑点。

bw2 = imclose(bw,strel(strel)('磁盘',20));imshow(BW2)

接下来,使用地区企业to find all the connected components and compute their areas and centroids. In recent versions of the Image Processing Toolbox, you can tell地区企业to return the result as a table, which makes the results easier to read.

t = regionprops('table',,,,BW2,'区域',,,,“质心”
T =区域质心_____ ________________ 1157 37.43 665.14 13259 260.56 313.99 2 217 49.5 6 259 31.5 1 265 82 82 6 356.5 31.667 12 387.5 31.5 31.5 31.5 31.5 31.5

最后,用最大的区域确定表行,并获得相应的质心。

[~,j] = max(t.Area); location = t.Centroid(j,:)
位置= 260.5581 313.9893

Let's see how well that worked by superimposing the location on the original image.

imshow(RGB)保持on情节(位置(1),位置(2),'dy',,,,'MarkerSize',10,“ MarkerfaceColor”,,,,'y')hold离开

你去。

赶上一切!




与Matlab®R2016A一起出版

|
  • 打印
  • 发送电子邮件

コメント

コメントを残すは,ここをクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。