下午好,
如何研究矩阵的点P(x,y)的邻域?例如在配置8连接中我的点P(x,y)有8个邻居,我想提取具有最小值并获得其坐标的那个
例如:
05-01 14:03:13.824 1267-1267/? E/Hyphenator: error loading hyphenation /system/usr/hyphen-data/hyph-as.hyb
java.io.FileNotFoundException: /system/usr/hyphen-data/hyph-as.hyb: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:455)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at android.text.Hyphenator.loadHyphenator(Hyphenator.java:118)
at android.text.Hyphenator.init(Hyphenator.java:224)
at com.android.internal.os.ZygoteInit.preloadTextResources(ZygoteInit.java:252)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:206)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:722)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:187)
at libcore.io.IoBridge.open(IoBridge.java:441)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at android.text.Hyphenator.loadHyphenator(Hyphenator.java:118)
at android.text.Hyphenator.init(Hyphenator.java:224)
at com.android.internal.os.ZygoteInit.preloadTextResources(ZygoteInit.java:252)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:206)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:722)
05-01 14:03:13.824 1267-1267/? E/Hyphenator: error loading hyphenation /system/usr/hyphen-data/hyph-bn.hyb
java.io.FileNotFoundException: /system/usr/hyphen-data/hyph-bn.hyb: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:455)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at android.text.Hyphenator.loadHyphenator(Hyphenator.java:118)
at android.text.Hyphenator.init(Hyphenator.java:224)
at com.android.internal.os.ZygoteInit.preloadTextResources(ZygoteInit.java:252)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:206)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:722)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:187)
at libcore.io.IoBridge.open(IoBridge.java:441)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at android.text.Hyphenator.loadHyphenator(Hyphenator.java:118)
at android.text.Hyphenator.init(Hyphenator.java:224)
at com.android.internal.os.ZygoteInit.preloadTextResources(ZygoteInit.java:252)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:206)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:722)
05-01 14:03:13.824 1267-1267/? E/Hyphenator: error loading hyphenation /system/usr/hyphen-data/hyph-cy.hyb
java.io.FileNotFoundException: /system/usr/hyphen-data/hyph-cy.hyb: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:455)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at android.text.Hyphenator.loadHyphenator(Hyphenator.java:118)
at android.text.Hyphenator.init(Hyphenator.java:224)
at com.android.internal.os.ZygoteInit.preloadTextResources(ZygoteInit.java:252)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:206)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:722)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:187)
at libcore.io.IoBridge.open(IoBridge.java:441)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at android.text.Hyphenator.loadHyphenator(Hyphenator.java:118)
at android.text.Hyphenator.init(Hyphenator.java:224)
at com.android.internal.os.ZygoteInit.preloadTextResources(ZygoteInit.java:252)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:206)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:722)
05-01 14:03:13.825 1267-1267/? E/Hyphenator: error loading hyphenation /system/usr/hyphen-data/hyph-da.hyb
java.io.FileNotFoundException: /system/usr/hyphen-data/hyph-da.hyb: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:455)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at android.text.Hyphenator.loadHyphenator(Hyphenator.java:118)
at android.text.Hyphenator.init(Hyphenator.java:224)
at com.android.internal.os.ZygoteInit.preloadTextResources(ZygoteInit.java:252)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:206)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:722)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:187)
at libcore.io.IoBridge.open(IoBridge.java:441)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at android.text.Hyphenator.loadHyphenator(Hyphenator.java:118)
at android.text.Hyphenator.init(Hyphenator.java:224)
at com.android.internal.os.ZygoteInit.preloadTextResources(ZygoteInit.java:252)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:206)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:722)
05-01 14:03:13.825 1267-1267/? E/Hyphenator: error loading hyphenation /system/usr/hyphen-data/hyph-de-1901.hyb
java.io.FileNotFoundException: /system/usr/hyphen-data/hyph-de-1901.hyb: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:455)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
at android.text.Hyphenator.loadHyphenator(Hyphenator.java:118)
at android.text.Hyphenator.init(Hyphenator.java:224)
at com.android.internal.os.ZygoteInit.preloadTextResources(ZygoteInit.java:252)
at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:206)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:722)
我希望研究r=rand(5)
答案 0 :(得分:1)
如果我理解正确,您只需要做
sub=P(x-1:x+1,y-1:y+1)
[v i]=min(sub(:))
然后v
是最小值,i
是矢量化子矩阵中的索引。根据{{1}}和x
的值查找原始索引是微不足道的(请记住,matlab是列专业)。
答案 1 :(得分:1)
你知道在这种情况下,邻居将位于[x,y] + [-1,-1],[ - 1,0] ...... [1,1]。暂时忽略两件事 - 这些点可能落在矩阵之外,并且该中心包含在其中。当你忽略这些2时,最终会得到
neighbors = r(x-1:x+1, y-1:y+1); % 3x3 matrix.
找到最低限度及其位置是微不足道的。
现在,重新考虑这两个遗漏:
首先你应该用nan填充矩阵来处理index out of range
问题(或者根本不看边缘点,你通常最终会遇到比他们的价值更多的麻烦)。
然后,要排除中心,你应该制作一个面具:
mask = [true, true, true; true, false, true; true, true, true];
最后,找到最小邻居可能很简单:
[minValue] = min(neighbors(mask));
这对于找到最小值确实很好,但是找到最小位置几乎没用。嗯,这里很简单,因为这个掩模,第5点未命中,通常掩模可能是一些较大的圆形(如果你不仅考虑直接邻居而是说距离<3的所有点),那就变得很痛苦将此线性索引映射回原始点。
一个简单的解决方法是
neighbors(~mask) = nan; % set values you don't want to nan.
[minValue, minPosLinear] = min(neighbors(:))
此时,只需重塑minPosLinear以协调并添加中心的坐标。
此过程很容易扩展到搜索任何其他形状的点 - 只需填充足够大的填充(或在边缘上排除足够大的点带),使足够大的初始矩形窗口加上合适的蒙版。