尝试使用白色背景在图像上绘制一个红色矩形而不掩盖字母。请参阅下面的图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()