How to calculate the gray value on a line segment
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
tao wang
el 28 de Feb. de 2022
Comentada: tao wang
el 28 de Feb. de 2022
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/909845/image.png)
Using the above code can realize the gray value distribution on a line segment, but you must click with the mouse. Is there a method to directly specify the pixel coordinates? It's really difficult for beginners to do this. Thank you
0 comentarios
Respuesta aceptada
Walter Roberson
el 28 de Feb. de 2022
You can pass in the coordinates as the xi and yi parameters.
5 comentarios
Walter Roberson
el 28 de Feb. de 2022
The values of the abscissa and ordinate above are increased by one
No they are not. I indexed at column 50:100 (which is 51 locations) and you can see that sx starts from exactly 50 and has length 51. Exactly the same values, nothing added to them.
but if it is a straight line connected by two arbitrary points
im = imread('cameraman.tif');
ny = size(im,1);
nx = size(im,2);
xstart = randi(nx)
xend = randi(nx)
ystart = randi(ny)
yend = randi(ny)
[sx, cy, c] = improfile(im, [xstart xend], [ystart yend])
Notice that sx(1) is exactly the same as xstart, and the sy(1) is exactly the same as ystart. The values have not been increased by 1.
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!