Fastest way to extract image parts from GM16ImageMBS?

I use GraphicsMagickMBS to load a scanned 600 dpi picture containing 286 color patches, using 16 bits per color channel. The image is > 10,000 x 6,000, so rather not so small.
Next I locate each of the color patches, address 75% of their area and want to extract their ColorHistogram data.
Which basically works but is much slower than it would need to:

I found no CopyImage method in GM16Image, only CopyPicture with an additional geometry which would make me lose the 16 bit color resolution. So for getting the subpictures I write the original image to a GM16BlobMBS and in a loop create new geometries for the respective patch, then reading the blob into a new GM16ImageMBS with the additional geometry parameter.

I thought by what the docs told me this would create the subimage, but instead it creates a full copy of the original image – the geometry parameter is ignored.
That’s why I have to use a crop(geometry) afterwards to really get the patch I want.

This works, but creating a full copy and then cropping it is pretty slow. Is there a faster way to extract image parts of an original? Why doesn’t the read blob command crop the new image automatically?

EDIT: The same is valid if I use the GM16ImageMBS constructor from a blob and geometry. Geometry is ignored; I have to crop the patch after creation.

The constructor with blog and geometry is for vector graphics to scale to the desired size.

to copy a picture, you may just use the constructor taking a gmimage.

dim NewImage as new GM16ImageMBS(OldImage)

those two images then share the same pixel cache until one gets modified.

1 Like

Thank you! Much, much faster this way!

1 Like