仿Photoshop利用曲线对图像调整亮度与色彩

news2024/12/27 13:45:35

曲线调整是Photoshop的最常用的重要功能之一。对于一个RGB图像,  可以对R,  G,  B 通道进行独立的曲线调整,即,对三个通道分别使用三条曲线(Curve)。还可以再增加一条曲线对 三个通道进行整体调整。 因此,对一个图像,可以用四条曲线调整。最终的结果,是四条曲线调整后合并产生的结果。

图中,横轴是输入,比左到右分别表示0到255.  纵轴是输出,从下到上分别表示0到255.

具体代码分三个实现:

头文件 Curves.h

/*
 * Adjust Curves
 */

#ifndef OPENCV2_PS_CURVES_HPP_
#define OPENCV2_PS_CURVES_HPP_
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
using namespace std;
using namespace cv;

namespace cv {

	/**
	 * Class of Curve for one channel
	 */
	class Curve {
	protected:
		Scalar color;
		Scalar back_color;
		int tolerance; //
		bool is_mouse_down;
		vector<Point> points;  //control points 
		vector<Point>::iterator current;  //pointer to current point

		vector<Point>::iterator  find(int x);
		vector<Point>::iterator  find(int x, int y);
		vector<Point>::iterator  add(int x, int y);

	public:
		Curve();
		virtual ~Curve();

		int calcCurve(double* z); //

		void draw(Mat& mat);  //
		void mouseDown(int x, int y); 
		bool mouseMove(int x, int y); 
		void mouseUp(int x, int y); 

		void clearPoints(); 
		int  addPoint(const Point& p); 
		int  deletePoint(const Point& p); 
		int  movePoint(const Point& p, int x, int y); 
	};

	/**
	 * Class of Curves for all channels
	 */
	class Curves {
	protected:
		void createColorTables(uchar colorTables[][256]);
	public:
		Curves();
		virtual ~Curves();

		Curve RGBChannel;   //RGB
		Curve RedChannel;   //Red
		Curve GreenChannel; //Green
		Curve BlueChannel;  //Blue

		Curve* CurrentChannel; 

		void draw(Mat& mat); 
		void mouseDown(int x, int y); 
		bool mouseMove(int x, int y);
		void mouseUp(int x, int y); 

	
		int adjust(InputArray src, OutputArray dst, InputArray mask = noArray());

	};
#endif/* OPENCV2_PS_CURVES_HPP_ */

	
	void dot_line(Mat& mat, Point& p1, Point& p2, Scalar& color, int step = 8);

} /* namespace cv */

Curves.cpp

/*
 * Adjust Curves
 *
 */

#include "Curves.hpp"

#ifdef HAVE_OPENMP
#include <omp.h>
#endif

#define SWAP(a, b, t)  do { t = a; a = b; b = t; } while(0)
#define CLIP_RANGE(value, min, max)  ( (value) > (max) ? (max) : (((value) < (min)) ? (min) : (value)) )
#define COLOR_RANGE(value)  CLIP_RANGE((value), 0, 255)

#include <iostream>
#define DEBUG_PRINT(a)  cout << (a) << endl
#define PRINT_VAR(var)  cout << #var << " = " << (var) <<  endl

namespace cv {

