在MATLAB中聚类连通方(Clustering Connected Squares in MATLAB)
假设有一个以特定模式着色的网格:
如您所见,这62个红色正方形在三个不同的组(群集)中连接在一起。 您可能希望从以下链接下载数据。
然后,您可以使用以下代码生成下面的网格:
load('data.mat'); figure('units','normalized','outerposition',[0 0 1 1]); % Opening big figure axis equal; axis off; SURF = surf( XX , YY , ZZ, C);
现在,我正在寻找可以分割这三个集群的代码。
请记住,您应该将这些正方形视为一组在任何方向上具有最大一平方间隙距离的正方形。 这意味着,在这种特殊情况下,我们有三个11,13和38个方块。
提前感谢您的时间。
Assume there is a mesh which is colored in the specific pattern:
As you can see, these 62 red squares are connected together in three different groups(Clusters). You might like to download the data from the following link.
Click here for downloading mesh coordinates (XX, YY, ZZ) and its colours(C)
Then, you can generate the mesh below with this code:
load('data.mat'); figure('units','normalized','outerposition',[0 0 1 1]); % Opening big figure axis equal; axis off; SURF = surf( XX , YY , ZZ, C);
Now, I am looking for a code which can segment these three clusters.
Please bear in mind that you should consider those squares as a one group which have maximum one square gap distance in any direction. It means, in this particular case, we have three clusters of 11 , 13 and 38 squares.
Thank you in advance for your time.
原文:https://stackoverflow.com/questions/31522023
最满意答案
在您的
DESCRIPTION
文件中放置以下行:Suggests: Rgraphviz
然后在你的R代码中使用:
if (require(Rgraphviz)) { ... } else stop("Rgraphviz package could not be loaded")
psych包是一个使用Rgraphviz的CRAN包的示例,因此您可以关注它。
In your
DESCRIPTION
file put this line:Suggests: Rgraphviz
and then in your R code use:
if (require(Rgraphviz)) { ... } else stop("Rgraphviz package could not be loaded")
The psych package is an example of a CRAN package that uses Rgraphviz so you can follow it.
相关问答
更多-
在您的DESCRIPTION文件中放置以下行: Suggests: Rgraphviz 然后在你的R代码中使用: if (require(Rgraphviz)) { ... } else stop("Rgraphviz package could not be loaded") psych包是一个使用Rgraphviz的CRAN包的示例,因此您可以关注它。 In your DESCRIPTION file put this line: Suggests: Rgraphviz and then in y ...
-
我相信Checkstyle有这方面的检查。 它被称为导入控制 I believe Checkstyle has a check for that. It's called Import Control
-
在版本2.7中有一个名为developmentDependency的选项,可以设置为package.config以避免包含依赖关系。 排除创建包时的开发依赖关系 In version 2.7 there is an option called developmentDependency that can be set into package.config to avoid including dependency. Excluding development dependencies when creat ...
-
如上所述,您可以复制xml2包的功能: 要在Linux / MacOS上运行,请复制文件configure和/src/Makevars.in 。 请注意,macOS默认包含libxml2的副本,因此您可以像在Linux上一样安全地链接到-lxml2 。 对于Windows,需要从xml2复制文件src/Makevars.win和tools/winlibs.R 。 这是一个简单的脚本,可以在Windows上构建R包时自动从rwinlib下载并静态链接libxml2 。 这些构建脚本经过测试可以在(几乎)任何平 ...
-
这里应该适用的是以下内容: install.packages(pkgs = "ZillowR", type = "source", lib = "/usr/lib64/R/library", contriburl = "file:///software/r_packages/") install.packages()的参数非常庞大,并且所有默认值都配置为使用从CRAN(或其他远程存储库)安装的软件包。 要解压这里发生的事情,请考虑以下 ...
-
它主要是一个功能。 有一个非循环图是不可能的: 大量的软件包,并没有工具来建议依赖性问题。 真的有循环依赖。 通过从零开始构建一个发行版,您会注意到它,例如,现在libc需要一些外部程序(例如解析器),而且此类程序需要libc 。 解决这个问题的一种方法是使用essential软件包:这些软件包构建了一个软件包核心,这可以互相依赖。 将程序拆分为程序库以及拆分体系结构中性文件的二进制文件(特别是在数据量很大的情况下)非常方便。 这可能会导致循环依赖性:两个部分应该一起安装。 包关系更改和包更改。 所以有时候 ...
-
试试这个例子来发现你的错误: 。 创建两个文件夹c:\a1\和c:\a2\ 。 。 在c:\a1\ create A.java文件中: package a1; import a2.B; public class A implements B{ public void metodoB(){ System.out.println("HELLO"); } } 。 在c:\a2\ create B.java文件中: package a2; public interface B ...
-
不,你不能。 Java应用程序的所有包都包含在同一个运行时类路径中,因此所有包中都可以看到类路径上的所有依赖关系。 No, you can't. All packages of a Java application are included in the same runtime classpath, so all of the dependencies that are on the classpath are visible in all of the packages.
-
是否可以在下载时安装R包的外部依赖关系(Is it possible to install external dependencies for R package on download)[2023-03-30]
tl;博士:我希望! 有更早的相关问题。 实质上,您希望在主机操作系统中拥有(精心打造的)CRAN依赖关系(在明确定义的Universe中工作)变得更加通用 - 其中有太多变体和太多变体。 以XML,PostgreSQL,PNG或JPEG为例。 他们的名字(和版本)在不同操作系统上会有所不同,所以这真的很难。 [我确实有一个包RcppAPT,它允许你从R查询apt的缓存,但是只能以另一种方式解决流 - 并且当然只针对一部分用户,因为它对人们没用Windows,MacOS,RH / CentOS等。 ] tl ... -
基于我所做的阅读和来自@gturri的回复,我得出的结论是我为自己创建了一个XY问题,所以我没有创建单独的包,而是创建了一个主包并在该包中创建了子文件夹......所以 src | ---- |--- pkg.exceptions |--- pkg.a |--- pkg.b |--- pkg.c |--- pkg.main libs | ----someExternalJar.jar 成为 src | ---- | | | --- pkg.main | ...