Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
r magick高光图片_R_Imagemagick - Fatal编程技术网

r magick高光图片

r magick高光图片,r,imagemagick,R,Imagemagick,我想通过添加一个白色填充来突出显示图片的某些部分,类似于本文中所做的 我正在使用magick和下面的代码 library(magick) frink <- image_read("https://jeroen.github.io/images/frink.png") %>% image_colorize( opacity = 80 , color = "white") %>% image_draw(.) rect(40, 20, 150, 150, border =

我想通过添加一个白色填充来突出显示图片的某些部分,类似于本文中所做的

我正在使用magick和下面的代码

library(magick)
frink <- image_read("https://jeroen.github.io/images/frink.png") %>%
  image_colorize( opacity = 80 , color = "white") %>% 
  image_draw(.)
rect(40, 20, 150, 150, border = "red", lty = "dashed", lwd = 5)
rect(80, 170, 150, 300, border = "blue", lty = "solid", lwd = 5)
库(magick)
弗林克%
图像着色(不透明度=80,color=“白色”)%>%
图像绘制()
矩形(40、20、150、150,border=“红色”,lty=“虚线”,lwd=5)
矩形(80170150300,border=“blue”,lty=“solid”,lwd=5)
结果就是这样


如何删除方框内的白色填充?

如果我假设Mark Setchell的注释是正确的,那么使用Imagemagick命令行,您可以执行以下操作。对不起,我不知道

输入:

我所做的是:

1. Read the input image.
2. Copy the input image and add 80% to make it whiter
3. Copy the image and fill it with white, then draw a black rectangle where you want to keep the original color. This will be a mask image
4. Use the mask image to composite the original and the white image together
5. Add a blue border
6. Save the result


convert lena.png \
\( -clone 0 -evaluate add 80% \) \
\( -clone 0 -fill white -colorize 100 \
-fill black -draw "rectangle 100,100 150,150" -alpha off \) \
-compose over -composite \
-fill none -stroke blue -strokewidth 5 \
-draw "rectangle 100,100 150,150" \
result.jpg

将80%调整为您喜欢的任何值,以使输入更白

也许50%更令人愉快


我不明白。你的问题令人困惑。在顶部,您要求添加白色填充。但在底部,你要求去除白色填充物。请澄清您的问题。@fmw42 Fred,OP正在使用第3行的
colorize()
命令添加80%的白色填充以覆盖整个图像,但实际上只希望在红色和蓝色突出显示的矩形以外的区域,而不是所有区域。我觉得干得不错!我希望我正确理解了这个问题