	/**
	 * spline function
	 *
	 * @param x [in]  array of x-coordinate of control points
	 * @param y [in]  array of y-coordinate of control points
	 * @param n [in]  count of control points
	 * @param t [in]  array of x-coordinate of output points
	 * @param m [in]  count of output points
	 * @param z [out]  array of y-coordinate of output points
	 */
	static double spline(double* x, double* y, int n, double* t, int m, double* z)
	{
		double* dy = (double*)malloc(n * sizeof(int));
		memset(dy, 0, sizeof(double) * n);
		dy[0] = -0.5;

		//double* ddy = new double[n];
		double* ddy = (double*)malloc(n * sizeof(int));
		memset(ddy, 0, sizeof(double) * n);

		double h1;
		double* s = (double*)malloc(n * sizeof(int));
		double h0 = x[1] - x[0];

		s[0] = 3.0 * (y[1] - y[0]) / (2.0 * h0) - ddy[0] * h0 / 4.0;
		for (int j = 1; j <= n - 2; ++j)
		{
			h1 = x[j + 1] - x[j];
			double alpha = h0 / (h0 + h1);
			double beta = (1.0 - alpha) * (y[j] - y[j - 1]) / h0;
			beta = 3.0 * (beta + alpha * (y[j + 1] - y[j]) / h1);
			dy[j] = -alpha / (2.0 + (1.0 - alpha) * dy[j - 1]);
			s[j] = (beta - (1.0 - alpha) * s[j - 1]);
			s[j] = s[j] / (2.0 + (1.0 - alpha) * dy[j - 1]);
			h0 = h1;
		}
		dy[n - 1] = (3.0 * (y[n - 1] - y[n - 2]) / h1 + ddy[n - 1] * h1 / 2.0 - s[n - 2]) / (2.0 + dy[n - 2]);

		for (int j = n - 2; j >= 0; --j)
		{
			dy[j] = dy[j] * dy[j + 1] + s[j];
		}

		for (int j = 0; j <= n - 2; ++j)
		{
			s[j] = x[j + 1] - x[j];
		}

		for (int j = 0; j <= n - 2; ++j)
		{
			h1 = s[j] * s[j];
			ddy[j] = 6.0 * (y[j + 1] - y[j]) / h1 - 2.0 * (2.0 * dy[j] + dy[j + 1]) / s[j];
		}

		h1 = s[n - 2] * s[n - 2];
		ddy[n - 1] = 6.0 * (y[n - 2] - y[n - 1]) / h1 + 2.0 * (2.0 * dy[n - 1] + dy[n - 2]) / s[n - 2];
		double g = 0.0;
		for (int i = 0; i <= n - 2; i++)
		{
			h1 = 0.5 * s[i] * (y[i] + y[i + 1]);
			h1 = h1 - s[i] * s[i] * s[i] * (ddy[i] + ddy[i + 1]) / 24.0;
			g = g + h1;
		}

		for (int j = 0; j <= m - 1; j++)
		{
			int i;
			if (t[j] >= x[n - 1]) {
				i = n - 2;
			}
			else {
				i = 0;
				while (t[j] > x[i + 1]) {
					i = i + 1;
				}
			}
			h1 = (x[i + 1] - t[j]) / s[i];
			h0 = h1 * h1;
			z[j] = (3.0 * h0 - 2.0 * h0 * h1) * y[i];
			z[j] = z[j] + s[i] * (h0 - h0 * h1) * dy[i];
			h1 = (t[j] - x[i]) / s[i];
			h0 = h1 * h1;
			z[j] = z[j] + (3.0 * h0 - 2.0 * h0 * h1) * y[i + 1];
			z[j] = z[j] - s[i] * (h0 - h0 * h1) * dy[i + 1];
		}

		return(g);
	}

#define WITHIN(x1, delta, x2) ( (delta) > 0 ) ? ( (x1) <= (x2) ) : ( (x1) >= (x2) )
#define EXCEED(x1, delta, x2) ( (delta) > 0 ) ? ( (x1) >= (x2) ) : ( (x1) <= (x2) )

	void dot_line(Mat& mat, const Point& p1, const Point& p2, const Scalar& color,
		int thickness = 1, int lineType = 8, int line_step = 6, int blank_step = 6);

