且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

关于使用K-means进行图像分割的帮助

更新时间:2023-12-02 21:51:58

Dientu,

实现此目的的一种方法是创建一个单独的图像,在该图像中,您为每个像素分配群集颜色(1、2或3).然后扫描此图像,并针对每个像素查看直接的邻居(如果考虑不考虑拐角,则有8个或4个).如果至少一个邻居的颜色不同,则给定的像素为边框像素,您可以将其绘制在原始图像中.

这将为您提供区域的内部边界.通过即时重新计算像素索引,您也可以不用单独的图像.
Dientu,

A way to achieve this is to create a separate image where you assign every pixel the cluster color (1, 2, or 3). Then scan this image and for every pixel look at the immediate neighbors (there are 8 or 4 of them if you consider corners or not). If at least one neighbor is of a different color, then the given pixel is a border pixel and you can paint it in your original image.

This will give you the internal borders of the regions. You can also do without the separate image, by recomputing the pixel indexes on the fly.


谢谢Ydaoust
我是越南人,我的编程技能很差,因为我的专业是电子学.我也理解您的意见,但是我很难像您的建议那样编写代码.因此,很高兴您能给我一个有关此问题的示例项目.
Thank you Ydaoust
I''m Vietnamese and my programming skill is fairly bad because my major''s electronic. I also understood your opinion, but it''s difficult for me to write code like your suggestion.So,I''m glad if you can give me a sample project about this problem.
Regards,


抱歉,我没有使用Accord.NET.我所能提供的只是伪代码.

您是否能够执行最基本的操作,例如在给定的X,Y坐标处获取或设置图像中的像素?
I am sorry, I don''t use Accord.NET. All I could give you is pseudocode.

Are you able to perform the most basic operations such as getting or setting a pixel in the image at given X, Y coordinates ?