java opencv 亮度_尝试使用OpenCV(Java)更改小png图像的颜色

(1)使用标记为IMREAD_UNCHANGED的Alpha通道读取PNG . (2)然后拆分通道并获得alpha . (3)其他步骤......

import java.util.*;

import org.opencv.core.*;

import org.opencv.imgproc.Imgproc;

import org.opencv.imgcodecs.Imgcodecs;

public class xtmp{

public static void main(String[] args){

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

test();

}

static void test(){

// Read with alpha channel

Mat img = Imgcodecs.imread("transparent.png", Imgcodecs.IMREAD_UNCHANGED);

// Split the channels and get the alpha

List bgra = new ArrayList(4);

Core.split(img, bgra) ;

// Save

Mat alpha = bgra.get(3);

Imgcodecs.imwrite("alpha.png", alpha);

}

}

透明:

Α:

你可能感兴趣的:(java,opencv,亮度)