	void dot_line(Mat& mat, const Point& p1, const Point& p2, const Scalar& color,
		int thickness, int lineType, int line_step, int blank_step)
	{
		if (p1 == p2) return;

		//validate line_step
		line_step = ::abs(line_step);
		if (line_step == 0) line_step = 1;

		//validate blank_step
		blank_step = ::abs(blank_step);
		if (blank_step == 0) blank_step = 1;

		//dot_ratio = blank_step / line_step;
		double dot_ratio = blank_step * 1.0 / line_step;

		//calculat step_x, step_y
		double len, step_x, step_y;
		len = sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
		step_x = (p2.x - p1.x) / len * line_step;
		step_y = (p2.y - p1.y) / len * line_step;

		double x1, y1, x2, y2;
		x1 = p1.x;  y1 = p1.y;  //start from Point p1

		//draw line step by step, until meet Point p2
		if (::abs(p1.x - p2.x) > ::abs(p1.y - p2.y)) {
			//step in direction of x-coordination
			while (WITHIN(x1, step_x, p2.x)) {
				if (EXCEED(x1 + step_x * (1 + dot_ratio), step_x, p2.x)) {
					x2 = p2.x;
					y2 = p2.y;
				}
				else if (EXCEED(x1 + step_x, step_x, p2.x)) {
					x2 = p2.x;
					y2 = p2.y;
				}
				else {
					x2 = x1 + step_x;
					y2 = y1 + step_y;
				}
				line(mat, Point(x1, y1), Point(x2, y2), color, thickness, lineType);
				//step
				x1 = x2 + step_x * dot_ratio;
				y1 = y2 + step_y * dot_ratio;
			}

		}
		else {
			//step in direction of y-coordination
			while (WITHIN(y1, step_y, p2.y)) {
				if (EXCEED(y1 + step_y * (1 + dot_ratio), step_y, p2.y)) {
					x2 = p2.x;
					y2 = p2.y;
				}
				else if (EXCEED(y1 + step_y, step_y, p2.y)) {
					x2 = p2.x;
					y2 = p2.y;
				}
				else {
					x2 = x1 + step_x;
					y2 = y1 + step_y;
				}
				line(mat, Point(x1, y1), Point(x2, y2), color, thickness, lineType);
				//step
				x1 = x2 + step_x * dot_ratio;
				y1 = y2 + step_y * dot_ratio;
			}
		}
	}

	Curve::Curve()
	{
		color = Scalar(0, 0, 0);
		back_color = Scalar(255, 255, 255);
		tolerance = 3;
		is_mouse_down = false;
		points.push_back(Point(0, 0));
		points.push_back(Point(255, 255));
		current = points.end();
	}

	Curve::~Curve()
	{
	}


	vector<Point>::iterator  Curve::find(int x)
	{
		vector<Point>::iterator iter;
		for (iter = points.begin(); iter != points.end(); ++iter) {
			if (::abs(iter->x - x) <= tolerance)
				return iter;
		}
		return points.end();
	}

	vector<Point>::iterator  Curve::find(int x, int y)
	{
		vector<Point>::iterator iter;
		for (iter = points.begin(); iter != points.end(); ++iter) {
			if (::abs(iter->x - x) <= tolerance && ::abs(iter->y - y) <= tolerance)
				return iter;
		}
		return points.end();
	}

	vector<Point>::iterator Curve::add(int x, int y)
	{
		vector<Point>::iterator it = find(x);
		if (it == points.end()) {
			Point p(x, y);
			vector<Point>::iterator iter;
			for (iter = points.begin(); iter != points.end(); ++iter) {

				if (iter == points.begin() && iter->x > p.x) {
					DEBUG_PRINT("points insert at beginning");
					return points.insert(iter, p);
				}

				if (iter->x < x && (iter + 1) != points.end() && (iter + 1)->x > p.x) {
					DEBUG_PRINT("points insert");
					return points.insert(iter + 1, p);
				}
			}
			DEBUG_PRINT("points append");
			return points.insert(points.end(), p);
		}
		else {
			return it;
		}
	}

