您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何使用Java OpenCV库将HSV转换为彩色图像?

2025/4/18 20:59:39发布23次查看
imgproc类的cvtcolor()方法可以将图像的颜色从一种转换为另一种。该方法接受三个参数:
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转换为彩色图像?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product