marvin java_使用Java中的Marvin框架去除轮廓

我开发了一种可以帮助你的简单方法.它只是从左到右和从右到左删除叶边界.

唯一的含义是叶面向.我手动旋转输出图像.但是,我认为你应该考虑这个位置的叶子来进行更好的分析.

leaf_rotated.jpg:

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

for(int x=0; x

if(image.getIntComponent0(x, y) > 10){

for(int x2=x; x2

image.setIntColor(x2, y, 0,0,0);

}

x=0;

break;

}

}

}

// right to left

for(int y=0; 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;

}

}

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值