How to select graph coordinates using given input value?

조회 수: 2 (최근 30일)
Lavanya
Lavanya 2022년 9월 19일
답변: Walter Roberson 2022년 9월 19일
Here I am enclosing ' .m' file. In this file using ginput(), (x,y) coordinates are extracted. Then these values are assigned to table columns. But I need to select the (x,y) coordinates by using edifields input value instead of using ginput(). Later on these values should assign to the table and select the graph as well(like image1.jpg)
Can anyone help me with this?

답변 (1개)

Walter Roberson
Walter Roberson 2022년 9월 19일
Assuming image1 is grayscale (you might need to rgb2gray() it)
values = interp2(1:size(image1, 1), 1:size(image1, 2), image1, query_y_locations, query_x_locations)
Notice the order is y and then x.
This assumes that your coordinates might be non-integers and that you want interpolation according to the surrounding points. If you want the nearest pixel from the image instead of interpolating then
ind = sub2ind(size(image1), round(query_y_locations), round(query_x_locations));
values = image1(ind);

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by