當前位置: 首頁>>代碼示例>>Java>>正文


Java Core.divide方法代碼示例

本文整理匯總了Java中org.opencv.core.Core.divide方法的典型用法代碼示例。如果您正苦於以下問題:Java Core.divide方法的具體用法?Java Core.divide怎麽用?Java Core.divide使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.opencv.core.Core的用法示例。


在下文中一共展示了Core.divide方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transEstimate

import org.opencv.core.Core; //導入方法依賴的package包/類
public static Mat transEstimate(Mat img, int patchSz, double[] airlight, double lambda, double fTrans, 
		int r, double eps, double gamma) {
	int rows = img.rows();
	int cols = img.cols();
	List<Mat> bgr = new ArrayList<>();
	Core.split(img, bgr);
	int type = bgr.get(0).type();
	// calculate the transmission map
	Mat T = computeTrans(img, patchSz, rows, cols, type, airlight, lambda, fTrans);
	// refine the transmission map
	img.convertTo(img, CvType.CV_8UC1);
	Mat gray = new Mat();
	Imgproc.cvtColor(img, gray, Imgproc.COLOR_BGR2GRAY);
	gray.convertTo(gray, CvType.CV_32F);
	Core.divide(gray, new Scalar(255.0), gray);
	T = Filters.GuidedImageFilter(gray, T, r, eps);
	Mat Tsmooth = new Mat();
	Imgproc.GaussianBlur(T, Tsmooth, new Size(81, 81), 40);
	Mat Tdetails = new Mat();
	Core.subtract(T, Tsmooth, Tdetails);
	Core.multiply(Tdetails, new Scalar(gamma), Tdetails);
	Core.add(Tsmooth, Tdetails, T);
	return T;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:25,代碼來源:TransmissionEstimate.java

示例2: enhance

import org.opencv.core.Core; //導入方法依賴的package包/類
public static Mat enhance(Mat image, int blkSize, int patchSize, double lambda, double eps, int krnlSize) {
	image.convertTo(image, CvType.CV_32F);
	// obtain air-light
	double[] airlight = AirlightEstimate.estimate(image, blkSize);
	// obtain coarse transmission map
	double fTrans = 0.5;
	Mat T = TransmissionEstimate.transEstimate(image, patchSize, airlight, lambda, fTrans);
	// refine the transmission map
	Mat gray = new Mat();
	Imgproc.cvtColor(image, gray, Imgproc.COLOR_RGB2GRAY);
	Core.divide(gray, new Scalar(255.0), gray);
	T = Filters.GuidedImageFilter(gray, T, krnlSize, eps);
	// dehaze
	List<Mat> bgr = new ArrayList<>();
	Core.split(image, bgr);
	Mat bChannel = dehaze(bgr.get(0), T, airlight[0]);
	//Core.normalize(bChannel, bChannel, 0, 255, Core.NORM_MINMAX);
	Mat gChannel = dehaze(bgr.get(1), T, airlight[1]);
	//Core.normalize(gChannel, gChannel, 0, 255, Core.NORM_MINMAX);
	Mat rChannel = dehaze(bgr.get(2), T, airlight[2]);
	//Core.normalize(rChannel, rChannel, 0, 255, Core.NORM_MINMAX);
	Mat dehazedImg = new Mat();
	Core.merge(new ArrayList<>(Arrays.asList(bChannel, gChannel, rChannel)), dehazedImg);
	return dehazedImg;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:26,代碼來源:OptimizedContrastEnhance.java

示例3: globalAdaptation

import org.opencv.core.Core; //導入方法依賴的package包/類
private static List<Mat> globalAdaptation(Mat b, Mat g, Mat r, int rows, int cols) {
	// Calculate Lw & maximum of Lw
	Mat Lw = new Mat(rows, cols, r.type());
	Core.multiply(r, new Scalar(rParam), r);
	Core.multiply(g, new Scalar(gParam), g);
	Core.multiply(b, new Scalar(bParam), b);
	Core.add(r, g, Lw);
	Core.add(Lw, b, Lw);
	double LwMax = Core.minMaxLoc(Lw).maxVal; // the maximum luminance value
	// Calculate log-average luminance and get global adaptation result
	Mat Lw_ = Lw.clone();
	Core.add(Lw_, new Scalar(0.001), Lw_);
	Core.log(Lw_, Lw_);
	double LwAver = Math.exp(Core.sumElems(Lw_).val[0] / (rows * cols));
	Mat Lg = Lw.clone();
	Core.divide(Lg, new Scalar(LwAver), Lg);
	Core.add(Lg, new Scalar(1.0), Lg);
	Core.log(Lg, Lg);
	Core.divide(Lg, new Scalar(Math.log(LwMax / LwAver + 1.0)), Lg); // Lg is the global adaptation
	List<Mat> list = new ArrayList<>();
	list.add(Lw);
	list.add(Lg);
	return list;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:25,代碼來源:ALTMRetinex.java

示例4: calWeight

import org.opencv.core.Core; //導入方法依賴的package包/類
private static Mat calWeight(Mat img) {
	Mat L = new Mat();
	img.convertTo(img, CvType.CV_8UC1);
	Imgproc.cvtColor(img, L, Imgproc.COLOR_BGR2GRAY);
	L.convertTo(L, CvType.CV_32F);
	Core.divide(L, new Scalar(255.0), L);
	// calculate Luminance weight
	Mat WC = FeatureWeight.LuminanceWeight(img, L);
	WC.convertTo(WC, L.type());
	// calculate the Saliency weight
	Mat WS = FeatureWeight.Saliency(img);
	WS.convertTo(WS, L.type());
	// calculate the Exposedness weight
	Mat WE = FeatureWeight.Exposedness(L);
	WE.convertTo(WE, L.type());
	// sum
	Mat weight = WC.clone();
	Core.add(weight, WS, weight);
	Core.add(weight, WE, weight);
	return weight;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:22,代碼來源:RemoveBackScatter.java

示例5: enhance

import org.opencv.core.Core; //導入方法依賴的package包/類
public static Mat enhance (Mat image, int level) {
	// color balance
	Mat img1 = Filters.SimplestColorBalance(image, 5);
	img1.convertTo(img1, CvType.CV_8UC1);
	// Perform sRGB to CIE Lab color space conversion
	Mat LabIm1 = new Mat();
	Imgproc.cvtColor(img1, LabIm1, Imgproc.COLOR_BGR2Lab);
	Mat L1 = new Mat();
	Core.extractChannel(LabIm1, L1, 0);
	// apply CLAHE
	Mat[] result = applyCLAHE(LabIm1, L1);
	Mat img2 = result[0];
	Mat L2 = result[1];
	// calculate normalized weight
	Mat w1 = calWeight(img1, L1);
	Mat w2 = calWeight(img2, L2);
	Mat sumW = new Mat();
	Core.add(w1, w2, sumW);
	Core.divide(w1, sumW, w1);
	Core.divide(w2, sumW, w2);
	// merge image1 and image2
	return ImgDecompose.fuseTwoImage(w1, img1, w2, img2, level);
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:24,代碼來源:FusionEnhance.java

示例6: calWeight

import org.opencv.core.Core; //導入方法依賴的package包/類
private static Mat calWeight(Mat img, Mat L) {
	Core.divide(L, new Scalar(255.0), L);
	L.convertTo(L, CvType.CV_32F);
	// calculate laplacian contrast weight
	Mat WL = FeatureWeight.LaplacianContrast(L);
	WL.convertTo(WL, L.type());
	// calculate Local contrast weight
	Mat WC = FeatureWeight.LocalContrast(L);
	WC.convertTo(WC, L.type());
	// calculate the saliency weight
	Mat WS = FeatureWeight.Saliency(img);
	WS.convertTo(WS, L.type());
	// calculate the exposedness weight
	Mat WE = FeatureWeight.Exposedness(L);
	WE.convertTo(WE, L.type());
	// sum
	Mat weight = WL.clone();
	Core.add(weight, WC, weight);
	Core.add(weight, WS, weight);
	Core.add(weight, WE, weight);
	return weight;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:23,代碼來源:FusionEnhance.java

示例7: calWeight

import org.opencv.core.Core; //導入方法依賴的package包/類
private static Mat calWeight(Mat img, Mat L) {
	Core.divide(L, new Scalar(255.0), L);
	L.convertTo(L, CvType.CV_32F);
	// calculate laplacian contrast weight
	Mat WL = WeightCalculate.LaplacianContrast(L);
	WL.convertTo(WL, L.type());
	// calculate Local contrast weight
	Mat WC = WeightCalculate.LocalContrast(L);
	WC.convertTo(WC, L.type());
	// calculate the saliency weight
	Mat WS = WeightCalculate.Saliency(img);
	WS.convertTo(WS, L.type());
	// calculate the exposedness weight
	Mat WE = WeightCalculate.Exposedness(L);
	WE.convertTo(WE, L.type());
	// sum
	Mat weight = WL.clone();
	Core.add(weight, WC, weight);
	Core.add(weight, WS, weight);
	Core.add(weight, WE, weight);
	return weight;
}
 
開發者ID:IsaacChanghau,項目名稱:ImageEnhanceViaFusion,代碼行數:23,代碼來源:EnhanceFunc.java

示例8: preDehaze

import org.opencv.core.Core; //導入方法依賴的package包/類
private static Mat preDehaze(Mat img, double a, double nTrans) {
	// nOut = ( (blkIm - a) * nTrans + 128 * a ) / 128;
	Core.subtract(img, new Scalar(a), img);
	Core.multiply(img, new Scalar(nTrans), img);
	Core.add(img, new Scalar(128.0 * a), img);
	Core.divide(img, new Scalar(128.0), img);
	return img;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:9,代碼來源:BlkTransEstimate.java

示例9: dehaze

import org.opencv.core.Core; //導入方法依賴的package包/類
private static Mat dehaze(Mat img, Mat T, double airlight) {
	// J = (img - airlight) ./ T + airlight;
	Core.subtract(img, new Scalar(airlight), img);
	Core.divide(img, T, img);
	Core.add(img, new Scalar(airlight), img);
	return img;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:8,代碼來源:OptimizedContrastEnhance.java

示例10: dehaze

import org.opencv.core.Core; //導入方法依賴的package包/類
private static Mat dehaze(Mat channel, Mat t, double minAtmosLight) {
	Mat t_ = new Mat();
	Core.subtract(t, new Scalar(1.0), t_);
	Core.multiply(t_, new Scalar(-1.0 * minAtmosLight), t_);
	Core.subtract(channel, t_, channel);
	Core.divide(channel, t, channel);
	return channel;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:9,代碼來源:DarkChannelPriorDehaze.java

示例11: pyramidFuse

import org.opencv.core.Core; //導入方法依賴的package包/類
private static Mat pyramidFuse(Mat w1, Mat w2, Mat img1, Mat img2, int level) {
	// Normalized weight
	Mat sumW = new Mat();
	Core.add(w1, w2, sumW);
	Core.divide(w1, sumW, w1);
	Core.multiply(w1, new Scalar(2.0), w1);
	Core.divide(w2, sumW, w2);
	Core.multiply(w2, new Scalar(2.0), w2);
	// Pyramid decomposition and reconstruct
	return ImgDecompose.fuseTwoImage(w1, img1, w2, img2, level);
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:12,代碼來源:RemoveBackScatter.java

示例12: dehazeProcess

import org.opencv.core.Core; //導入方法依賴的package包/類
private static Mat dehazeProcess(Mat img, Mat trans, double[] airlight) {
	Mat balancedImg = Filters.SimplestColorBalance(img, 5);
	Mat bCnl = new Mat();
	Core.extractChannel(balancedImg, bCnl, 0);
	Mat gCnl = new Mat();
	Core.extractChannel(balancedImg, gCnl, 1);
	Mat rCnl = new Mat();
	Core.extractChannel(balancedImg, rCnl, 2);
	// get mean value
	double bMean = Core.mean(bCnl).val[0];
	double gMean = Core.mean(gCnl).val[0];
	double rMean = Core.mean(rCnl).val[0];
	// get transmission map for each channel
	Mat Tb = trans.clone();
	Core.multiply(Tb, new Scalar(Math.max(bMean, Math.max(gMean, rMean)) / bMean * 0.8), Tb);
	Mat Tg = trans.clone();
	Core.multiply(Tg, new Scalar(Math.max(bMean, Math.max(gMean, rMean)) / gMean * 0.9), Tg);
	Mat Tr = trans.clone();
	Core.multiply(Tr, new Scalar(Math.max(bMean, Math.max(gMean, rMean)) / rMean * 0.8), Tr);
	// dehaze by formula
	// blue channel
	Mat bChannel = new Mat();
	Core.subtract(bCnl, new Scalar(airlight[0]), bChannel);
	Core.divide(bChannel, Tb, bChannel);
	Core.add(bChannel, new Scalar(airlight[0]), bChannel);
	// green channel
	Mat gChannel = new Mat();
	Core.subtract(gCnl, new Scalar(airlight[1]), gChannel);
	Core.divide(gChannel, Tg, gChannel);
	Core.add(gChannel, new Scalar(airlight[1]), gChannel);
	// red channel
	Mat rChannel = new Mat();
	Core.subtract(rCnl, new Scalar(airlight[2]), rChannel);
	Core.divide(rChannel, Tr, rChannel);
	Core.add(rChannel, new Scalar(airlight[2]), rChannel);
	Mat dehazed = new Mat();
	Core.merge(new ArrayList<>(Arrays.asList(bChannel, gChannel, rChannel)), dehazed);
	return dehazed;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:40,代碼來源:RemoveBackScatter.java

示例13: GuidedImageFilter

import org.opencv.core.Core; //導入方法依賴的package包/類
/**
 * Guided Image Filter for grayscale image, O(1) time implementation of guided filter
 *
 * @param I guidance image (should be a gray-scale/single channel image)
 * @param p filtering input image (should be a gray-scale/single channel image)
 * @param r local window radius
 * @param eps regularization parameter
 * @return filtered image
 */
public static Mat GuidedImageFilter(Mat I, Mat p, int r, double eps) {
	I.convertTo(I, CvType.CV_64FC1);
	p.convertTo(p, CvType.CV_64FC1);
	//[hei, wid] = size(I);
	int rows = I.rows();
	int cols = I.cols();
	// N = boxfilter(ones(hei, wid), r); % the size of each local patch; N=(2r+1)^2 except for boundary pixels.
	Mat N = new Mat();
	Imgproc.boxFilter(Mat.ones(rows, cols, I.type()), N, -1, new Size(r, r));
	// mean_I = boxfilter(I, r) ./ N;
	Mat mean_I = new Mat();
	Imgproc.boxFilter(I, mean_I, -1, new Size(r, r));
	// mean_p = boxfilter(p, r) ./ N
	Mat mean_p = new Mat();
	Imgproc.boxFilter(p, mean_p, -1, new Size(r, r));
	// mean_Ip = boxfilter(I.*p, r) ./ N;
	Mat mean_Ip = new Mat();
	Imgproc.boxFilter(I.mul(p), mean_Ip, -1, new Size(r, r));
	// cov_Ip = mean_Ip - mean_I .* mean_p; % this is the covariance of (I, p) in each local patch.
	Mat cov_Ip = new Mat();
	Core.subtract(mean_Ip, mean_I.mul(mean_p), cov_Ip);
	// mean_II = boxfilter(I.*I, r) ./ N;
	Mat mean_II = new Mat();
	Imgproc.boxFilter(I.mul(I), mean_II, -1, new Size(r, r));
	// var_I = mean_II - mean_I .* mean_I;
	Mat var_I = new Mat();
	Core.subtract(mean_II, mean_I.mul(mean_I), var_I);
	// a = cov_Ip ./ (var_I + eps); % Eqn. (5) in the paper;
	Mat a = new Mat();
	Core.add(var_I, new Scalar(eps), a);
	Core.divide(cov_Ip, a, a);
	//b = mean_p - a .* mean_I; % Eqn. (6) in the paper;
	Mat b = new Mat();
	Core.subtract(mean_p, a.mul(mean_I), b);
	// mean_a = boxfilter(a, r) ./ N;
	Mat mean_a = new Mat();
	Imgproc.boxFilter(a, mean_a, -1, new Size(r, r));
	Core.divide(mean_a, N, mean_a);
	// mean_b = boxfilter(b, r) ./ N;
	Mat mean_b = new Mat();
	Imgproc.boxFilter(b, mean_b, -1, new Size(r, r));
	Core.divide(mean_b, N, mean_b);
	// q = mean_a .* I + mean_b; % Eqn. (8) in the paper;
	Mat q = new Mat();
	Core.add(mean_a.mul(I), mean_b, q);
	q.convertTo(q, CvType.CV_32F);
	return q;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:58,代碼來源:Filters.java

示例14: enhance

import org.opencv.core.Core; //導入方法依賴的package包/類
public static Mat enhance(Mat image, int r, double eps, double eta, double lambda, double krnlRatio) {
	image.convertTo(image, CvType.CV_32F);
	// extract each color channel
	List<Mat> bgr = new ArrayList<>();
	Core.split(image, bgr);
	Mat bChannel = bgr.get(0);
	Mat gChannel = bgr.get(1);
	Mat rChannel = bgr.get(2);
	int m = rChannel.rows();
	int n = rChannel.cols();
	// Global Adaptation
	List<Mat> list = globalAdaptation(bChannel, gChannel, rChannel, m, n);
	Mat Lw = list.get(0);
	Mat Lg = list.get(1);
	// Local Adaptation
	Mat Hg = localAdaptation(Lg, m, n, r, eps, krnlRatio);
	Lg.convertTo(Lg, CvType.CV_32F);
	// process
	Mat alpha = new Mat(m, n, rChannel.type());
	Core.divide(Lg, new Scalar(Core.minMaxLoc(Lg).maxVal / eta), alpha);
	//Core.multiply(alpha, new Scalar(eta), alpha);
	Core.add(alpha, new Scalar(1.0), alpha);
	//alpha = adjustment(alpha, 1.25);
	Mat Lg_ = new Mat(m, n, rChannel.type());
	Core.add(Lg, new Scalar(1.0 / 255.0), Lg_);
	Core.log(Lg_, Lg_);
	double beta = Math.exp(Core.sumElems(Lg_).val[0] / (m * n)) * lambda;
	Mat Lout = new Mat(m, n, rChannel.type());
	Core.divide(Lg, Hg, Lout);
	Core.add(Lout, new Scalar(beta), Lout);
	Core.log(Lout, Lout);
	Core.normalize(alpha.mul(Lout), Lout, 0, 255, Core.NORM_MINMAX);
	Mat gain = obtainGain(Lout, Lw, m, n);
	// output
	Core.divide(rChannel.mul(gain), new Scalar(Core.minMaxLoc(rChannel).maxVal / 255.0), rChannel); // Red Channel
	Core.divide(gChannel.mul(gain), new Scalar(Core.minMaxLoc(gChannel).maxVal / 255.0), gChannel); // Green Channel
	Core.divide(bChannel.mul(gain), new Scalar(Core.minMaxLoc(bChannel).maxVal / 255.0), bChannel); // Blue Channel
	// merge three color channels to a image
	Mat outval = new Mat();
	Core.merge(new ArrayList<>(Arrays.asList(bChannel, gChannel, rChannel)), outval);
	outval.convertTo(outval, CvType.CV_8UC1);
	return outval;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:44,代碼來源:ALTMRetinex.java

示例15: enhance

import org.opencv.core.Core; //導入方法依賴的package包/類
public static Mat enhance(Mat image, double krnlRatio, double minAtmosLight, double eps) {
	image.convertTo(image, CvType.CV_32F);
	// extract each color channel
	List<Mat> rgb = new ArrayList<>();
	Core.split(image, rgb);
	Mat rChannel = rgb.get(0);
	Mat gChannel = rgb.get(1);
	Mat bChannel = rgb.get(2);
	int rows = rChannel.rows();
	int cols = rChannel.cols();
	// derive the dark channel from original image
	Mat dc = rChannel.clone();
	for (int i = 0; i < image.rows(); i++) {
		for (int j = 0; j < image.cols(); j++) {
			double min = Math.min(rChannel.get(i, j)[0], Math.min(gChannel.get(i, j)[0], bChannel.get(i, j)[0]));
			dc.put(i, j, min);
		}
	}
	// minimum filter
	int krnlSz = Double.valueOf(Math.max(Math.max(rows * krnlRatio, cols * krnlRatio), 3.0)).intValue();
	Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(krnlSz, krnlSz), new Point(-1, -1));
	Imgproc.erode(dc, dc, kernel);
	// get coarse transmission map
	Mat t = dc.clone();
	Core.subtract(t, new Scalar(255.0), t);
	Core.multiply(t, new Scalar(-1.0), t);
	Core.divide(t, new Scalar(255.0), t);
	// obtain gray scale image
	Mat gray = new Mat();
	Imgproc.cvtColor(image, gray, Imgproc.COLOR_RGB2GRAY);
	Core.divide(gray, new Scalar(255.0), gray);
	// refine transmission map
	int r = krnlSz * 4;
	t = Filters.GuidedImageFilter(gray, t, r, eps);
	// get minimum atmospheric light
	minAtmosLight = Math.min(minAtmosLight, Core.minMaxLoc(dc).maxVal);
	// dehaze each color channel
	rChannel = dehaze(rChannel, t, minAtmosLight);
	gChannel = dehaze(gChannel, t, minAtmosLight);
	bChannel = dehaze(bChannel, t, minAtmosLight);
	// merge three color channels to a image
	Mat outval = new Mat();
	Core.merge(new ArrayList<>(Arrays.asList(rChannel, gChannel, bChannel)), outval);
	outval.convertTo(outval, CvType.CV_8UC1);
	return outval;
}
 
開發者ID:IsaacChanghau,項目名稱:OptimizedImageEnhance,代碼行數:47,代碼來源:DarkChannelPriorDehaze.java


注:本文中的org.opencv.core.Core.divide方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。