	int Curve::calcCurve(double* output_y)
	{
		//if count of control points is less than 2, return linear output
		if (points.size() < 2) {
			for (int i = 0; i < 256; ++i)
				output_y[i] = 255 - i;
			return 0;
		}

		//if count of control points is 2, return linear output
		if (points.size() == 2) {
			vector<Point>::iterator point1 = points.begin();
			vector<Point>::iterator point2 = point1 + 1;

			double delta_y = 0;
			if (point2->x != point1->x)
				delta_y = (point2->y - point1->y) * 1.0 / (point2->x - point1->x);

			//create output
			for (int i = 0; i < 256; ++i) {
				if (i < point1->x) {
					output_y[i] = point1->y;
				}
				else if (i >= point1->x && i < point2->x) {
					output_y[i] = COLOR_RANGE(point1->y + delta_y * (i - point1->x));
				}
				else {
					output_y[i] = point2->y;
				}
			}
			return 0;
		}


		//the count of control points is greater than 2,  create spline line
		int n = 0;
		n = points.size();  //count of points
		double* x = (double*)malloc(n * sizeof(int));
		double* y = (double*)malloc(n * sizeof(int));
		//create array of x-coordinate and y-coordinate of control points
		vector<Point>::iterator start_point = points.end();
		vector<Point>::iterator end_point = points.end();
		vector<Point>::iterator iter;
		int k = 0;
		for (iter = points.begin(); iter != points.end(); ++iter, ++k) {
			if (k == 0) start_point = iter;
			x[k] = iter->x - start_point->x;
			y[k] = iter->y;
			end_point = iter;
		}

		//if start_point or end_point is invalid
		if (start_point == points.end() || end_point == points.end() || start_point == end_point) {
			for (int i = 0; i < 256; ++i)
				output_y[i] = 255 - i;
			return 1;
		}

		//create array of x-coordinate of output points
		int m = end_point->x - start_point->x;
		double* t = (double*)malloc(n * sizeof(int));
		double* z = (double*)malloc(n * sizeof(int));
		//initialize array of x-coordinate
		for (int i = 0; i < m; ++i) {
			t[i] = i;
		}

		//perform spline, output y-coordinate is stored in array z
		spline(x, y, n, t, m, z);

		//create output
		for (int i = 0; i < 256; ++i) {
			if (i < start_point->x) {
				output_y[i] = start_point->y;
			}
			else if (i >= start_point->x && i < end_point->x) {
				output_y[i] = CLIP_RANGE(z[i - start_point->x], 0, 255);
			}
			else {
				output_y[i] = end_point->y;
			}
		}

		return 0;
	}

	void Curve::draw(Mat& mat)
	{
		int thinkness = 1;
		int n = 0;
		Point lastPoint;

		//clear background
		mat.setTo(back_color);

		vector<Point>::iterator it;
		for (it = points.begin(); it != points.end(); ++it) {
			cout << "point:  " << it->x << ", " << it->y << endl;
		}

		//draw lines
		dot_line(mat, Point(0, 0), Point(255, 0), Scalar(0, 0, 255), 1, 8, 4, 4);
		dot_line(mat, Point(0, 255), Point(255, 255), Scalar(0, 0, 255), 1, 8, 4, 4);

		dot_line(mat, Point(63, 0), Point(63, 255), color, 1, 8, 4, 4);
		dot_line(mat, Point(127, 0), Point(127, 255), color, 1, 8, 4, 4);
		dot_line(mat, Point(191, 0), Point(191, 255), color, 1, 8, 4, 4);
		dot_line(mat, Point(0, 255 - 63), Point(255, 255 - 63), color, 1, 8, 4, 4);
		dot_line(mat, Point(0, 255 - 127), Point(255, 255 - 127), color, 1, 8, 4, 4);
		dot_line(mat, Point(0, 255 - 191), Point(255, 255 - 191), color, 1, 8, 4, 4);

		//create curve
		double z[256];
		calcCurve(z);
		for (int i = 1; i < 256; ++i) {
			line(mat, Point(i - 1, 255 - z[i - 1]), Point(i, 255 - z[i]), color, 1, 8);
		}

		//draw control points
		vector<Point>::iterator iter, iter_next;
		for (iter = points.begin(); iter != points.end(); ++iter, ++n) {
			thinkness = (iter == current) ? -1 : 1;
			rectangle(mat, Point(iter->x - 2, 255 - iter->y + 2),
				Point(iter->x + 2, 255 - iter->y - 2), color, thinkness, 8);
		}
	}


	void Curve::mouseDown(int x, int y)
	{
		y = 255 - y;
		current = add(x, y);
		is_mouse_down = true;
	}

