我们首先定义一个合适大小的核
Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, new Size(5, 5));
然后调用
Imgproc.erode()
方法把图像的暗区放大
Imgproc.erode(src, src, kernelErode);
* 扩大图片暗区(腐蚀图片)
*
@param
bitmap 要处理的图片
public
void
erode
(Bitmap bitmap) {
if
(
null
!= mSubscriber)
Observable
.just(bitmap)
.map(
new
Func1<Bitmap, Bitmap>() {
@Override
public
Bitmap
call
(Bitmap bitmap) {
Mat src =
new
Mat(bitmap.getHeight(), bitmap.getWidth(), CvType.CV_8UC4);
Utils.bitmapToMat(bitmap, src);
Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE,
new
Size(
5
,
5
));
Imgproc.erode(src, src, kernelErode);
Bitmap processedImage = Bitmap.createBitmap(src.cols(), src.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(src, processedImage);
return
processedImage;
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(mSubscriber);
mBlurUtil = new BlurUtil(new Subscriber<Bitmap>() {
@Override
public void onCompleted() {
dismissProgressDialog();
@Override
public void onError(Throwable e) {
dismissProgressDialog();
@Override
public void onNext(Bitmap bitmap) {
mIvImageProcessed.setImageBitmap(bitmap);
mBlurUtil.erode(mSelectImage);