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

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

2025/3/4 7:15:06发布21次查看
imgproc 类的 cvtcolor() 方法将图像的颜色从一种颜色更改/转换为另一种颜色。此方法接受三个参数 -
src - 表示源的 matrix 对象。
dst - 代表目的地的 matrix 对象。
code - 代表颜色的整数值目标图像。
您可以通过将 imgproc.color_rgb2hls 作为参数传递给上述方法,将彩色图像转换为 hls 图像。 p>
示例import org.opencv.core.core;import org.opencv.core.mat;import org.opencv.imgcodecs.imgcodecs;import org.opencv.imgproc.imgproc;public class rgb2hsl { 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\car.jpg"); //creating the empty destination matrix mat dst = new mat(); //converting the image to gray scale imgproc.cvtcolor(src, dst, imgproc.color_rgb2hls); //instantiating the imagecodecs class imgcodecs imagecodecs = new imgcodecs(); //writing the image imagecodecs.imwrite("d:\images\hslimage.jpg", dst); system.out.println("image saved"); }}
输入
输出
以上就是如何使用java opencv库将hls转换为彩色图像?的详细内容。
该用户其它信息

VIP推荐

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