	bool  Curve::mouseMove(int x, int y)
	{
		y = 255 - y;
		if (is_mouse_down) {
			if (current != points.end()) {
				int prev_x = 0;
				int next_x = 255;

				if (current != points.begin()) {
					int prev_y = (current - 1)->y;
					prev_x = (current - 1)->x;

					//match the previous point
					if (points.size() > 2 && ::abs(x - prev_x) <= tolerance && ::abs(y - prev_y) <= tolerance) {
						current--;
						current = points.erase(current);
						DEBUG_PRINT("erase previous");
						return true;
					}

					//if x less than x of previou point
					if (x <= prev_x) {
						//DEBUG_PRINT("less than prev_x");
						return true;
					}
				}

				if ((current + 1) != points.end()) {
					int next_y = (current + 1)->y;
					next_x = (current + 1)->x;

					//match the next point
					if (points.size() > 2 && ::abs(x - next_x) <= tolerance && ::abs(y - next_y) <= tolerance) {
						current = points.erase(current);
						DEBUG_PRINT("erase next");
						return true;
					}

					//if x great than x of next point
					if (x >= next_x) {
						//DEBUG_PRINT("large than next_x");
						return true;
					}
				}

				current->x = CLIP_RANGE(x, 0, 255);
				current->y = CLIP_RANGE(y, 0, 255);

				return true;
			}
		}
		return false;
	}

	void Curve::mouseUp(int x, int y)
	{
		y = 255 - y;
		is_mouse_down = false;
	}


	void Curve::clearPoints()
	{
		points.clear();
	}

	int  Curve::addPoint(const Point& p)
	{
		vector<Point>::iterator iter = add(p.x, p.y);
		if (iter != points.end())
			return 1;
		else
			return 0;
	}

	int  Curve::deletePoint(const Point& p)
	{
		vector<Point>::iterator iter;
		iter = find(p.x, p.y);
		if (iter != points.end()) {
			if (current == iter)
				current = points.end();
			points.erase(iter);
			return 1;
		}
		return 0;
	}

	int  Curve::movePoint(const Point& p, int x, int y)
	{
		vector<Point>::iterator iter;
		iter = find(p.x, p.y);
		if (iter != points.end()) {
			iter->x = x;
			iter->y = y;
			return 1;
		}
		return 0;
	}


	//==========================================================
	// Curves

	Curves::Curves()
	{
		CurrentChannel = &RGBChannel;
	}

	Curves::~Curves()
	{
	}

	void Curves::draw(Mat& mat)
	{
		if (CurrentChannel)  CurrentChannel->draw(mat);
	}

	void Curves::mouseDown(int x, int y)
	{
		if (CurrentChannel)  CurrentChannel->mouseDown(x, y);
	}

	bool Curves::mouseMove(int x, int y)
	{
		if (CurrentChannel)
			return CurrentChannel->mouseMove(x, y);
		return false;
	}

	void Curves::mouseUp(int x, int y)
	{
		if (CurrentChannel)  CurrentChannel->mouseUp(x, y);
	}

	void Curves::createColorTables(uchar colorTables[][256])
	{
		double z[256];

		BlueChannel.calcCurve(z);
		for (int i = 0; i < 256; ++i) {
			colorTables[0][i] = z[i];
		}

		GreenChannel.calcCurve(z);
		for (int i = 0; i < 256; ++i)
			colorTables[1][i] = z[i];

		RedChannel.calcCurve(z);
		for (int i = 0; i < 256; ++i) {
			colorTables[2][i] = z[i];
		}

		uchar value;
		RGBChannel.calcCurve(z);
		for (int i = 0; i < 256; ++i) {
			for (int c = 0; c < 3; c++) {
				value = colorTables[c][i];
				colorTables[c][i] = z[value];
			}
		}
	}

