在 scilab 中提取像素坐标

Extract pixel coordinates in scilab

我已经使用图像处理提取了边缘,然后我使用 xclick 提取的 edge.Is 选择了像素坐标,这是正确的,或者需要 reverse y axis coordinate?(提取的边是黑底白边) 我想自动提取提取边缘的像素坐标 不是通过鼠标selection.Is scilab 中有可用的命令吗?(我使用 canny 边缘检测器和形态过滤器来提取边缘)

请给我一些建议

谢谢

1.) y坐标是否反转,取决于后续处理。如果您只需要相对测量并且特征的真实方向并不重要,则可以使用任何坐标系(例如,如果您只想计算物体或液滴的数量,则颠倒顶部和底部没有区别)。但是,如果您想通过在上面绘制一个点、一条线或一个矩形(例如 plot2dxrect)或一个数字(例如 xnumb)来指示您找到的特征图像,则需要匹配两个坐标系。我推荐第二个选项并将结果绘制在原始图像上,因为这是检查结果的最简单方法。 2.) 可以通过find 函数进行自动坐标提取:它returns 矩阵的那些索引,其中表达式为真。

IM=[0,0,0,1;0,0,0,1;0,1,1,1;1,1,0,0];   //edge image, edge = 1, background = 0
disp(IM,"Edge image");
[row,col]=find(IM==1);    //row & column indices where IM = 1 (= edge)
disp([row',col'],"Egde coordinates (row, col)");

如果你的"Egde image"标记的边缘不是1(或255,纯白像素)而是数字比较高(亮像素),那么你可以修改[=16=的逻辑表达式]函数来检测值超过某个阈值的像素:

[row,col]=find(IM>0.8);    //if edges > a certain threshold, e.g. 0.8

编辑:对于您的特定图像: 试试下面的代码:

imagefile="d:\Attila\PROJECTS\Scilab\Whosebug\MORPHOLOGICAL_FILTERING.jpg";
//you have to modify this path!
I=imread(imagefile); 
IM=imcrop(I,[170,100,950,370]);   //discard the thick white border of the image
scf(0); clf(0);
ShowImage(IM,'cropped image');
threshold=100;    //try different values between 0-255 (black - white)
[row,col]=find(IM>threshold);
imheight=size(IM,"r");   //image height
row=imheight-row+1;   //reverse y axes coordinates (0 is at top)
plot2d(col,row,style=0);  //plot over the image (zoom to see the dots)
scf(1); clf(1);  //plot separate graph
plot2d(col,row,style=0);

如果您使用阈值参数,您将看到如何找到较暗或较白的像素。