
[英]how to snip or crop or white-fill a rectangle tightly surrounding the outside of a polygon with ggplot2
[英]How to fill red rectangle on image with white background
试图在白色背景的图像上绘制一个红色矩形而不屏蔽字母。请参见下面的图 1。我怎样才能使它像图 2 一样? 我尝试了 alpha,它看起来像图 3,它不像图 2 那样暗。有什么建议吗? 我正在研究 R。
谢谢。
img <- readPNG("test.png")
width<-dim(img)[2]
height<-dim(img)[1]
imgNamePlot<-paste("testPlot","png",sep='_EE.')
png(imgNamePlot, width = width, height = height, res=300)
op=par(mar = c(0, 0, 0, 0))
plot(c(0, width), c(0, height), type = "n", xlab = "", ylab = "",xaxs = "i",yaxs = "i")
rasterImage(img, 0, 0, width, height, interpolate = F)
image <- as.raster(rgb(255, 0, 0, 255, maxColorValue = 255))
geneWidth<-46
geneHeight<-17
geneX<-188
geneY<-519
rasterImage(image, geneX-0.5*geneWidth+1, height-geneY-0.5*geneHeight-1, geneX-0.5*geneWidth+geneWidth+1, height-geneY-0.5*geneHeight+geneHeight-1, interpolate=FALSE)
dev.off()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.