	int Curves::adjust(InputArray src, OutputArray dst, InputArray mask)
	{
		Mat input = src.getMat();
		if (input.empty()) {
			return -1;
		}

		dst.create(src.size(), src.type());
		Mat output = dst.getMat();

		bool hasMask = true;
		Mat msk = mask.getMat();
		if (msk.empty())
			hasMask = false;

		const uchar* in;
		const uchar* pmask;
		uchar* out;
		int width = input.cols;
		int height = input.rows;
		int channels = input.channels();

		uchar colorTables[3][256];

		//create color tables
		createColorTables(colorTables);

		//adjust each pixel

		if (hasMask) {
#ifdef HAVE_OPENMP
#pragma omp parallel for
#endif
			for (int y = 0; y < height; y++) {
				in = input.ptr<uchar>(y);
				out = output.ptr<uchar>(y);
				pmask = msk.ptr<uchar>(y);
				for (int x = 0; x < width; x++) {
					for (int c = 0; c < 3; c++) {
						*out = (colorTables[c][*in] * pmask[x] / 255.0)
							+ (*in) * (255 - pmask[x]) / 255.0;
						out++; in++;
					}
					for (int c = 0; c < channels - 3; c++) {
						*out++ = *in++;
					}
				}
			}
		}
		else {
#ifdef HAVE_OPENMP
#pragma omp parallel for
#endif
			for (int y = 0; y < height; y++) {
				in = input.ptr<uchar>(y);
				out = output.ptr<uchar>(y);
				for (int x = 0; x < width; x++) {
					for (int c = 0; c < 3; c++) {
						*out++ = colorTables[c][*in++];
					}
					for (int c = 0; c < channels - 3; c++) {
						*out++ = *in++;
					}
				}
			}
		}

		return 0;
			}


		} /* namespace cv */

 主函数main.cpp

/*
 * test_Curves
 *
 */

#include <cstdio>
#include <iostream>
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "Curves.hpp"

using namespace std;
using namespace cv;

static string window_name = "Photo";
static Mat src;

static string curves_window = "Adjust Curves";
static Mat curves_mat;
static int channel = 0;
Curves  curves;

static void invalidate()
{
	curves.draw(curves_mat);
	imshow(curves_window, curves_mat);

	Mat dst;
	curves.adjust(src, dst);
	imshow(window_name, dst);

	int y, x;
	uchar* p;

	y = 150; x = 50;
	p = dst.ptr<uchar>(y) + x * 3;
	cout << "(" << int(p[2]) << ", " << int(p[1]) << ", " << int(p[0]) << ")  ";

	y = 150; x = 220;
	p = dst.ptr<uchar>(y) + x * 3;
	cout << "(" << int(p[2]) << ", " << int(p[1]) << ", " << int(p[0]) << ")  ";

	y = 150; x = 400;
	p = dst.ptr<uchar>(y) + x * 3;
	cout << "(" << int(p[2]) << ", " << int(p[1]) << ", " << int(p[0]) << ")  " << endl;
}

static void callbackAdjustChannel(int, void*)
{
	switch (channel) {
	case 3:
		curves.CurrentChannel = &curves.BlueChannel;
		break;
	case 2:
		curves.CurrentChannel = &curves.GreenChannel;
		break;
	case 1:
		curves.CurrentChannel = &curves.RedChannel;
		break;
	default:
		curves.CurrentChannel = &curves.RGBChannel;
		break;
	}


	invalidate();
}

static void callbackMouseEvent(int mouseEvent, int x, int y, int flags, void* param)
{
	switch (mouseEvent) {
	case EVENT_LBUTTONDOWN:
		curves.mouseDown(x, y);
		invalidate();
		break;
	case EVENT_MOUSEMOVE:
		if (curves.mouseMove(x, y))
			invalidate();
		break;
	case EVENT_LBUTTONUP:
		curves.mouseUp(x, y);
		invalidate();
		break;
	}
	return;
}


int main()
{
	//read image file
	src = imread("center.jpg");
	if (!src.data) {
		cout << "error read image" << endl;
		return -1;
	}

	//create window
	namedWindow(window_name, WINDOW_NORMAL);
	resizeWindow(window_name, 800, 600);
	imshow(window_name, src);

	//create Mat for curves
	curves_mat = Mat::ones(256, 256, CV_8UC3);

	//create window for curves
	namedWindow(curves_window);
	setMouseCallback(curves_window, callbackMouseEvent, NULL);
	createTrackbar("Channel", curves_window, &channel, 3, callbackAdjustChannel);

	invalidate();


	waitKey();

	return 0;

}



代码是复制之后就能运行的,只要替换一下图像文件名。

1, Curves类中定义了四个Curve对象(即四个通道),分别是RedChannel, GreenChannel, BlueChannel 和 RGBChannel.

2,  Curves类支持用鼠标生成曲线,使用方法见代码。

2, Curves.cpp中的spline()函数是生成曲线数值的,即输入一串控制点,通过插值运算,生成一系列的输出值。  

3, 除了用鼠标生成曲线以外, 也可以用程序代码直接生成曲线:

     先使用Curve类的clearPoints()方法清除所有控制点,再调用addPoint()方法逐个添加控制点即可。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1865543.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Blast L2空投教学,好用的Blast钱包推荐bitget

什么是 Blast L2&#xff1f; Blast&#xff08;web3.bitget.com/en/&#xff09;是一个与 EVM 兼容的第 2 层 (L2) 区块链网络&#xff0c;旨在通过原生收益产生收益。该项目由匿名联合创始人 PacmanBlur 领导&#xff0c;并已成功从 Paradigm 和 Standard Crypto 等知名投资…

早餐店小程序开发

在快节奏的城市生活中&#xff0c;早餐对于许多人来说是一天中最重要的一餐。然而&#xff0c;传统的早餐店在经营过程中常常面临客流量不稳定、服务效率低下等问题。为了解决这些问题&#xff0c;越来越多的早餐店老板开始寻求利用科技手段提升经营效率。早餐店小程序作为一种…

Energy-based PINN在固体力学中的运用

简介 物理信息神经网络&#xff08;Physic informed neural network&#xff0c;PINN&#xff09;已经成为在有限差分、有限体积和有限元之后的另一种求解偏微分方程组的范式&#xff0c;受到学者们广泛关注。 在固体力学领域有两类不同的PINN: &#xff08;1&#xff09;PDE…

【D3.js in Action 3 精译】1.2 D3 生态系统——入门须知

1.2 D3 生态系统——入门须知 D3.js 从不单打独斗&#xff0c;而是作为 D3 生态系统的一员&#xff0c;与生态内的一系列技术和工具相结合来创建丰富的 Web 界面。与其他网页一样&#xff0c;D3 项目也是充分利用 HTML5 的强大功能在 DOM 内构建出来的。尽管 D3 也可以创建并操…

栈,ASCII编码

