[英]Removing contour using Marvin Framework in Java
我正在使用Marvin Framework来获取静脉图案,但我不知道如何去除叶子轮廓
我正在做以下事情:(每个函数调用其相应的Marvin插件。):
MarvinImage source = MarvinImageIO.loadImage("source.jpg");
MarvinImage gsImage = grayscaleImage(source);
MarvinImage blImage1 = blurEffect(gsImage.clone(),1);
MarvinImage blImage2 = blurEffect(blImage1.clone(), 13);
MarvinImage difi = subtract(blImage2.clone(), blImage1.clone());
difi = invertC(difi.clone());
difi = closingEffect(difi.clone());
difi = MarvinColorModelConverter.binaryToRgb(difi.clone());
difi = reduceNoise(difi.clone());
difi = invertC(difi.clone());
MarvinImageIO.saveImage(difi, "result.jpg");
我开发了一种可以帮助你的简单方法。 它只是从左到右和从右到左移除叶子边框。
唯一的含义是叶子方向。 我已手动旋转输出图像。 但是,我认为您应该考虑在该位置使用叶子以便更好地进行分析。
leaf_rotated.jpg:
http://marvinproject.sourceforge.net/other/leaf_rotated.jpg
leaf_rotated_out.jpg:
http://marvinproject.sourceforge.net/other/leaf_rotated_out.jpg
源代码:
public class LeafTest {
public static void main(String[] args) {
MarvinImage image = MarvinImageIO.loadImage("./res/leaf_rotated.jpg");
removeBorder(image);
MarvinImageIO.saveImage(image, "./res/leaf_rotated_out.jpg");
}
private static void removeBorder(MarvinImage image){
// left to right
for(int y=0; y<image.getHeight(); y++){
for(int x=0; x<image.getWidth(); x++){
if(image.getIntComponent0(x, y) > 10){
for(int x2=x; x2<image.getWidth() && x2 < x+40; x2++){
image.setIntColor(x2, y, 0,0,0);
}
x=0;
break;
}
}
}
// right to left
for(int y=0; y<image.getHeight(); y++){
for(int x=image.getWidth()-1; x>=0; x--){
if(image.getIntComponent0(x, y) > 10){
for(int x2=x; x2>=0 && x2 > x-40; x2--){
image.setIntColor(x2, y, 0,0,0);
}
x=image.getWidth()-1;
break;
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.