I have an image of size 30 x 100 pixels.
How can I count how many pixels are there on the diagonal? can I just apply the Pythagorean theorem? but if yes, we may obtain float number of pixels. So how can I address this issue?
In addition, how can I extract automatically the
xandycoordinate values of each pixel on the diagonal?
I have written a MATLAB code for a square matrix which is very easy. But how can I generalize my code to include images of any size (not only square images)..
%suppose an image of size 100 x 100
image = rand(100,100);
n = length(image);
%extract how many pixels are there on the diagonal
diagonal_pixels = sqrt(n^2 + n^2);
%Get the x and y coordinates values of each diagonal pixel
for i = 1: n
x_coordinate_diag(i) = i;
y_coordinate_diag(i) = i;
end