我想可视化两个 2D 高斯的卷积(或类似的东西)。为此,我在 tikzfadingfrompicture 环境中声明它们。但是,为了获得所需的结果,而不是在中心太靠近时在中间形成一个整体,我需要将透明度范围设置在 transparent!50 和 transparent!0 之间,这使得输出的图像很难看清。有没有办法增加强度?或者在这种情况下重新调整透明度以使图像更黑?
梅威瑟:
\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{tikz}
\usetikzlibrary{fadings}
\usetikzlibrary{shadings}
\begin{document}
\tikzfading[name=fade in, inner color=transparent!100, outer color=transparent!0]
\newcommand\DetFading[4]{
% % 1+2: xy a, 3+4; xy coords b
\begin{tikzfadingfrompicture}[name=fadingpict]
\begin{scope}
\clip (#1,#2) circle(1.5cm); % clip away the non-overlapping parts
\clip (#3,#4) circle(1.5cm);
\fill [black,path fading=fade in] (#1,#2) circle(1.5cm);
\fill [black,path fading=fade in] (#3,#4) circle(1.5cm);
\end{scope}
\draw [draw=black,line width=2cm] (#1,#2) circle (2.4cm); % remove borders due to clipping
\draw [draw=black,line width=2cm] (#3,#4) circle (2.4cm);
\end{tikzfadingfrompicture}
\node [fill=white,inner sep=0pt,outer sep=0pt,rotate=0,minimum width=3cm,minimum height=3cm] at (#1,#2) (textnode) {};
\shade[fill=black,path fading=fadingpict,fit fading=false,fading transform={xshift=#1,yshift=#2},rotate=0] (textnode.south west) rectangle (textnode.north east); }
\tikzfading[name=fade in half, inner color=transparent!50, outer color=transparent!0]
\newcommand\DetFadingHalf[4]{ % % 1+2: xy a, 3+4; xy coords b
\begin{tikzfadingfrompicture}[name=fadingpict]
\begin{scope}
\clip (#1,#2) circle(1.5cm); % clip away the non-overlapping parts
\clip (#3,#4) circle(1.5cm);
\fill [black,path fading=fade in half] (#1,#2) circle(1.5cm);
\fill [black,path fading=fade in half] (#3,#4) circle(1.5cm);
\end{scope}
\draw [draw=black,line width=2cm] (#1,#2) circle (2.4cm); % remove borders due to clipping
\draw [draw=black,line width=2cm] (#3,#4) circle (2.4cm);
\end{tikzfadingfrompicture}
\node [fill=white,inner sep=0pt,outer sep=0pt,rotate=0,minimum width=3cm,minimum height=3cm] at (#1,#2) (textnode) {};
\shade[fill=black,path fading=fadingpict,fit fading=false,fading transform={xshift=#1,yshift=#2},rotate=0] (textnode.south west) rectangle (textnode.north east); }
\begin{tikzpicture}
\DetFading{0}{3cm}{1.5cm}{3cm}
\DetFading{0}{0cm}{0}{0cm}
\DetFadingHalf{3cm}{3cm}{4.5cm}{3cm}
\DetFadingHalf{3cm}{0}{3cm}{0} %\node at (3,4) {a};
\end{tikzpicture}
\end{document}
结果: