create a loop to determine the pixel distance from the center using the distance formula

1 次查看(过去 30 天)
using the distance formula I need to find the the pixel distance from the center of my image 'sunflower.jpg'. I have found the center of my image im just cofused on how to write the loop and what values my x and y would be.
d^2 = (x-x_c)^2 + (y-y_c)^2 (distance formula)

采纳的回答

Setsuna Yuuki.
Setsuna Yuuki. 2020-11-12
编辑:Setsuna Yuuki. 2020-11-12
you just have to move (x, y).
(x_c, y_x) are fixed.
image = imread('sunflower,jpg');
[l,h,~] = size(image);
%(x_c,y_c) = center of image
for x=1:l
for y=1:h
d = sqrt((x-x_c)^2+(y-y_c)^2);
end
end
  6 个评论
Yogesh Bhambhwani
Yogesh Bhambhwani 2020-11-13
So I have been doing that and its not working (color is the original image) everytime I view the image it is just all black.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by