栈 LinkedList stack new LinkedList<>(); int i 0; while (i < s.length()) { char c s.charAt(i); if (c <) {if (stack.isEmpty()) {i;continue;}stack.removeLast(); //从栈的末尾移除一个元素} else {stack.addLast(c); //压入栈的末尾栈是只允许在一端…

二叉树——另一颗树的子树

目录 1&#xff1a;题目分析及思路 2&#xff1a;代码实现和分析 1&#xff1a;代码 2&#xff1a;分析 1&#xff1a;题目分析及思路 给我们两棵二叉树&#xff0c;分别是 root 和 subRoot 。检验 root 中是否包含和 subRoot 具有相同结构和节点值的子树。如果存在&…

ZGC垃圾收集的主要流程

值得说明的是&#xff0c;在执行就地迁移时&#xff0c;ZGC 必须首先压缩指定为对象迁移区域内的对象&#xff0c;这可能会对性能产生负面影响。增加堆大小可以帮助 ZGC 避免使用就地迁移。 如上图&#xff0c;ZGC 的工作流程主要包括以下几个步骤&#xff1a; &#xff08;STW…

昇思25天学习打卡营第8天|保存与加载

一、简介&#xff1a; 上一章节主要介绍了如何调整超参数&#xff0c;并进行网络模型训练。在训练网络模型的过程中&#xff0c;实际上我们希望保存中间和最后的结果&#xff0c;用于微调&#xff08;fine-tune&#xff09;和后续的模型推理与部署&#xff0c;本章节我们将介绍…

drozer中文乱码解决方法

drozer简介 drozer 是 Android 的安全测试框架。 drozer 允许您通过扮演应用的角色并与 Android 运行时、其他应用的 IPC 端点和底层操作系统进行交互来搜索应用和设备中的安全漏洞。 drozer 提供了一些工具来帮助您使用、分享和理解公共 Android 漏洞。 drozer 是开源软件…

stm32学习笔记---TIM输出比较(代码部分)PWM驱动LED呼吸灯/舵机/直流电机

目录 第一个工程&#xff1a;PWM驱动LED呼吸灯 PWM.c 初始化PWM步骤 TIM的库函数 TIM_OCStructInit TIM_CtrlPWMOutputs TIM_CCxCmd和TIM_CCxNCmd TIM_SelectOCxM 四个单独更改CCR寄存器值的函数 四个初始化定时器的通道的函数 给结构体一次性都赋初始值的函数 如何…

nginx的基本配置

#user nobody;#工作进程数量 worker_processes 4;events {#子进程最大连接数worker_connections 1024; }http {#囊括的文件类型include mime.types;default_type application/octet-stream;sendfile on;#长连接多长时间没沟通后断开keepalive_timeout 65;#服…

光伏储能为什么变得那么受欢迎?

在当今这个追求可持续发展和清洁能源的时代&#xff0c;光伏储能技术逐渐崭露头角&#xff0c;并成为了能源领域的热门话题。其受欢迎程度不断攀升&#xff0c;背后有着多方面的原因。光伏储能技术的优点众多&#xff0c;涵盖了多个方面&#xff0c;以下是关于其安全、寿命等关…

建筑信息模型(BIM)的应用与案例研究:塑造建筑与施工的新纪元

在数字化浪潮的推动下&#xff0c;建筑信息模型&#xff08;Building Information Modeling, BIM&#xff09;已从一项新兴技术发展为建筑与施工领域不可或缺的核心工具。本文将深入探讨BIM技术的应用原理&#xff0c;分享实际案例&#xff0c;揭示其如何引领建筑行业走向更加高…

C语言学习记录20240626

飞船无论朝哪边行驶&#xff0c;都能通过结构体记录获取它的初始坐标、转向角度和在该方向行进的距离&#xff0c;需要根据这些信息计算飞船移动后的坐标。 向量(vector)指具有大小(magnitude)和方向(direction)的量&#xff0c;可以理解为有方向的线段。 标量或纯量(scalar)指…

MySQL 7种Join的定义图解示范结果(所有join类型)

文章目录 MySQL 7种Join的定义&图解&示范&结果&#xff08;所有join类型&#xff09;基本知识笛卡尔积 建表&填充数据1-Join不带条件account筛选 1-Inner Join 内连接不带条件account相同where筛选玩点特殊的 2-Left Join 左连接不带条件account筛选 3-Right J…

django 和 pyecharts实现可视化大屏(完整代码)

1.配置settings文件 &#xff08;1&#xff09;注意&#xff1a;需要先创建app(djnago-admin startapp app名称) &#xff08;2&#xff09;配置模板文件 DIRS: [os.path.join(BASE_DIR, templates)], &#xff08;3&#xff09;配置静态文件(这里我由于存放清洗好的需要进行可…

基于Java+MySQL停车场车位管理系统详细设计和实现(源码+LW+调试文档+讲解等)

&#x1f497;博主介绍&#xff1a;✌全网粉丝10W,CSDN作者、博客专家、全栈领域优质创作者&#xff0c;博客之星、平台优质作者、专注于Java、小程序技术领域和毕业项目实战✌&#x1f497; &#x1f31f;文末获取源码数据库&#x1f31f; 感兴趣的可以先收藏起来&#xff0c;…

基于51单片机密码锁—六位密码LCD1602显示

基于51单片机密码锁设计 &#xff08;仿真&#xff0b;程序&#xff0b;设计报告&#xff09; 功能介绍 具体功能&#xff1a; 1.密码为六位数字&#xff0c;有键按下&#xff0c;LCD1602就会显示出字符 “*”&#xff1b; 2.当用户键入正确密码后&#xff0c;再按确认键&a…

HistoQC|病理切片的质量控制工具

小罗碎碎念 这期推文介绍的内容&#xff0c;我相信研究病理组学的人&#xff0c;一定都非常熟悉——HistoQC——病理切片的质量控制。 之前写过Hover Net系列的推文&#xff0c;反响还可以&#xff0c;但是Hover Net是用于细胞核检测和分类的&#xff0c;直接从这里开始还不够系…

应用程序任务驱动:详细解析LLM的评估指标

在自然语言处理(NLP)的动态环境中&#xff0c;大型语言模型(LM)性能的评估是衡量其在各种下游应用程序中的有效性的关键因素。不同的应用程序需要与其目标一致的不同性能指标。本文将详细介绍各种LLM评估指标&#xff0c;探索它们如何应用于实际场景。 从传统的摘要任务到更细…