简体   繁体   中英

Library or approach to extract RGB channels values in RAW image

I'm searching for a solution for image comparison for different purposes. To make it possible to analyze, I need access to every pixel channels values. For example: RAW format which supported by a lot of cameras.

* Is there some open source library to get access to channels, or is it possible to extract it directly as byte values?
* Currently I'm using bitmap_image reader ( https://github.com/ArashPartow/bitmap ), but not a good idea to convert everytime raw image bo BMP to analyze, I've related repo added to github , it kind of library written on C++14

Please suggest fastest way to access to data of image, thanks.

Use ImageMagick which is installed on most Linux distros and is available for macOS and Windows.

At the command-line:

# Convert NEF raw file to 16-bit RGB data
magick image.nef -depth 16 rgb:image.bin

# Convert CR2 raw file to 8-bit RGB data
magick image.cr2 -depth 8 rgb:image.bin

Or use it with popen() in C/C++ and have it write on stdout :

magick image.dng -depth 16 rgb:-

and then read in C/C++.


If you want to identify the dimensions of an image before reading:

magick identify temp.png
temp.png PNG 640x480 640x480+0+0 8-bit Gray 2c 12348B 0.000u 0:00.009

If using version 6, replace magick with convert , and replace magick identify with identify .


Alternatively, look at NetPBM PPM format (see P6 format here ) and develop some code to read it then just convert anything and everything into PPM format with ImageMagick and read that, which gives you the dimensions at the start:

magick image.nef -depth 16 ppm:-
magick image.cr2 -depth 8  ppm:- 

Note that this is exactly the strategy adopted by CImg .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM