当前位置:网站首页>Playful palette: an interactive parametric color mixer for artists

Playful palette: an interactive parametric color mixer for artists

2022-06-30 02:22:00 Researcher-Du

Playful Palette: An Interactive Parametric Color Mixer for Artists Published in TOG 2017, This paper presents a new palette called :Playful Palette. Like the previous palette, for example [Chang 2013] Clustering based palette and [Tan 2017] The difference between convex hull based palettes is , The previous palette can only modify the colors of existing images . But this article has really generated the color palette that can be used by painters , That is, multiple colors can be generated ( Pigment ) Blend gradient colors for .

The customary , Take the last one teaser.(a) Inside the middle circle is the palette generated by several colors currently used , You can see that there is a smooth gradient effect . On the circle are historical color records , And the palette of the moment corresponding to each color outside the circle , This is mainly used to go back to a certain step or change the color .(b) Select a color painting in the palette ;(c) Painting effect ,(d) Modify image colors through palette history .
 Insert picture description here

Paper points out Color Picker The research of has not been paid attention to , The current color user interface has been unable to meet the needs of digital painting . At first, the paper makes a preliminary user survey on the problems of digital painting . Research indicates that there are Color Picker The most obvious drawback is the inability to mix multiple colors , But real painting often needs to make a variety of pigments into new colors to meet the demand . therefore , The most important contribution of this paper is to propose a new palette that can mix multiple colors and generate smooth color gradient effects .

One 、Playful Palette principle

The palette consists of a plurality of circular color drops (Blob) Generate , Each color drop can be represented as a Yuanzu : B i = ( r i , g i , b i , x i , y i , r i ) B_i = (r_i,g_i,b_i,x_i,y_i, r_i) Bi=(ri,gi,bi,xi,yi,ri), among c i = ( r i , g i , b i ) c_i=(r_i,g_i,b_i) ci=(ri,gi,bi) It's the color of this water drop , p i = ( x i , y i ) p_i=(x_i,y_i) pi=(xi,yi) and r i r_i ri The center and radius of the water drop respectively .

Given a rectangular or circular bounding box ( In a word, all color drops are covered ), And multiple color drops inside B { B 1 , B 2 , . . . B k } B\{B_1,B_2,...B_k\} B{ B1,B2,...Bk}, We want to get a palette of these water droplets . Intuitively , Each color drop corresponds to a circular area , The pixels in the bounding box are closer to which water drop is located , The closer the color is . So , We traverse each position in the bounding box and calculate their color .

A pixel in the bounding box p p p Receiving water drop B i B_i Bi The influence weight of can be expressed as :
M i ( p ) = F ( B i , p ) = { 1 − 4 d 6 9 b 6 + 17 d 4 9 b 4 − 22 d 2 9 b 2 d ≤ b 0  else  (1) M_i(p) = F(B_i,{p})=\left\{\begin{array}{ll} 1-\frac{4 d^{6}}{9 b^{6}}+\frac{17 d^{4}}{9 b^{4}}-\frac{22 d^{2}}{9 b^{2}} & d \leq b \\ 0 & \text { else } \end{array}\right.\tag1 Mi(p)=F(Bi,p)={ 19b64d6+9b417d49b222d20db else (1)

among , d d d Express p p p To Water drop B i B_i Bi The center of the circle ( x i , y i ) (x_i,y_i) (xi,yi) Distance of , b b b Is an adjustment parameter, which can be taken as the radius, i.e : b = r i b = r_i b=ri.

During palette drawing , The same pixel is affected by the sum of the weights of multiple water droplets Draw only when it is greater than a given threshold , Otherwise it's white .
c ( p ) = { ∑ i M i ( p ) ⋅ c i ∑ i M i ( p ) ∑ i M i ( p ) > = T w h i t e  else  (2) c(p) = \left\{\begin{array}{ll} \frac{\sum_i M_i(p) \cdot c_i}{\sum_i M_i(p) } & \sum_i M_i(p) >= T \\ white & \text { else } \end{array}\right. \tag2 c(p)={ iMi(p)iMi(p)ciwhiteiMi(p)>=T else (2)
here T = 0.6 T = 0.6 T=0.6.

Actually , The boundary of the palette of water droplet generation is The formula (2) Corresponding c ( p ) = T c(p) = T c(p)=T The isoline of the , Blogger Birdy_C Draw a diagram showing the composite effect of two water drops .
 Insert picture description here

It should be noted that , Modify the formula (1) in b b b The value of can change the influence range of each water drop . We make z = d / b z = d/b z=d/b, Then the above formula will be d < b d < b d<b When established , M i ( p ) M_i(p) Mi(p) Can be written as :

M i ( p ) = 1 − 4 9 x 6 + 17 9 x 4 − 22 9 x 2 M_i(p) = 1 - \frac{4}{9}x^6 + \frac{17}{9}x^4 - \frac{22}{9}x^2 Mi(p)=194x6+917x4922x2
The image of this function is as follows : It can be seen that the dry function is 0,1 Monotonically decreasing between , That is, when we change, we grow b b b, x = d / b x = d/b x=d/b smaller , thus M i ( p ) M_i(p) Mi(p) Bigger , Therefore, the influence range of water droplets becomes larger .

 Insert picture description here
The color palette effect is obtained by the generation of multiple water drops given in the paper :
 Insert picture description here

Two 、 Simple implementation

#include <vector> 
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;

void DrawPlayfulPalette() {
    
	vector<Vec6d> blobs; //r,g,b,x,y
	blobs.push_back(Vec6d(255, 0, 0, 120, 45));
	blobs.push_back(Vec6d(0, 0, 255, 120, 135));
	blobs.push_back(Vec6d(0, 255, 0, 50, 90));
	
	int rows = 200, cols = 200;
	cv::Mat img = cv::Mat(rows, cols, CV_8UC3, Scalar(255, 255, 255));

	for (int r = 0; r < rows; r++) {
    
		uchar* data = img.ptr<uchar>(r);
		for (int c = 0; c < cols; c++) {
    
			Vec2d pix_pos(r , c);

			Vec3d sum_color(0, 0, 0);
			Vec3i res_color(0, 0, 0);
			double sum_w = 0;

			for (int i = 0; i < blobs.size(); i++) {
    
				Vec3d blob_color(blobs[i][0], blobs[i][1], blobs[i][2]);
				Vec2d blob_pos(blobs[i][3], blobs[i][4]);

				double d2 = (pix_pos - blob_pos).dot(pix_pos - blob_pos);
				double b2 = 70 * 70;
				double db = d2 / b2;

				double w = d2  <= b2 ? 1 - 4 / 9 * pow(db, 3) + 17 / 9 * pow(db, 2) - 22 / 9 * db : 0;
				sum_w += w;
				sum_color += w * blob_color;
			}
			res_color = sum_w < 0.6 ? Vec3d(255, 255, 255): sum_color / sum_w;
			data[3 * c + 0] = res_color[2];
			data[3 * c + 1] = res_color[1];
			data[3 * c + 2] = res_color[0];
		}
	}
	imshow("PlayfulPalette", img);
	waitKey();
}

Draw a few simple palette effects :
 Insert picture description here
The rest of the article focuses on how to keep historical records , I'm not very interested in , So I won't repeat .

原网站

版权声明
本文为[Researcher-Du]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/181/202206300218434308.html