【发布时间】:2020-11-27 10:58:21
【问题描述】:
我有一个大小为30 x 100 像素的图像。
-
如何计算对角线上有多少像素?我可以吗 只应用勾股定理?但如果是,我们可能会获得浮点数 像素数。那么我该如何解决这个问题呢?
-
另外,如何自动提取
x和y的坐标值 对角线上的每个像素?
我已经为一个非常简单的方阵编写了一个 MATLAB 代码。但是我怎样才能概括我的代码以包含任何大小的图像(不仅仅是方形图像)..
%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
【问题讨论】: