dahtah / imager

R package for image processing
GNU Lesser General Public License v3.0
187 stars 43 forks source link

Colour argument has wrong length #158

Closed Zirys1 closed 3 years ago

Zirys1 commented 3 years ago

Sorry for the stupid question, but what does this error message mean when using draw_text: colour argument has wrong length

I am basically using the example draw_text(boats,100,100,"Some text",col="black") %>% plot with a different picture. The picture has 4 colour channels instead of 3, as the boat picture does.

ShotaOchi commented 3 years ago

You must specify values of col explicitly for images having 4 color channels.

# add alpha channel to boats
a <- imfill(width(boats), height(boats))
b <- imlist(boats, a) %>% imappend("c")

# doesn't work
draw_text(b,100,100,"Some text",col="black") %>% plot

# work
draw_text(b,100,100,"Some text",col=c(0,0,0,0)) %>% plot