Dealing with MONO12 images in memory
Robert <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.help |
|---|---|
| Message-ID | <[email protected]> |
(Trying this again since my last attempt to email the list seems to
have disappeared...)
Hello
I am new to Graphicsmagick and this list.
I'm using the graphicsmagick libraries with C++ on a Redhat linux
machine.
I have a program which captures images from GigE cameras using
Aravis libraries. I've been doing this successfully with images
in formats they call MONO8 and MONO12 for a while. Now I would
like to take advantage of Graphicsmagick to deal with other
formats (e.g. RGB8, BayerRG8, YUV422Packed...), get some loss-less
image compression, write files in different formats, etc., but I'm
running into a few problems. Hopefully, I'm missing something
simple?
Maybe this code snippet will be enough to show what I am talking
about:
Blob blob(pRaw16Image, (arv_width * arv_height *
nbytes));
printf("Blob data: 0x%x, length: %ld\n",
blob.data(), blob.length());
Image gmimage;
gmimage.read(blob, Geometry(arv_width, arv_height),
16);
gmimage.type(GrayscaleType);
// gmimage.magick("MONO12");
printf("gmimage.isValid: %d\n", gmimage.isValid());
gmimage.display();
if((Filename != NULL) && (strcmp(Filename,
"none") != 0)) {
printf(1, "writing file: %s\n", Filename);
gmimage.write(Filename);
}
pRaw16Image points to data which I know to contain grayscale data
represented in two bytes per pixel which I've been able to
manipulate/display using other code. nbytes is two in this
example.
Not sure about the proper use of the 3rd argument in the
image.read() function - I've tried both 16 and 2.
The commented out image.magick("MONO12") was a shot in the dark
that compiled o.k. but didn't do what I hoped.
gmimage.display() pops up a window that is the right size, but is
empty/black. The image info for the window says
Image:
Format:
Geometry: 1292x964
Class: DirectClass
Type: bilevel
Depth: 1 bits-per-pixel component
Channel Depths:
Gray: 1 bits
Channel Statistics:
Gray:
Minimum: 255.00 (1.0000)
Maximum: 0.00 (0.0000)
Obviously I am wrong on depth, min, max
I've tried several different file extensions on Filename. With
output like this:
for jpg:
width : 1292
height : 964
bpp : 16
format : MONO_12 (0x1100005)
Blob data: 0xee39f008, length: 2490976
gmimage.isValid: 1
writing file: gmimage3.jpg
terminate called after throwing an
instance of 'Magick::ErrorCoder'
what(): Magick: Application transferred too
few scanlines (gmimage3.jpg) reported by coders/jpeg.c:345
(JPEGErrorHandler)
Magick: abort due to signal 6 (SIGABRT) "Abort"...
for tiff:
terminate called after throwing an instance of
'Magick::ErrorCache'
what(): Magick: Pixel cache is not open
(gmimage3.tiff) reported by magick/pixel_cache.c:825
(AcquireCacheNexus)
Magick: abort due to signal 6 (SIGABRT) "Abort"...
for png
terminate called after throwing an instance of
'Magick::ErrorCoder'
what(): Magick: No IDATs written into file
(gmimage3.png) reported by coders/png.c:1084 (PNGErrorHandler)
Magick: abort due to signal 6 (SIGABRT) "Abort"...
Hopefully this is readable, and you'll be able to tell me I've
missed something basic. The size is right, but I obviously don't
understand proper formatting of either the blob or the image.
Thanks in advance for any help you might offer.
Rob
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Graphicsmagick-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help