src − 表示源图像的matrix对象。
dst − 表示目标图像的matrix对象。
code − 表示目标图像的颜色的整数值。
要将hsv图像转换为rgb,需要将imgproc.color_hsv2rgb作为第三个参数传递给该方法。
示例import org.opencv.core.core;import org.opencv.core.mat;import org.opencv.imgcodecs.imgcodecs;import org.opencv.imgproc.imgproc;public class hsv2rgb { public static void main(string args[]) throws exception { //loading the opencv core library system.loadlibrary( core.native_library_name ); //reading the image mat src = imgcodecs.imread("d:\images\hsvimage.jpg"); //creating the empty destination matrix mat dst = new mat(); //converting the image to gray scale imgproc.cvtcolor(src, dst, imgproc.color_hsv2rgb); //instantiating the imagecodecs class imgcodecs imagecodecs = new imgcodecs(); //writing the image imagecodecs.imwrite("d:\images\hsv2rgb.jpg", dst); system.out.println("image saved"); }}
输入
输出
以上就是如何使用java opencv库将hsv转换为彩色图像?的详细内容。
