是否可以使用乳胶创建喷枪效果?

是否可以使用乳胶创建喷枪效果?

我有一张旧图片,想用在一本书中。但上面有一些污点,还有一些其他难看的瑕疵。如果可能的话,我想尝试用 Latex 对其进行“喷绘”。

为了模拟该场景,请考虑以下 MWE:

\documentclass{article}
\usepackage{graphicx,xcolor,tikz}
\usepackage{transparent}
\begin{document}
\usetikzlibrary{calc}

\def\blob#1#2{\draw[fill,rounded corners=#1*3mm] (#2) +($(0:#1*2+#1*rnd)$)
\foreach \a in {10,20} {  -- +($(\a: #1*2+#1*rnd)$) } -- cycle;}

\begin{figure}[!htb]
\centering
\includegraphics[width=20em,height=33em]{example-image}\llap{\texttransparent{0.5}{\color{green}\rule{20em}{33em}}}
\end{figure}
\vspace*{-125pt}\hspace*{125pt}\begin{tikzpicture}
\blob{0.2}{1,3}
\foreach \a in {15,35} {
\fill[green!65!brown] let \p1 = ($(1,3)+(\a+20*rnd:2*rnd)$),
                     \n1 = {0.15*rnd}
                  in (\p1) circle(\n1);
 }
\end{tikzpicture}
\end{document}

产生输出

在此处输入图片描述

如您所见,示例图像上有一些不同颜色的斑点。

问题:如果这是我想要使用的图像,而不考虑生成该图像的 Latex 代码,我如何才能合理地尝试消除这些斑点?另外,有人能告诉我如何开始消除其中一条模糊的对角线吗,因为我的实际图片上也出现了类似的东西?

谢谢。

答案1

我想说的是不是适合 LaTeX 的工作。-使用任何带有克隆工具的照片/图像编辑器。可以使用 TikZ 完成,-全部取决于所需的结果和工作量。

\documentclass[tikz, border=0.2 cm]{standalone}
\tikzset{%
glow/.style={%
draw=none,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.1,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.1,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.1,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.1,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.1,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.1,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.3,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.3,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.3,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.3,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.3,
preaction={draw, line cap=round, line join=round, line width=0.9*\pgflinewidth, opacity=0.3,
}}}}}}}}}}}}}}
\usetikzlibrary{fadings}
\begin{tikzfadingfrompicture}[name=myfading, color=transparent!0]
\draw[glow, line width=10pt] (-5.5,-3.4) -- (-3,-1.8);
\draw[glow, line width=50pt] (-0.5,1.8) -- (0.2,1.8);
\path (0,0) circle[radius=10]; %encompassing circle for alignment
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\node {\includegraphics[width=\linewidth]{example-image-duck}};
%\fill[path fading=myfading, fit fading=false] (-6,-6) rectangle  (6,6);
\fill[path fading=myfading, fit fading=false] node{\includegraphics[width=\linewidth, trim=25 25 0 0]{example-image-duck}};
\end{tikzpicture}
\end{document}

原来的: 带皇冠的鸭子图像

面具: 线条模糊的鸭子图像

结果: 缺少线条和皇冠的鸭子图像

代码改编自https://tex.stackexchange.com/a/569645/8650

答案2

此解决方案的理念是将图像与其自身(或另一张图片)叠加,并为叠加层添加淡入淡出效果,这样我们就得到了一个边缘平滑的圆圈。这样,您就可以用同一张图片的另一部分(或另一张图片的一部分)覆盖图片的某个部分,这与 Photoshop 等提供的克隆图章工具的功能非常相似。

它与其他答案的解决方案大致相同,我只是使用阴影而不是从图片创建淡入淡出。这有点简单,缺点是您只能使用圆形或椭圆形作为“笔”。

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}

\pgfdeclareradialshading{radialBrushFading}{\pgfpointorigin}{
  color(0pt)=(pgftransparent!0); color(10bp)=(pgftransparent!0);
  color(25bp)=(pgftransparent!100); color(50bp)=(pgftransparent!100)}%
\pgfdeclarefading{radial brush}{\pgfuseshading{radialBrushFading}}%

\def\brushimageoptions{}
\def\brushimageshift{(0,0)}
\tikzset{
    brush/.style args={#1 shift (#2)}{
        path fading={
            radial brush
        },
        path picture={
            \node at ([shift={(#2)}]path picture bounding box.center) {\includegraphics#1};
        },
        fill=none
    }
}

\begin{document}
\begin{tikzpicture}

\node at (0,0) {\includegraphics{example-image-a}};
\fill [brush={{[height=8cm]{example-image-duck}} shift (0,-1)}] (1,1) circle[radius=1.5cm];

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容