如何在iPhone應用程序中實現Matlab算法,以在Objective-C中縮略/縮小二元(黑色 和白色)圖像?我將如何在iPhone上實現Matlab鏤空/細化算法?
1
A
回答
3
嗯,基本上你可以使用morpholocial運營商爲這個...
建設8條命中或錯過運營商這樣的:
0 0 0
St1 = x 1 x (for deleting upper pixels)
1 1 1
旋轉此4次得到它的4個側面。然後還建立4個OFR這樣的角落:
0 0 x
St5 = 0 1 1 (rotate this again 4 times for the 4 corners)
x 1 1
然後你蠶食你的圖像(循環),直到沒有運營商的可再使用......剩下的就是這種形象的骨架.. 。
這應該不是太難的目標CI猜測來實現......(不熟悉)......這是一個總體戰略...
希望幫助...如果不是,不斷詢問... ;-)
0
編輯:
我寫過GLSL片段着色器,它可以在圖像上執行快速構圖。你可以在循環中應用這個着色器,直到你得到你需要的。 GLSL着色器代碼:
uniform sampler2D Texture0;
varying vec2 texCoord;
// 3x3 pixel window
// (-1,+1) (0,+1) (+1,+1)
// (-1,0) (0,0) (+1,0)
// (-1,-1) (0,-1) (+1,-1)
float dtex = 1.0/float(textureSize(Texture0,0));
vec4 pixel(int dx, int dy) {
return texture2D(Texture0,texCoord +
vec2(float(dx)*dtex, float(dy)*dtex));
}
int exists(int dx, int dy) {
return int(pixel(dx,dy).r < 0.5);
}
int neighbors() {
return exists(-1,+1) +
exists(0,+1) +
exists(+1,+1) +
exists(-1,0) +
exists(+1,0) +
exists(-1,-1) +
exists(0,-1) +
exists(+1,-1);
}
int transitions() {
return int(
clamp(float(exists(-1,+1))-float(exists(0,+1)),0.,1.) + // (-1,+1) -> (0,+1)
clamp(float(exists(0,+1))-float(exists(+1,+1)),0.,1.) + // (0,+1) -> (+1,+1)
clamp(float(exists(+1,+1))-float(exists(+1,0)),0.,1.) + // (+1,+1) -> (+1,0)
clamp(float(exists(+1,0))-float(exists(+1,-1)),0.,1.) + // (+1,0) -> (+1,-1)
clamp(float(exists(+1,-1))-float(exists(0,-1)),0.,1.) + // (+1,-1) -> (0,-1)
clamp(float(exists(0,-1))-float(exists(-1,-1)),0.,1.) + // (0,-1) -> (-1,-1)
clamp(float(exists(-1,-1))-float(exists(-1,0)),0.,1.) + // (-1,-1) -> (-1,0)
clamp(float(exists(-1,0))-float(exists(-1,+1)),0.,1.) // (-1,0) -> (-1,+1)
);
}
int MarkedForRemoval() {
int neib = neighbors();
int tran = transitions();
if (exists(0,0)==0 // do not remove if already white
|| neib==0 // do not remove an isolated point
|| neib==1 // do not remove tip of a line
|| neib==7 // do not remove located in concavity
|| neib==8 // do not remove not a boundary point
|| tran>=2 // do not remove on a bridge connecting two or more edge pieces
)
return 0;
else
return 1;
}
void main(void)
{
int remove = MarkedForRemoval();
vec4 curr = texture2D(Texture0,texCoord);
vec4 col = vec4(remove,remove,remove,1.0);
gl_FragColor = (remove==1)? col:((curr.r > 0.05)?
vec4(1.0,1.0,1.0,1.0):curr);
}
只是這一次的代碼是基於this lecture(實際上是在演講的第一部分,這樣的算法有一些錯誤:-)) 見當黑猩猩差不斷受到這種GLSL着色器送入發生了什麼:
迭代0
迭代5
ITE比10
迭代15
相關問題
- 1. 用java細化或鏤空
- 2. 在MATLAB中理解和實現細化算法
- 3. 在Spartan 3E中實現MATLAB算法
- 4. 在MatLab中實現Neville的算法
- 5. 如何在iOS上實現我的android算法?
- 6. Matlab:如何實現L1距離計算的矢量化版本
- 7. 在C++或MATLAB上實現SVM-SMO算法
- 8. 我該如何實現Goertzel算法?
- 9. 如何實現在MATLAB
- 10. 如何在iphone應用程序中實現RSA算法?
- 11. 如何實現AO *算法?
- 12. 在iphone應用程序中實現應用程序細化
- 13. 在iPhone上實現水平指南針 - 算法?
- 14. 如何在iPhone上實現標籤雲?
- 15. 如何在服務器上實現iPhone
- 16. 如何在iPhone上實現slurp效果?
- 17. 我將如何實現這個蠻力中值搜索算法?
- 18. 如何在SQL中實現此算法?
- 19. 如何在J2ME中實現Blowfish算法?
- 20. 如何在JavaScript中實現TileWindows算法?
- 21. 如何在JavaScript中實現PBEWithMD5AndDES算法?
- 22. 如何在ns3中實現GPSR算法?
- 23. 在JAVA上實現TOTP算法
- 24. 實現在Matlab
- 25. 實現在Matlab
- 26. 我如何在IPHONE上實施PUSH NOTIFICATION?
- 27. 如何在我的計算機上實現一組量子位?
- 28. Matlab如何實現knnclassify?
- 29. 我如何在Objective-C中實現Mid-Point/Bresenham循環算法?
- 30. 我在Matlab中正確實現了PSNR計算代碼嗎?
將是巨大的,如果你能告訴我們Matlab的算法是如何工作的?我剛剛發現bwmorph(),它應該做的一樣我下面提供的方式。爲操作員實現8個小3x3矩陣,將它們硬編碼到您的例程中,並將它們「滑動」到圖像的每個像素(x和y方向上的兩個循環)。在每個像素上,您可以使用運算符來查看是否可以通過比較圖像的相應像素和運算符來侵蝕某些東西。如果你在周圍放置一段時間(真正的)循環,然後遍歷像素並侵蝕和侵蝕,直到你剩下骨架。 – evident 2011-01-26 23:55:00