dahtah / imager

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

Draw_poly? #157

Open mconsidine opened 3 years ago

mconsidine commented 3 years ago

Is there any documentation available for "draw_poly"? It appears to be omitted from the list of functions available - or have I overlooked something? Matt

ShotaOchi commented 3 years ago

I'm not sure which version of imager has draw_poly function. Can you tell me?

mconsidine commented 3 years ago

Hi, I see it in the current master code on dahtah's GitHub. Thanks for looking! Matt

Sent from allegedly smart phone

On Mon, Jul 5, 2021, 3:48 AM Shota Ochi @.***> wrote:

I'm not sure which version of imager has draw_poly function. Can you tell me?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dahtah/imager/issues/157#issuecomment-873885732, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEPIPHPRWLDPYDFH5ZUO6TTWFPVBANCNFSM47Z62OKQ .

mconsidine commented 3 years ago

See line 417 for example in src/RcppEcports.cpp

mconsidine commented 3 years ago

It's also in your fork: imager/src/RcppExports.cpp

ShotaOchi commented 3 years ago

I saw it. Which version of imager exports the function? We can put it back if old imager exports the function.

mconsidine commented 3 years ago

I'm not sure. It's the first timetomei needed it. How could I do this with Magicka

Sent from allegedly smart phone

On Mon, Jul 5, 2021, 4:54 AM Shota Ochi @.***> wrote:

I saw it. Which version of imager exports the function? We can put it back if old imager exports the function.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dahtah/imager/issues/157#issuecomment-873933258, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEPIPBYXA7QMM4HFXHXYFLTWFXN7ANCNFSM47Z62OKQ .

ShotaOchi commented 3 years ago

I believe image_draw function of magick package is what you're looking for.

library(magick)
library(imager)

lineseg <- matrix(c(5,5,100,100,150,110,180,10),nrow=4,byrow=TRUE) 
colnames(lineseg)<-c('x','y') 
a <- image_draw(image_read(boats))
lines(lineseg, col = "red")
dev.off()
b <- magick2cimg(a)

layout(t(1:2))
plot(boats)
plot(b)

Note that this way doesn't work for very small images.

mconsidine commented 3 years ago

I've found that I can use "implot" to accomplish this. But I think it would be good to have draw_poly/draw_polygon brought back. Thank you! Matt