Group Abstract Group Abstract

Message Boards Message Boards

0
|
10.4K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Speed up image creation from Graphics[] primitives?

POSTED BY: Matthew Sottile
4 Replies

Conversion of Graphics to Image usually requires a rasterization and unfortunately it is the case here. Image constructor internally calls Rasterize when the input argument is a Graphics object. The only exception is Graphics[Raster[..]], where the image data is extracted directly from Raster. You can use ImageSize option of Graphics in your render function to avoid ImageResize call:

render3[i_, size_] := Image[Graphics[oneline[#, 0.5, 200] & /@ i, ImageSize -> size]]
POSTED BY: Piotr Wendykier
Posted 7 years ago

All the time seems to be in the Image[]. The rest is fast. I would contact tech support to see if the developers in that group can explain why. Sorry I could not be more helpful.

Regards

POSTED BY: Updating Name

Matthew,

You should provide some sample data otherwise its hard to say without trying things out. One thing that I notice is that imageResize is slow and not needed because you can specify the resolution in Image:

This is much faster

AbsoluteTiming[
 Image[RandomReal[1, {500, 500, 3}], ImageSize -> {200, 200}]]

than

AbsoluteTiming[
 Image[RandomReal[1, {500, 500, 3}]] // ImageResize[#, {200, 200}] &]

But beyond that I can't duplicate what you are doing without data.

Regards,

Neil

POSTED BY: Neil Singer
POSTED BY: Matthew Sottile
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard