So? How married are you to .bmp
?
You have, just before output off G’MIC’s image pipeline, exactly what you want. At least two non-corrupting formats, G’MIC’s own .cimg
and Portable Network Graphics .png
write out one GRAY image plane and read back in one GRAY plane, both 8 bpp. With BMP, G’MIC tries to write out a one plane GRAY, but what lands onto disk is a 3 plane (all identical), file; when G’MIC reads it back in, it pulls in three planes. Gory details:
gosgood@bertha ~ $ gmic i test.bmp [0] -jeje_normalize_local_variance 31.5,4.5,15.41,1,0,0 -fx_thin_edges[0] 0,18.5,0,100,100 o[0] test_out_too.cimg
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'test.bmp' at position 0 (1 image 256x240x1x3).
[gmic]-1./ Input copy of image [0] at position 1 (1 image 256x240x1x3).
[gmic]-2./ Output image [0] as cimg file 'test_out_too.cimg', with pixel type 'auto'.
[gmic]-2./ End G'MIC interpreter.
gosgood@bertha ~ $ gmic test_out_too.cimg
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'test_out_too.cimg' at position 0 (1 image 256x240x1x1). # <-- one 8 bpp plane coming in...
[gmic]-1./ Display image [0] = 'test_out_too.cimg'.
[0] = 'test_out_too.cimg':
size = (256,240,1,1) [240 Kio of floats]. # <-- one 8 bpp plane image on the stack.
data = (255,255,255,255,255,255,255,255,255,255,255,255,(...),255,255,255,255,255,255,255,255,255,255,255,255).
min = 0, max = 255, mean = 222.465, std = 85.0764, coords_min = (150,0,0,0), coords_max = (0,0,0,0).
[gmic]-1./ End G'MIC interpreter.
gosgood@bertha ~ $ gmic i test.bmp [0] -jeje_normalize_local_variance 31.5,4.5,15.41,1,0,0 -fx_thin_edges[0] 0,18.5,0,100,100 o[0] test_out_too.png
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'test.bmp' at position 0 (1 image 256x240x1x3).
[gmic]-1./ Input copy of image [0] at position 1 (1 image 256x240x1x3).
[gmic]-2./ Output image [0] as png file 'test_out_too.png' (1 image 256x240x1x1). # <-- G'MIC asks the .PNG delegate to write out a one 8 bpp plane image
[gmic]-2./ End G'MIC interpreter.
gosgood@bertha ~ $ gmic test_out_too.png
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'test_out_too.png' at position 0 (1 image 256x240x1x1). # <-- G'MIC reads back in a one 8 bpp plane image
[gmic]-1./ Display image [0] = 'test_out_too.png'.
[0] = 'test_out_too.png':
size = (256,240,1,1) [240 Kio of floats]. #<-- and a one plane, 8 bpp is on the image stack.
data = (255,255,255,255,255,255,255,255,255,255,255,255,(...),255,255,255,255,255,255,255,255,255,255,255,255).
min = 0, max = 255, mean = 222.465, std = 85.0764, coords_min = (150,0,0,0), coords_max = (0,0,0,0).
[gmic]-1./ End G'MIC interpreter.
gosgood@bertha ~ $ gmic i test.bmp [0] -jeje_normalize_local_variance 31.5,4.5,15.41,1,0,0 -fx_thin_edges[0] 0,18.5,0,100,100 o[0] test_out_too.bmp
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'test.bmp' at position 0 (1 image 256x240x1x3).
[gmic]-1./ Input copy of image [0] at position 1 (1 image 256x240x1x3).
[gmic]-2./ Output image [0] as bmp file 'test_out_too.bmp' (1 image 256x240x1x1).# <-- G'MIC asks the .BMP delegate to write out a one 8 bpp plane image
[gmic]-2./ End G'MIC interpreter.
gosgood@bertha ~ $ gmic test_out_too.bmp
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'test_out_too.bmp' at position 0 (1 image 256x240x1x3). #<-- !!! G'MIC reads back in a three plane 24 bpp image from what was actually written to disk!
[gmic]-1./ Display image [0] = 'test_out_too.bmp'.
[0] = 'test_out_too.bmp':
size = (256,240,1,3) [720 Kio of floats]. #<-- A three plane, 24 bpp is on G'MIC's image stack: 3 × 240 = 720 kilos
data = (255,255,255,255,255,255,255,255,255,255,255,255,(...),255,255,255,255,255,255,255,255,255,255,255,255).
min = 0, max = 255, mean = 222.465, std = 85.076, coords_min = (150,0,0,0), coords_max = (0,0,0,0).
[gmic]-1./ End G'MIC interpreter.
In linux land, where I live, I believe G’MIC uses ImageMagick as a delegate to write formats like .png
and .bmp
and has no idea what happens after the hand-off. (Plenty of people here can correct me if I’m wrong). At this stage, should I go poof! and suddenly become you, I’d be asking myself how important is the particularity of a file format to my overall workflow. Just because I happen to have a toy that reads .bmp
? Or is the .bmp
reader inextricably mangled with the C code that also does the analytics — that would be a problem ( Ah, me. No Separation of Concerns — shot myself in the foot a billion times not heeding that…). Judging from the links I’ve looked at, the world, in general, seems to have difficulty putting just one plane, 8 bpp, into a .bmp
file…