通过MATLAB的像素位置 [英] Pixel location through MATLAB

查看:227
本文介绍了通过MATLAB的像素位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展一个项目,我必须通过使用附带的相机在平台上找到某个对象MATLAB 的。我想过将平台用作网格,但我被告知使用相机的像素,我可以通过点击相机窗口/屏幕并选择某个像素(对象的位置)来精确地获得该位置将在相机窗口/屏幕上显示。

I am working on a project where I have to find a certain object on a platform using an attached camera through MATLAB. I thought about using the platform as a grid, but I've been told that using the pixels of the camera, I might be able to get that position precisely by clicking on the camera window/screen and choosing a certain pixel (where the objects are going to show on the camera window/screen).

有没有办法计算对象的位置(点击的像素)或者有什么方法可以那样做?

Is there a way to calculate the location of the object (clicked pixel) or is there any possible way I could do that?

推荐答案

尝试在MATLAB中使用ginput(...)函数,如下所示:

Try using the ginput(...) function in MATLAB, like this:

% Load some image:
data = imread('fishy 01.jpg');

% display the image:
figure(88);
clf;
h = imagesc(data);
axis image

% Get a value from the screen:
[x, y] = ginput(1);

msgbox(['You want pixel: ' num2str(round([x,y]))]);

这将为您提供当前轴中像素的位置。或者你可以使用图形回调 WindowButtonUpFcn 获取当前数据然后,图中的鼠标位置将其转换为您想要的相对轴,然后缩放到当前轴xlim和ylim。但是ginput(1)会容易得多。

This will give you the location of the pixel in the current axis. Alternately you, could use the figure callback WindowButtonUpFcn to get the current mouse position in the figure then translate that over to the axis you want it relative to, then scale to the current axis xlim and ylim. But ginput(1) will be much easier.

这篇关于通过MATLAB的像素位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