Pixel arrangement via MATLAB

I am working on a project where I need to find a specific object on the platform using an attached camera via MATLAB . I was thinking about using the platform as a grid, but I was told that using the camera’s pixels, I could get this position accurately by clicking on the camera’s window / screen and selecting a specific pixel (where objects will be displayed in the camera’s window / screen).

Is there a way to calculate the location of an object (by clicking a pixel) or is there any possible way to do this?

+4
source share
1 answer

Try using the ginput (...) function in MATLAB, for example:

% 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]))]); 

This will give you the location of the pixel on the current axis. Alternatively, you could use the WindowButtonUpFcn shape callback to get the current mouse position in the drawing, and then translate this to the axis where you want it relative then, then scale to the current xlim and ylim axis. But ginput (1) will be much simpler.

Example run

+6
source

Source: https://habr.com/ru/post/1343071/


All Articles