【发布时间】:2015-10-30 00:49:15
【问题描述】:
我想获取一张 RGB 图像,找到图像中的白色点,然后获取图像中这些点的笛卡尔坐标。我已经走了大部分路,但是当我尝试绘制笛卡尔坐标时,我得到了一个垂直平铺的图像(即我应该看到的 5 个重叠副本)。有谁知道是什么原因造成的?
,
代码:(JPG 格式为 2448 x x3264 x 3 uint8)
I = imread('IMG_0245.JPG');
imshow(I); % display unaltered image
% Convert image to grayscale
I = rgb2gray(I);
% Convert image to binary (black/white)
I = im2bw(I, 0.9);
% Generate cartesian coordinates of image
imageSize = size(I);
[x, y] = meshgrid( 1:imageSize(1), 1:imageSize(2) );
PerspectiveImage = [x(:), y(:), I(:)];
% Get indices of white points only
whiteIndices = find(PerspectiveImage(:,3));
figure; plot( PerspectiveImage(whiteIndices, 1), PerspectiveImage(whiteIndices, 2),'.');
% Flip vertically to correct indexing vs. plotting issue
axis ij
【问题讨论】:
标签: image matlab image-processing